babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4100. static readonly GEQUAL: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Specifies whether the left control stick should be Y-inverted
  12300. */
  12301. protected _invertLeftStickY: boolean;
  12302. /**
  12303. * Specifies if the gamepad has been connected
  12304. */
  12305. readonly isConnected: boolean;
  12306. /**
  12307. * Initializes the gamepad
  12308. * @param id The id of the gamepad
  12309. * @param index The index of the gamepad
  12310. * @param browserGamepad The browser gamepad
  12311. * @param leftStickX The x component of the left joystick
  12312. * @param leftStickY The y component of the left joystick
  12313. * @param rightStickX The x component of the right joystick
  12314. * @param rightStickY The y component of the right joystick
  12315. */
  12316. constructor(
  12317. /**
  12318. * The id of the gamepad
  12319. */
  12320. id: string,
  12321. /**
  12322. * The index of the gamepad
  12323. */
  12324. index: number,
  12325. /**
  12326. * The browser gamepad
  12327. */
  12328. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12329. /**
  12330. * Callback triggered when the left joystick has changed
  12331. * @param callback
  12332. */
  12333. onleftstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Callback triggered when the right joystick has changed
  12336. * @param callback
  12337. */
  12338. onrightstickchanged(callback: (values: StickValues) => void): void;
  12339. /**
  12340. * Gets the left joystick
  12341. */
  12342. /**
  12343. * Sets the left joystick values
  12344. */
  12345. leftStick: StickValues;
  12346. /**
  12347. * Gets the right joystick
  12348. */
  12349. /**
  12350. * Sets the right joystick value
  12351. */
  12352. rightStick: StickValues;
  12353. /**
  12354. * Updates the gamepad joystick positions
  12355. */
  12356. update(): void;
  12357. /**
  12358. * Disposes the gamepad
  12359. */
  12360. dispose(): void;
  12361. }
  12362. /**
  12363. * Represents a generic gamepad
  12364. */
  12365. export class GenericPad extends Gamepad {
  12366. private _buttons;
  12367. private _onbuttondown;
  12368. private _onbuttonup;
  12369. /**
  12370. * Observable triggered when a button has been pressed
  12371. */
  12372. onButtonDownObservable: Observable<number>;
  12373. /**
  12374. * Observable triggered when a button has been released
  12375. */
  12376. onButtonUpObservable: Observable<number>;
  12377. /**
  12378. * Callback triggered when a button has been pressed
  12379. * @param callback Called when a button has been pressed
  12380. */
  12381. onbuttondown(callback: (buttonPressed: number) => void): void;
  12382. /**
  12383. * Callback triggered when a button has been released
  12384. * @param callback Called when a button has been released
  12385. */
  12386. onbuttonup(callback: (buttonReleased: number) => void): void;
  12387. /**
  12388. * Initializes the generic gamepad
  12389. * @param id The id of the generic gamepad
  12390. * @param index The index of the generic gamepad
  12391. * @param browserGamepad The browser gamepad
  12392. */
  12393. constructor(id: string, index: number, browserGamepad: any);
  12394. private _setButtonValue;
  12395. /**
  12396. * Updates the generic gamepad
  12397. */
  12398. update(): void;
  12399. /**
  12400. * Disposes the generic gamepad
  12401. */
  12402. dispose(): void;
  12403. }
  12404. }
  12405. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12406. import { Nullable } from "babylonjs/types";
  12407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12408. import { Scene } from "babylonjs/scene";
  12409. module "babylonjs/Engines/engine" {
  12410. interface Engine {
  12411. /**
  12412. * Creates a raw texture
  12413. * @param data defines the data to store in the texture
  12414. * @param width defines the width of the texture
  12415. * @param height defines the height of the texture
  12416. * @param format defines the format of the data
  12417. * @param generateMipMaps defines if the engine should generate the mip levels
  12418. * @param invertY defines if data must be stored with Y axis inverted
  12419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12420. * @param compression defines the compression used (null by default)
  12421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12422. * @returns the raw texture inside an InternalTexture
  12423. */
  12424. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12425. /**
  12426. * Update a raw texture
  12427. * @param texture defines the texture to update
  12428. * @param data defines the data to store in the texture
  12429. * @param format defines the format of the data
  12430. * @param invertY defines if data must be stored with Y axis inverted
  12431. */
  12432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12433. /**
  12434. * Update a raw texture
  12435. * @param texture defines the texture to update
  12436. * @param data defines the data to store in the texture
  12437. * @param format defines the format of the data
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @param compression defines the compression used (null by default)
  12440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12441. */
  12442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12443. /**
  12444. * Creates a new raw cube texture
  12445. * @param data defines the array of data to use to create each face
  12446. * @param size defines the size of the textures
  12447. * @param format defines the format of the data
  12448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12449. * @param generateMipMaps defines if the engine should generate the mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compression used (null by default)
  12453. * @returns the cube texture as an InternalTexture
  12454. */
  12455. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12456. /**
  12457. * Update a raw cube texture
  12458. * @param texture defines the texture to udpdate
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw cube texture
  12467. * @param texture defines the texture to udpdate
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @param invertY defines if data must be stored with Y axis inverted
  12472. * @param compression defines the compression used (null by default)
  12473. */
  12474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12475. /**
  12476. * Update a raw cube texture
  12477. * @param texture defines the texture to udpdate
  12478. * @param data defines the data to store
  12479. * @param format defines the data format
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @param invertY defines if data must be stored with Y axis inverted
  12482. * @param compression defines the compression used (null by default)
  12483. * @param level defines which level of the texture to update
  12484. */
  12485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @returns the cube texture as an InternalTexture
  12499. */
  12500. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12501. /**
  12502. * Creates a new raw cube texture from a specified url
  12503. * @param url defines the url where the data is located
  12504. * @param scene defines the current scene
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param noMipmap defines if the engine should avoid generating the mip levels
  12509. * @param callback defines a callback used to extract texture data from loaded data
  12510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12511. * @param onLoad defines a callback called when texture is loaded
  12512. * @param onError defines a callback called if there is an error
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param invertY defines if data must be stored with Y axis inverted
  12515. * @returns the cube texture as an InternalTexture
  12516. */
  12517. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12518. /**
  12519. * Creates a new raw 3D texture
  12520. * @param data defines the data used to create the texture
  12521. * @param width defines the width of the texture
  12522. * @param height defines the height of the texture
  12523. * @param depth defines the depth of the texture
  12524. * @param format defines the format of the texture
  12525. * @param generateMipMaps defines if the engine must generate mip levels
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12528. * @param compression defines the compressed used (can be null)
  12529. * @param textureType defines the compressed used (can be null)
  12530. * @returns a new raw 3D texture (stored in an InternalTexture)
  12531. */
  12532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12533. /**
  12534. * Update a raw 3D texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store
  12537. * @param format defines the data format
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. */
  12540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12541. /**
  12542. * Update a raw 3D texture
  12543. * @param texture defines the texture to update
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param invertY defines if data must be stored with Y axis inverted
  12547. * @param compression defines the used compression (can be null)
  12548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12549. */
  12550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12551. }
  12552. }
  12553. }
  12554. declare module "babylonjs/Materials/Textures/rawTexture" {
  12555. import { Scene } from "babylonjs/scene";
  12556. import { Texture } from "babylonjs/Materials/Textures/texture";
  12557. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12558. /**
  12559. * Raw texture can help creating a texture directly from an array of data.
  12560. * This can be super useful if you either get the data from an uncompressed source or
  12561. * if you wish to create your texture pixel by pixel.
  12562. */
  12563. export class RawTexture extends Texture {
  12564. /**
  12565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12566. */
  12567. format: number;
  12568. private _engine;
  12569. /**
  12570. * Instantiates a new RawTexture.
  12571. * Raw texture can help creating a texture directly from an array of data.
  12572. * This can be super useful if you either get the data from an uncompressed source or
  12573. * if you wish to create your texture pixel by pixel.
  12574. * @param data define the array of data to use to create the texture
  12575. * @param width define the width of the texture
  12576. * @param height define the height of the texture
  12577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. * @param scene define the scene the texture belongs to
  12579. * @param generateMipMaps define whether mip maps should be generated or not
  12580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12583. */
  12584. constructor(data: ArrayBufferView, width: number, height: number,
  12585. /**
  12586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12587. */
  12588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12589. /**
  12590. * Updates the texture underlying data.
  12591. * @param data Define the new data of the texture
  12592. */
  12593. update(data: ArrayBufferView): void;
  12594. /**
  12595. * Creates a luminance texture from some data.
  12596. * @param data Define the texture data
  12597. * @param width Define the width of the texture
  12598. * @param height Define the height of the texture
  12599. * @param scene Define the scene the texture belongs to
  12600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12603. * @returns the luminance texture
  12604. */
  12605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12606. /**
  12607. * Creates a luminance alpha texture from some data.
  12608. * @param data Define the texture data
  12609. * @param width Define the width of the texture
  12610. * @param height Define the height of the texture
  12611. * @param scene Define the scene the texture belongs to
  12612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12615. * @returns the luminance alpha texture
  12616. */
  12617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12618. /**
  12619. * Creates an alpha texture from some data.
  12620. * @param data Define the texture data
  12621. * @param width Define the width of the texture
  12622. * @param height Define the height of the texture
  12623. * @param scene Define the scene the texture belongs to
  12624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12627. * @returns the alpha texture
  12628. */
  12629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12630. /**
  12631. * Creates a RGB texture from some data.
  12632. * @param data Define the texture data
  12633. * @param width Define the width of the texture
  12634. * @param height Define the height of the texture
  12635. * @param scene Define the scene the texture belongs to
  12636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12640. * @returns the RGB alpha texture
  12641. */
  12642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12643. /**
  12644. * Creates a RGBA texture from some data.
  12645. * @param data Define the texture data
  12646. * @param width Define the width of the texture
  12647. * @param height Define the height of the texture
  12648. * @param scene Define the scene the texture belongs to
  12649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12653. * @returns the RGBA texture
  12654. */
  12655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12656. /**
  12657. * Creates a R texture from some data.
  12658. * @param data Define the texture data
  12659. * @param width Define the width of the texture
  12660. * @param height Define the height of the texture
  12661. * @param scene Define the scene the texture belongs to
  12662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12666. * @returns the R texture
  12667. */
  12668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12669. }
  12670. }
  12671. declare module "babylonjs/Maths/math.size" {
  12672. /**
  12673. * Interface for the size containing width and height
  12674. */
  12675. export interface ISize {
  12676. /**
  12677. * Width
  12678. */
  12679. width: number;
  12680. /**
  12681. * Heighht
  12682. */
  12683. height: number;
  12684. }
  12685. /**
  12686. * Size containing widht and height
  12687. */
  12688. export class Size implements ISize {
  12689. /**
  12690. * Width
  12691. */
  12692. width: number;
  12693. /**
  12694. * Height
  12695. */
  12696. height: number;
  12697. /**
  12698. * Creates a Size object from the given width and height (floats).
  12699. * @param width width of the new size
  12700. * @param height height of the new size
  12701. */
  12702. constructor(width: number, height: number);
  12703. /**
  12704. * Returns a string with the Size width and height
  12705. * @returns a string with the Size width and height
  12706. */
  12707. toString(): string;
  12708. /**
  12709. * "Size"
  12710. * @returns the string "Size"
  12711. */
  12712. getClassName(): string;
  12713. /**
  12714. * Returns the Size hash code.
  12715. * @returns a hash code for a unique width and height
  12716. */
  12717. getHashCode(): number;
  12718. /**
  12719. * Updates the current size from the given one.
  12720. * @param src the given size
  12721. */
  12722. copyFrom(src: Size): void;
  12723. /**
  12724. * Updates in place the current Size from the given floats.
  12725. * @param width width of the new size
  12726. * @param height height of the new size
  12727. * @returns the updated Size.
  12728. */
  12729. copyFromFloats(width: number, height: number): Size;
  12730. /**
  12731. * Updates in place the current Size from the given floats.
  12732. * @param width width to set
  12733. * @param height height to set
  12734. * @returns the updated Size.
  12735. */
  12736. set(width: number, height: number): Size;
  12737. /**
  12738. * Multiplies the width and height by numbers
  12739. * @param w factor to multiple the width by
  12740. * @param h factor to multiple the height by
  12741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12742. */
  12743. multiplyByFloats(w: number, h: number): Size;
  12744. /**
  12745. * Clones the size
  12746. * @returns a new Size copied from the given one.
  12747. */
  12748. clone(): Size;
  12749. /**
  12750. * True if the current Size and the given one width and height are strictly equal.
  12751. * @param other the other size to compare against
  12752. * @returns True if the current Size and the given one width and height are strictly equal.
  12753. */
  12754. equals(other: Size): boolean;
  12755. /**
  12756. * The surface of the Size : width * height (float).
  12757. */
  12758. readonly surface: number;
  12759. /**
  12760. * Create a new size of zero
  12761. * @returns a new Size set to (0.0, 0.0)
  12762. */
  12763. static Zero(): Size;
  12764. /**
  12765. * Sums the width and height of two sizes
  12766. * @param otherSize size to add to this size
  12767. * @returns a new Size set as the addition result of the current Size and the given one.
  12768. */
  12769. add(otherSize: Size): Size;
  12770. /**
  12771. * Subtracts the width and height of two
  12772. * @param otherSize size to subtract to this size
  12773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12774. */
  12775. subtract(otherSize: Size): Size;
  12776. /**
  12777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12778. * @param start starting size to lerp between
  12779. * @param end end size to lerp between
  12780. * @param amount amount to lerp between the start and end values
  12781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. */
  12783. static Lerp(start: Size, end: Size, amount: number): Size;
  12784. }
  12785. }
  12786. declare module "babylonjs/Animations/runtimeAnimation" {
  12787. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12788. import { Animatable } from "babylonjs/Animations/animatable";
  12789. import { Scene } from "babylonjs/scene";
  12790. /**
  12791. * Defines a runtime animation
  12792. */
  12793. export class RuntimeAnimation {
  12794. private _events;
  12795. /**
  12796. * The current frame of the runtime animation
  12797. */
  12798. private _currentFrame;
  12799. /**
  12800. * The animation used by the runtime animation
  12801. */
  12802. private _animation;
  12803. /**
  12804. * The target of the runtime animation
  12805. */
  12806. private _target;
  12807. /**
  12808. * The initiating animatable
  12809. */
  12810. private _host;
  12811. /**
  12812. * The original value of the runtime animation
  12813. */
  12814. private _originalValue;
  12815. /**
  12816. * The original blend value of the runtime animation
  12817. */
  12818. private _originalBlendValue;
  12819. /**
  12820. * The offsets cache of the runtime animation
  12821. */
  12822. private _offsetsCache;
  12823. /**
  12824. * The high limits cache of the runtime animation
  12825. */
  12826. private _highLimitsCache;
  12827. /**
  12828. * Specifies if the runtime animation has been stopped
  12829. */
  12830. private _stopped;
  12831. /**
  12832. * The blending factor of the runtime animation
  12833. */
  12834. private _blendingFactor;
  12835. /**
  12836. * The BabylonJS scene
  12837. */
  12838. private _scene;
  12839. /**
  12840. * The current value of the runtime animation
  12841. */
  12842. private _currentValue;
  12843. /** @hidden */
  12844. _animationState: _IAnimationState;
  12845. /**
  12846. * The active target of the runtime animation
  12847. */
  12848. private _activeTargets;
  12849. private _currentActiveTarget;
  12850. private _directTarget;
  12851. /**
  12852. * The target path of the runtime animation
  12853. */
  12854. private _targetPath;
  12855. /**
  12856. * The weight of the runtime animation
  12857. */
  12858. private _weight;
  12859. /**
  12860. * The ratio offset of the runtime animation
  12861. */
  12862. private _ratioOffset;
  12863. /**
  12864. * The previous delay of the runtime animation
  12865. */
  12866. private _previousDelay;
  12867. /**
  12868. * The previous ratio of the runtime animation
  12869. */
  12870. private _previousRatio;
  12871. private _enableBlending;
  12872. private _keys;
  12873. private _minFrame;
  12874. private _maxFrame;
  12875. private _minValue;
  12876. private _maxValue;
  12877. private _targetIsArray;
  12878. /**
  12879. * Gets the current frame of the runtime animation
  12880. */
  12881. readonly currentFrame: number;
  12882. /**
  12883. * Gets the weight of the runtime animation
  12884. */
  12885. readonly weight: number;
  12886. /**
  12887. * Gets the current value of the runtime animation
  12888. */
  12889. readonly currentValue: any;
  12890. /**
  12891. * Gets the target path of the runtime animation
  12892. */
  12893. readonly targetPath: string;
  12894. /**
  12895. * Gets the actual target of the runtime animation
  12896. */
  12897. readonly target: any;
  12898. /** @hidden */
  12899. _onLoop: () => void;
  12900. /**
  12901. * Create a new RuntimeAnimation object
  12902. * @param target defines the target of the animation
  12903. * @param animation defines the source animation object
  12904. * @param scene defines the hosting scene
  12905. * @param host defines the initiating Animatable
  12906. */
  12907. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12908. private _preparePath;
  12909. /**
  12910. * Gets the animation from the runtime animation
  12911. */
  12912. readonly animation: Animation;
  12913. /**
  12914. * Resets the runtime animation to the beginning
  12915. * @param restoreOriginal defines whether to restore the target property to the original value
  12916. */
  12917. reset(restoreOriginal?: boolean): void;
  12918. /**
  12919. * Specifies if the runtime animation is stopped
  12920. * @returns Boolean specifying if the runtime animation is stopped
  12921. */
  12922. isStopped(): boolean;
  12923. /**
  12924. * Disposes of the runtime animation
  12925. */
  12926. dispose(): void;
  12927. /**
  12928. * Apply the interpolated value to the target
  12929. * @param currentValue defines the value computed by the animation
  12930. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12931. */
  12932. setValue(currentValue: any, weight: number): void;
  12933. private _getOriginalValues;
  12934. private _setValue;
  12935. /**
  12936. * Gets the loop pmode of the runtime animation
  12937. * @returns Loop Mode
  12938. */
  12939. private _getCorrectLoopMode;
  12940. /**
  12941. * Move the current animation to a given frame
  12942. * @param frame defines the frame to move to
  12943. */
  12944. goToFrame(frame: number): void;
  12945. /**
  12946. * @hidden Internal use only
  12947. */
  12948. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12949. /**
  12950. * Execute the current animation
  12951. * @param delay defines the delay to add to the current frame
  12952. * @param from defines the lower bound of the animation range
  12953. * @param to defines the upper bound of the animation range
  12954. * @param loop defines if the current animation must loop
  12955. * @param speedRatio defines the current speed ratio
  12956. * @param weight defines the weight of the animation (default is -1 so no weight)
  12957. * @param onLoop optional callback called when animation loops
  12958. * @returns a boolean indicating if the animation is running
  12959. */
  12960. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12961. }
  12962. }
  12963. declare module "babylonjs/Animations/animatable" {
  12964. import { Animation } from "babylonjs/Animations/animation";
  12965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12966. import { Nullable } from "babylonjs/types";
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Scene } from "babylonjs/scene";
  12969. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12970. import { Node } from "babylonjs/node";
  12971. /**
  12972. * Class used to store an actual running animation
  12973. */
  12974. export class Animatable {
  12975. /** defines the target object */
  12976. target: any;
  12977. /** defines the starting frame number (default is 0) */
  12978. fromFrame: number;
  12979. /** defines the ending frame number (default is 100) */
  12980. toFrame: number;
  12981. /** defines if the animation must loop (default is false) */
  12982. loopAnimation: boolean;
  12983. /** defines a callback to call when animation ends if it is not looping */
  12984. onAnimationEnd?: (() => void) | null | undefined;
  12985. /** defines a callback to call when animation loops */
  12986. onAnimationLoop?: (() => void) | null | undefined;
  12987. private _localDelayOffset;
  12988. private _pausedDelay;
  12989. private _runtimeAnimations;
  12990. private _paused;
  12991. private _scene;
  12992. private _speedRatio;
  12993. private _weight;
  12994. private _syncRoot;
  12995. /**
  12996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12997. * This will only apply for non looping animation (default is true)
  12998. */
  12999. disposeOnEnd: boolean;
  13000. /**
  13001. * Gets a boolean indicating if the animation has started
  13002. */
  13003. animationStarted: boolean;
  13004. /**
  13005. * Observer raised when the animation ends
  13006. */
  13007. onAnimationEndObservable: Observable<Animatable>;
  13008. /**
  13009. * Observer raised when the animation loops
  13010. */
  13011. onAnimationLoopObservable: Observable<Animatable>;
  13012. /**
  13013. * Gets the root Animatable used to synchronize and normalize animations
  13014. */
  13015. readonly syncRoot: Nullable<Animatable>;
  13016. /**
  13017. * Gets the current frame of the first RuntimeAnimation
  13018. * Used to synchronize Animatables
  13019. */
  13020. readonly masterFrame: number;
  13021. /**
  13022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13023. */
  13024. weight: number;
  13025. /**
  13026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13027. */
  13028. speedRatio: number;
  13029. /**
  13030. * Creates a new Animatable
  13031. * @param scene defines the hosting scene
  13032. * @param target defines the target object
  13033. * @param fromFrame defines the starting frame number (default is 0)
  13034. * @param toFrame defines the ending frame number (default is 100)
  13035. * @param loopAnimation defines if the animation must loop (default is false)
  13036. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13037. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13038. * @param animations defines a group of animation to add to the new Animatable
  13039. * @param onAnimationLoop defines a callback to call when animation loops
  13040. */
  13041. constructor(scene: Scene,
  13042. /** defines the target object */
  13043. target: any,
  13044. /** defines the starting frame number (default is 0) */
  13045. fromFrame?: number,
  13046. /** defines the ending frame number (default is 100) */
  13047. toFrame?: number,
  13048. /** defines if the animation must loop (default is false) */
  13049. loopAnimation?: boolean, speedRatio?: number,
  13050. /** defines a callback to call when animation ends if it is not looping */
  13051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13052. /** defines a callback to call when animation loops */
  13053. onAnimationLoop?: (() => void) | null | undefined);
  13054. /**
  13055. * Synchronize and normalize current Animatable with a source Animatable
  13056. * This is useful when using animation weights and when animations are not of the same length
  13057. * @param root defines the root Animatable to synchronize with
  13058. * @returns the current Animatable
  13059. */
  13060. syncWith(root: Animatable): Animatable;
  13061. /**
  13062. * Gets the list of runtime animations
  13063. * @returns an array of RuntimeAnimation
  13064. */
  13065. getAnimations(): RuntimeAnimation[];
  13066. /**
  13067. * Adds more animations to the current animatable
  13068. * @param target defines the target of the animations
  13069. * @param animations defines the new animations to add
  13070. */
  13071. appendAnimations(target: any, animations: Animation[]): void;
  13072. /**
  13073. * Gets the source animation for a specific property
  13074. * @param property defines the propertyu to look for
  13075. * @returns null or the source animation for the given property
  13076. */
  13077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13078. /**
  13079. * Gets the runtime animation for a specific property
  13080. * @param property defines the propertyu to look for
  13081. * @returns null or the runtime animation for the given property
  13082. */
  13083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13084. /**
  13085. * Resets the animatable to its original state
  13086. */
  13087. reset(): void;
  13088. /**
  13089. * Allows the animatable to blend with current running animations
  13090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13091. * @param blendingSpeed defines the blending speed to use
  13092. */
  13093. enableBlending(blendingSpeed: number): void;
  13094. /**
  13095. * Disable animation blending
  13096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13097. */
  13098. disableBlending(): void;
  13099. /**
  13100. * Jump directly to a given frame
  13101. * @param frame defines the frame to jump to
  13102. */
  13103. goToFrame(frame: number): void;
  13104. /**
  13105. * Pause the animation
  13106. */
  13107. pause(): void;
  13108. /**
  13109. * Restart the animation
  13110. */
  13111. restart(): void;
  13112. private _raiseOnAnimationEnd;
  13113. /**
  13114. * Stop and delete the current animation
  13115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13116. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13117. */
  13118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13119. /**
  13120. * Wait asynchronously for the animation to end
  13121. * @returns a promise which will be fullfilled when the animation ends
  13122. */
  13123. waitAsync(): Promise<Animatable>;
  13124. /** @hidden */
  13125. _animate(delay: number): boolean;
  13126. }
  13127. module "babylonjs/scene" {
  13128. interface Scene {
  13129. /** @hidden */
  13130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13131. /** @hidden */
  13132. _processLateAnimationBindingsForMatrices(holder: {
  13133. totalWeight: number;
  13134. animations: RuntimeAnimation[];
  13135. originalValue: Matrix;
  13136. }): any;
  13137. /** @hidden */
  13138. _processLateAnimationBindingsForQuaternions(holder: {
  13139. totalWeight: number;
  13140. animations: RuntimeAnimation[];
  13141. originalValue: Quaternion;
  13142. }, refQuaternion: Quaternion): Quaternion;
  13143. /** @hidden */
  13144. _processLateAnimationBindings(): void;
  13145. /**
  13146. * Will start the animation sequence of a given target
  13147. * @param target defines the target
  13148. * @param from defines from which frame should animation start
  13149. * @param to defines until which frame should animation run.
  13150. * @param weight defines the weight to apply to the animation (1.0 by default)
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the animatable object created for this animation
  13158. */
  13159. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13160. /**
  13161. * Will start the animation sequence of a given target
  13162. * @param target defines the target
  13163. * @param from defines from which frame should animation start
  13164. * @param to defines until which frame should animation run.
  13165. * @param loop defines if the animation loops
  13166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13167. * @param onAnimationEnd defines the function to be executed when the animation ends
  13168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13170. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the animatable object created for this animation
  13173. */
  13174. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Will start the animation sequence of a given target and its hierarchy
  13177. * @param target defines the target
  13178. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the list of created animatables
  13189. */
  13190. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13191. /**
  13192. * Begin a new animation on a given node
  13193. * @param target defines the target where the animation will take place
  13194. * @param animations defines the list of animations to start
  13195. * @param from defines the initial value
  13196. * @param to defines the final value
  13197. * @param loop defines if you want animation to loop (off by default)
  13198. * @param speedRatio defines the speed ratio to apply to all animations
  13199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13200. * @param onAnimationLoop defines the callback to call when an animation loops
  13201. * @returns the list of created animatables
  13202. */
  13203. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13204. /**
  13205. * Begin a new animation on a given node and its hierarchy
  13206. * @param target defines the root node where the animation will take place
  13207. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13208. * @param animations defines the list of animations to start
  13209. * @param from defines the initial value
  13210. * @param to defines the final value
  13211. * @param loop defines if you want animation to loop (off by default)
  13212. * @param speedRatio defines the speed ratio to apply to all animations
  13213. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13214. * @param onAnimationLoop defines the callback to call when an animation loops
  13215. * @returns the list of animatables created for all nodes
  13216. */
  13217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13218. /**
  13219. * Gets the animatable associated with a specific target
  13220. * @param target defines the target of the animatable
  13221. * @returns the required animatable if found
  13222. */
  13223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13224. /**
  13225. * Gets all animatables associated with a given target
  13226. * @param target defines the target to look animatables for
  13227. * @returns an array of Animatables
  13228. */
  13229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13230. /**
  13231. * Stops and removes all animations that have been applied to the scene
  13232. */
  13233. stopAllAnimations(): void;
  13234. }
  13235. }
  13236. module "babylonjs/Bones/bone" {
  13237. interface Bone {
  13238. /**
  13239. * Copy an animation range from another bone
  13240. * @param source defines the source bone
  13241. * @param rangeName defines the range name to copy
  13242. * @param frameOffset defines the frame offset
  13243. * @param rescaleAsRequired defines if rescaling must be applied if required
  13244. * @param skelDimensionsRatio defines the scaling ratio
  13245. * @returns true if operation was successful
  13246. */
  13247. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13248. }
  13249. }
  13250. }
  13251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13252. /**
  13253. * Class used to override all child animations of a given target
  13254. */
  13255. export class AnimationPropertiesOverride {
  13256. /**
  13257. * Gets or sets a value indicating if animation blending must be used
  13258. */
  13259. enableBlending: boolean;
  13260. /**
  13261. * Gets or sets the blending speed to use when enableBlending is true
  13262. */
  13263. blendingSpeed: number;
  13264. /**
  13265. * Gets or sets the default loop mode to use
  13266. */
  13267. loopMode: number;
  13268. }
  13269. }
  13270. declare module "babylonjs/Bones/skeleton" {
  13271. import { Bone } from "babylonjs/Bones/bone";
  13272. import { Observable } from "babylonjs/Misc/observable";
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Scene } from "babylonjs/scene";
  13275. import { Nullable } from "babylonjs/types";
  13276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13277. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13278. import { Animatable } from "babylonjs/Animations/animatable";
  13279. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13280. import { Animation } from "babylonjs/Animations/animation";
  13281. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13284. /**
  13285. * Class used to handle skinning animations
  13286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13287. */
  13288. export class Skeleton implements IAnimatable {
  13289. /** defines the skeleton name */
  13290. name: string;
  13291. /** defines the skeleton Id */
  13292. id: string;
  13293. /**
  13294. * Defines the list of child bones
  13295. */
  13296. bones: Bone[];
  13297. /**
  13298. * Defines an estimate of the dimension of the skeleton at rest
  13299. */
  13300. dimensionsAtRest: Vector3;
  13301. /**
  13302. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13303. */
  13304. needInitialSkinMatrix: boolean;
  13305. /**
  13306. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13307. */
  13308. overrideMesh: Nullable<AbstractMesh>;
  13309. /**
  13310. * Gets the list of animations attached to this skeleton
  13311. */
  13312. animations: Array<Animation>;
  13313. private _scene;
  13314. private _isDirty;
  13315. private _transformMatrices;
  13316. private _transformMatrixTexture;
  13317. private _meshesWithPoseMatrix;
  13318. private _animatables;
  13319. private _identity;
  13320. private _synchronizedWithMesh;
  13321. private _ranges;
  13322. private _lastAbsoluteTransformsUpdateId;
  13323. private _canUseTextureForBones;
  13324. private _uniqueId;
  13325. /** @hidden */
  13326. _numBonesWithLinkedTransformNode: number;
  13327. /** @hidden */
  13328. _hasWaitingData: Nullable<boolean>;
  13329. /**
  13330. * Specifies if the skeleton should be serialized
  13331. */
  13332. doNotSerialize: boolean;
  13333. private _useTextureToStoreBoneMatrices;
  13334. /**
  13335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13336. * Please note that this option is not available if the hardware does not support it
  13337. */
  13338. useTextureToStoreBoneMatrices: boolean;
  13339. private _animationPropertiesOverride;
  13340. /**
  13341. * Gets or sets the animation properties override
  13342. */
  13343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. /**
  13345. * List of inspectable custom properties (used by the Inspector)
  13346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13347. */
  13348. inspectableCustomProperties: IInspectable[];
  13349. /**
  13350. * An observable triggered before computing the skeleton's matrices
  13351. */
  13352. onBeforeComputeObservable: Observable<Skeleton>;
  13353. /**
  13354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13355. */
  13356. readonly isUsingTextureForMatrices: boolean;
  13357. /**
  13358. * Gets the unique ID of this skeleton
  13359. */
  13360. readonly uniqueId: number;
  13361. /**
  13362. * Creates a new skeleton
  13363. * @param name defines the skeleton name
  13364. * @param id defines the skeleton Id
  13365. * @param scene defines the hosting scene
  13366. */
  13367. constructor(
  13368. /** defines the skeleton name */
  13369. name: string,
  13370. /** defines the skeleton Id */
  13371. id: string, scene: Scene);
  13372. /**
  13373. * Gets the current object class name.
  13374. * @return the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Returns an array containing the root bones
  13379. * @returns an array containing the root bones
  13380. */
  13381. getChildren(): Array<Bone>;
  13382. /**
  13383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13385. * @returns a Float32Array containing matrices data
  13386. */
  13387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13388. /**
  13389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13391. * @returns a raw texture containing the data
  13392. */
  13393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13394. /**
  13395. * Gets the current hosting scene
  13396. * @returns a scene object
  13397. */
  13398. getScene(): Scene;
  13399. /**
  13400. * Gets a string representing the current skeleton data
  13401. * @param fullDetails defines a boolean indicating if we want a verbose version
  13402. * @returns a string representing the current skeleton data
  13403. */
  13404. toString(fullDetails?: boolean): string;
  13405. /**
  13406. * Get bone's index searching by name
  13407. * @param name defines bone's name to search for
  13408. * @return the indice of the bone. Returns -1 if not found
  13409. */
  13410. getBoneIndexByName(name: string): number;
  13411. /**
  13412. * Creater a new animation range
  13413. * @param name defines the name of the range
  13414. * @param from defines the start key
  13415. * @param to defines the end key
  13416. */
  13417. createAnimationRange(name: string, from: number, to: number): void;
  13418. /**
  13419. * Delete a specific animation range
  13420. * @param name defines the name of the range
  13421. * @param deleteFrames defines if frames must be removed as well
  13422. */
  13423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13424. /**
  13425. * Gets a specific animation range
  13426. * @param name defines the name of the range to look for
  13427. * @returns the requested animation range or null if not found
  13428. */
  13429. getAnimationRange(name: string): Nullable<AnimationRange>;
  13430. /**
  13431. * Gets the list of all animation ranges defined on this skeleton
  13432. * @returns an array
  13433. */
  13434. getAnimationRanges(): Nullable<AnimationRange>[];
  13435. /**
  13436. * Copy animation range from a source skeleton.
  13437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13438. * @param source defines the source skeleton
  13439. * @param name defines the name of the range to copy
  13440. * @param rescaleAsRequired defines if rescaling must be applied if required
  13441. * @returns true if operation was successful
  13442. */
  13443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13444. /**
  13445. * Forces the skeleton to go to rest pose
  13446. */
  13447. returnToRest(): void;
  13448. private _getHighestAnimationFrame;
  13449. /**
  13450. * Begin a specific animation range
  13451. * @param name defines the name of the range to start
  13452. * @param loop defines if looping must be turned on (false by default)
  13453. * @param speedRatio defines the speed ratio to apply (1 by default)
  13454. * @param onAnimationEnd defines a callback which will be called when animation will end
  13455. * @returns a new animatable
  13456. */
  13457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13458. /** @hidden */
  13459. _markAsDirty(): void;
  13460. /** @hidden */
  13461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13462. /** @hidden */
  13463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13464. private _computeTransformMatrices;
  13465. /**
  13466. * Build all resources required to render a skeleton
  13467. */
  13468. prepare(): void;
  13469. /**
  13470. * Gets the list of animatables currently running for this skeleton
  13471. * @returns an array of animatables
  13472. */
  13473. getAnimatables(): IAnimatable[];
  13474. /**
  13475. * Clone the current skeleton
  13476. * @param name defines the name of the new skeleton
  13477. * @param id defines the id of the new skeleton
  13478. * @returns the new skeleton
  13479. */
  13480. clone(name: string, id: string): Skeleton;
  13481. /**
  13482. * Enable animation blending for this skeleton
  13483. * @param blendingSpeed defines the blending speed to apply
  13484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13485. */
  13486. enableBlending(blendingSpeed?: number): void;
  13487. /**
  13488. * Releases all resources associated with the current skeleton
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Serialize the skeleton in a JSON object
  13493. * @returns a JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Creates a new skeleton from serialized data
  13498. * @param parsedSkeleton defines the serialized data
  13499. * @param scene defines the hosting scene
  13500. * @returns a new skeleton
  13501. */
  13502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13503. /**
  13504. * Compute all node absolute transforms
  13505. * @param forceUpdate defines if computation must be done even if cache is up to date
  13506. */
  13507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13508. /**
  13509. * Gets the root pose matrix
  13510. * @returns a matrix
  13511. */
  13512. getPoseMatrix(): Nullable<Matrix>;
  13513. /**
  13514. * Sorts bones per internal index
  13515. */
  13516. sortBones(): void;
  13517. private _sortBones;
  13518. }
  13519. }
  13520. declare module "babylonjs/Bones/bone" {
  13521. import { Skeleton } from "babylonjs/Bones/skeleton";
  13522. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13523. import { Nullable } from "babylonjs/types";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13526. import { Node } from "babylonjs/node";
  13527. import { Space } from "babylonjs/Maths/math.axis";
  13528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13529. /**
  13530. * Class used to store bone information
  13531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13532. */
  13533. export class Bone extends Node {
  13534. /**
  13535. * defines the bone name
  13536. */
  13537. name: string;
  13538. private static _tmpVecs;
  13539. private static _tmpQuat;
  13540. private static _tmpMats;
  13541. /**
  13542. * Gets the list of child bones
  13543. */
  13544. children: Bone[];
  13545. /** Gets the animations associated with this bone */
  13546. animations: import("babylonjs/Animations/animation").Animation[];
  13547. /**
  13548. * Gets or sets bone length
  13549. */
  13550. length: number;
  13551. /**
  13552. * @hidden Internal only
  13553. * Set this value to map this bone to a different index in the transform matrices
  13554. * Set this value to -1 to exclude the bone from the transform matrices
  13555. */
  13556. _index: Nullable<number>;
  13557. private _skeleton;
  13558. private _localMatrix;
  13559. private _restPose;
  13560. private _baseMatrix;
  13561. private _absoluteTransform;
  13562. private _invertedAbsoluteTransform;
  13563. private _parent;
  13564. private _scalingDeterminant;
  13565. private _worldTransform;
  13566. private _localScaling;
  13567. private _localRotation;
  13568. private _localPosition;
  13569. private _needToDecompose;
  13570. private _needToCompose;
  13571. /** @hidden */
  13572. _linkedTransformNode: Nullable<TransformNode>;
  13573. /** @hidden */
  13574. _waitingTransformNodeId: Nullable<string>;
  13575. /** @hidden */
  13576. /** @hidden */
  13577. _matrix: Matrix;
  13578. /**
  13579. * Create a new bone
  13580. * @param name defines the bone name
  13581. * @param skeleton defines the parent skeleton
  13582. * @param parentBone defines the parent (can be null if the bone is the root)
  13583. * @param localMatrix defines the local matrix
  13584. * @param restPose defines the rest pose matrix
  13585. * @param baseMatrix defines the base matrix
  13586. * @param index defines index of the bone in the hiearchy
  13587. */
  13588. constructor(
  13589. /**
  13590. * defines the bone name
  13591. */
  13592. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13593. /**
  13594. * Gets the current object class name.
  13595. * @return the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Gets the parent skeleton
  13600. * @returns a skeleton
  13601. */
  13602. getSkeleton(): Skeleton;
  13603. /**
  13604. * Gets parent bone
  13605. * @returns a bone or null if the bone is the root of the bone hierarchy
  13606. */
  13607. getParent(): Nullable<Bone>;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Sets the parent bone
  13615. * @param parent defines the parent (can be null if the bone is the root)
  13616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13617. */
  13618. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13619. /**
  13620. * Gets the local matrix
  13621. * @returns a matrix
  13622. */
  13623. getLocalMatrix(): Matrix;
  13624. /**
  13625. * Gets the base matrix (initial matrix which remains unchanged)
  13626. * @returns a matrix
  13627. */
  13628. getBaseMatrix(): Matrix;
  13629. /**
  13630. * Gets the rest pose matrix
  13631. * @returns a matrix
  13632. */
  13633. getRestPose(): Matrix;
  13634. /**
  13635. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13636. */
  13637. getWorldMatrix(): Matrix;
  13638. /**
  13639. * Sets the local matrix to rest pose matrix
  13640. */
  13641. returnToRest(): void;
  13642. /**
  13643. * Gets the inverse of the absolute transform matrix.
  13644. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13645. * @returns a matrix
  13646. */
  13647. getInvertedAbsoluteTransform(): Matrix;
  13648. /**
  13649. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13650. * @returns a matrix
  13651. */
  13652. getAbsoluteTransform(): Matrix;
  13653. /**
  13654. * Links with the given transform node.
  13655. * The local matrix of this bone is copied from the transform node every frame.
  13656. * @param transformNode defines the transform node to link to
  13657. */
  13658. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13659. /**
  13660. * Gets the node used to drive the bone's transformation
  13661. * @returns a transform node or null
  13662. */
  13663. getTransformNode(): Nullable<TransformNode>;
  13664. /** Gets or sets current position (in local space) */
  13665. position: Vector3;
  13666. /** Gets or sets current rotation (in local space) */
  13667. rotation: Vector3;
  13668. /** Gets or sets current rotation quaternion (in local space) */
  13669. rotationQuaternion: Quaternion;
  13670. /** Gets or sets current scaling (in local space) */
  13671. scaling: Vector3;
  13672. /**
  13673. * Gets the animation properties override
  13674. */
  13675. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13676. private _decompose;
  13677. private _compose;
  13678. /**
  13679. * Update the base and local matrices
  13680. * @param matrix defines the new base or local matrix
  13681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13682. * @param updateLocalMatrix defines if the local matrix should be updated
  13683. */
  13684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13685. /** @hidden */
  13686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13687. /**
  13688. * Flag the bone as dirty (Forcing it to update everything)
  13689. */
  13690. markAsDirty(): void;
  13691. /** @hidden */
  13692. _markAsDirtyAndCompose(): void;
  13693. private _markAsDirtyAndDecompose;
  13694. /**
  13695. * Translate the bone in local or world space
  13696. * @param vec The amount to translate the bone
  13697. * @param space The space that the translation is in
  13698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13699. */
  13700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13701. /**
  13702. * Set the postion of the bone in local or world space
  13703. * @param position The position to set the bone
  13704. * @param space The space that the position is in
  13705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13706. */
  13707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13708. /**
  13709. * Set the absolute position of the bone (world space)
  13710. * @param position The position to set the bone
  13711. * @param mesh The mesh that this bone is attached to
  13712. */
  13713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13714. /**
  13715. * Scale the bone on the x, y and z axes (in local space)
  13716. * @param x The amount to scale the bone on the x axis
  13717. * @param y The amount to scale the bone on the y axis
  13718. * @param z The amount to scale the bone on the z axis
  13719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13720. */
  13721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13722. /**
  13723. * Set the bone scaling in local space
  13724. * @param scale defines the scaling vector
  13725. */
  13726. setScale(scale: Vector3): void;
  13727. /**
  13728. * Gets the current scaling in local space
  13729. * @returns the current scaling vector
  13730. */
  13731. getScale(): Vector3;
  13732. /**
  13733. * Gets the current scaling in local space and stores it in a target vector
  13734. * @param result defines the target vector
  13735. */
  13736. getScaleToRef(result: Vector3): void;
  13737. /**
  13738. * Set the yaw, pitch, and roll of the bone in local or world space
  13739. * @param yaw The rotation of the bone on the y axis
  13740. * @param pitch The rotation of the bone on the x axis
  13741. * @param roll The rotation of the bone on the z axis
  13742. * @param space The space that the axes of rotation are in
  13743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13744. */
  13745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13746. /**
  13747. * Add a rotation to the bone on an axis in local or world space
  13748. * @param axis The axis to rotate the bone on
  13749. * @param amount The amount to rotate the bone
  13750. * @param space The space that the axis is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the rotation of the bone to a particular axis angle in local or world space
  13756. * @param axis The axis to rotate the bone on
  13757. * @param angle The angle that the bone should be rotated to
  13758. * @param space The space that the axis is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the euler rotation of the bone in local of world space
  13764. * @param rotation The euler rotation that the bone should be set to
  13765. * @param space The space that the rotation is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. */
  13768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13769. /**
  13770. * Set the quaternion rotation of the bone in local of world space
  13771. * @param quat The quaternion rotation that the bone should be set to
  13772. * @param space The space that the rotation is in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. */
  13775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13776. /**
  13777. * Set the rotation matrix of the bone in local of world space
  13778. * @param rotMat The rotation matrix that the bone should be set to
  13779. * @param space The space that the rotation is in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. */
  13782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13783. private _rotateWithMatrix;
  13784. private _getNegativeRotationToRef;
  13785. /**
  13786. * Get the position of the bone in local or world space
  13787. * @param space The space that the returned position is in
  13788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13789. * @returns The position of the bone
  13790. */
  13791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13792. /**
  13793. * Copy the position of the bone to a vector3 in local or world space
  13794. * @param space The space that the returned position is in
  13795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13796. * @param result The vector3 to copy the position to
  13797. */
  13798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13799. /**
  13800. * Get the absolute position of the bone (world space)
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The absolute position of the bone
  13803. */
  13804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Copy the absolute position of the bone (world space) to the result param
  13807. * @param mesh The mesh that this bone is attached to
  13808. * @param result The vector3 to copy the absolute position to
  13809. */
  13810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13811. /**
  13812. * Compute the absolute transforms of this bone and its children
  13813. */
  13814. computeAbsoluteTransforms(): void;
  13815. /**
  13816. * Get the world direction from an axis that is in the local space of the bone
  13817. * @param localAxis The local direction that is used to compute the world direction
  13818. * @param mesh The mesh that this bone is attached to
  13819. * @returns The world direction
  13820. */
  13821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13822. /**
  13823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13824. * @param localAxis The local direction that is used to compute the world direction
  13825. * @param mesh The mesh that this bone is attached to
  13826. * @param result The vector3 that the world direction will be copied to
  13827. */
  13828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13829. /**
  13830. * Get the euler rotation of the bone in local or world space
  13831. * @param space The space that the rotation should be in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. * @returns The euler rotation
  13834. */
  13835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13836. /**
  13837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13838. * @param space The space that the rotation should be in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. * @param result The vector3 that the rotation should be copied to
  13841. */
  13842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13843. /**
  13844. * Get the quaternion rotation of the bone in either local or world space
  13845. * @param space The space that the rotation should be in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The quaternion rotation
  13848. */
  13849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13850. /**
  13851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13852. * @param space The space that the rotation should be in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The quaternion that the rotation should be copied to
  13855. */
  13856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13857. /**
  13858. * Get the rotation matrix of the bone in local or world space
  13859. * @param space The space that the rotation should be in
  13860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13861. * @returns The rotation matrix
  13862. */
  13863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13864. /**
  13865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13866. * @param space The space that the rotation should be in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. * @param result The quaternion that the rotation should be copied to
  13869. */
  13870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13871. /**
  13872. * Get the world position of a point that is in the local space of the bone
  13873. * @param position The local position
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The world position
  13876. */
  13877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13880. * @param position The local position
  13881. * @param mesh The mesh that this bone is attached to
  13882. * @param result The vector3 that the world position should be copied to
  13883. */
  13884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13885. /**
  13886. * Get the local position of a point that is in world space
  13887. * @param position The world position
  13888. * @param mesh The mesh that this bone is attached to
  13889. * @returns The local position
  13890. */
  13891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13892. /**
  13893. * Get the local position of a point that is in world space and copy it to the result param
  13894. * @param position The world position
  13895. * @param mesh The mesh that this bone is attached to
  13896. * @param result The vector3 that the local position should be copied to
  13897. */
  13898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13899. }
  13900. }
  13901. declare module "babylonjs/Meshes/transformNode" {
  13902. import { DeepImmutable } from "babylonjs/types";
  13903. import { Observable } from "babylonjs/Misc/observable";
  13904. import { Nullable } from "babylonjs/types";
  13905. import { Camera } from "babylonjs/Cameras/camera";
  13906. import { Scene } from "babylonjs/scene";
  13907. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13908. import { Node } from "babylonjs/node";
  13909. import { Bone } from "babylonjs/Bones/bone";
  13910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13911. import { Space } from "babylonjs/Maths/math.axis";
  13912. /**
  13913. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13914. * @see https://doc.babylonjs.com/how_to/transformnode
  13915. */
  13916. export class TransformNode extends Node {
  13917. /**
  13918. * Object will not rotate to face the camera
  13919. */
  13920. static BILLBOARDMODE_NONE: number;
  13921. /**
  13922. * Object will rotate to face the camera but only on the x axis
  13923. */
  13924. static BILLBOARDMODE_X: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the y axis
  13927. */
  13928. static BILLBOARDMODE_Y: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the z axis
  13931. */
  13932. static BILLBOARDMODE_Z: number;
  13933. /**
  13934. * Object will rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_ALL: number;
  13937. private _forward;
  13938. private _forwardInverted;
  13939. private _up;
  13940. private _right;
  13941. private _rightInverted;
  13942. private _position;
  13943. private _rotation;
  13944. private _rotationQuaternion;
  13945. protected _scaling: Vector3;
  13946. protected _isDirty: boolean;
  13947. private _transformToBoneReferal;
  13948. private _isAbsoluteSynced;
  13949. private _billboardMode;
  13950. /**
  13951. * Gets or sets the billboard mode. Default is 0.
  13952. *
  13953. * | Value | Type | Description |
  13954. * | --- | --- | --- |
  13955. * | 0 | BILLBOARDMODE_NONE | |
  13956. * | 1 | BILLBOARDMODE_X | |
  13957. * | 2 | BILLBOARDMODE_Y | |
  13958. * | 4 | BILLBOARDMODE_Z | |
  13959. * | 7 | BILLBOARDMODE_ALL | |
  13960. *
  13961. */
  13962. billboardMode: number;
  13963. private _preserveParentRotationForBillboard;
  13964. /**
  13965. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13966. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13967. */
  13968. preserveParentRotationForBillboard: boolean;
  13969. /**
  13970. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13971. */
  13972. scalingDeterminant: number;
  13973. private _infiniteDistance;
  13974. /**
  13975. * Gets or sets the distance of the object to max, often used by skybox
  13976. */
  13977. infiniteDistance: boolean;
  13978. /**
  13979. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13980. * By default the system will update normals to compensate
  13981. */
  13982. ignoreNonUniformScaling: boolean;
  13983. /**
  13984. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13985. */
  13986. reIntegrateRotationIntoRotationQuaternion: boolean;
  13987. /** @hidden */
  13988. _poseMatrix: Nullable<Matrix>;
  13989. /** @hidden */
  13990. _localMatrix: Matrix;
  13991. private _usePivotMatrix;
  13992. private _absolutePosition;
  13993. private _absoluteScaling;
  13994. private _absoluteRotationQuaternion;
  13995. private _pivotMatrix;
  13996. private _pivotMatrixInverse;
  13997. protected _postMultiplyPivotMatrix: boolean;
  13998. protected _isWorldMatrixFrozen: boolean;
  13999. /** @hidden */
  14000. _indexInSceneTransformNodesArray: number;
  14001. /**
  14002. * An event triggered after the world matrix is updated
  14003. */
  14004. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14005. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14006. /**
  14007. * Gets a string identifying the name of the class
  14008. * @returns "TransformNode" string
  14009. */
  14010. getClassName(): string;
  14011. /**
  14012. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14013. */
  14014. position: Vector3;
  14015. /**
  14016. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14017. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14018. */
  14019. rotation: Vector3;
  14020. /**
  14021. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14022. */
  14023. scaling: Vector3;
  14024. /**
  14025. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14026. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14027. */
  14028. rotationQuaternion: Nullable<Quaternion>;
  14029. /**
  14030. * The forward direction of that transform in world space.
  14031. */
  14032. readonly forward: Vector3;
  14033. /**
  14034. * The up direction of that transform in world space.
  14035. */
  14036. readonly up: Vector3;
  14037. /**
  14038. * The right direction of that transform in world space.
  14039. */
  14040. readonly right: Vector3;
  14041. /**
  14042. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14043. * @param matrix the matrix to copy the pose from
  14044. * @returns this TransformNode.
  14045. */
  14046. updatePoseMatrix(matrix: Matrix): TransformNode;
  14047. /**
  14048. * Returns the mesh Pose matrix.
  14049. * @returns the pose matrix
  14050. */
  14051. getPoseMatrix(): Matrix;
  14052. /** @hidden */
  14053. _isSynchronized(): boolean;
  14054. /** @hidden */
  14055. _initCache(): void;
  14056. /**
  14057. * Flag the transform node as dirty (Forcing it to update everything)
  14058. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14059. * @returns this transform node
  14060. */
  14061. markAsDirty(property: string): TransformNode;
  14062. /**
  14063. * Returns the current mesh absolute position.
  14064. * Returns a Vector3.
  14065. */
  14066. readonly absolutePosition: Vector3;
  14067. /**
  14068. * Returns the current mesh absolute scaling.
  14069. * Returns a Vector3.
  14070. */
  14071. readonly absoluteScaling: Vector3;
  14072. /**
  14073. * Returns the current mesh absolute rotation.
  14074. * Returns a Quaternion.
  14075. */
  14076. readonly absoluteRotationQuaternion: Quaternion;
  14077. /**
  14078. * Sets a new matrix to apply before all other transformation
  14079. * @param matrix defines the transform matrix
  14080. * @returns the current TransformNode
  14081. */
  14082. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14083. /**
  14084. * Sets a new pivot matrix to the current node
  14085. * @param matrix defines the new pivot matrix to use
  14086. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14087. * @returns the current TransformNode
  14088. */
  14089. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14090. /**
  14091. * Returns the mesh pivot matrix.
  14092. * Default : Identity.
  14093. * @returns the matrix
  14094. */
  14095. getPivotMatrix(): Matrix;
  14096. /**
  14097. * Prevents the World matrix to be computed any longer.
  14098. * @returns the TransformNode.
  14099. */
  14100. freezeWorldMatrix(): TransformNode;
  14101. /**
  14102. * Allows back the World matrix computation.
  14103. * @returns the TransformNode.
  14104. */
  14105. unfreezeWorldMatrix(): this;
  14106. /**
  14107. * True if the World matrix has been frozen.
  14108. */
  14109. readonly isWorldMatrixFrozen: boolean;
  14110. /**
  14111. * Retuns the mesh absolute position in the World.
  14112. * @returns a Vector3.
  14113. */
  14114. getAbsolutePosition(): Vector3;
  14115. /**
  14116. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14117. * @param absolutePosition the absolute position to set
  14118. * @returns the TransformNode.
  14119. */
  14120. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14121. /**
  14122. * Sets the mesh position in its local space.
  14123. * @param vector3 the position to set in localspace
  14124. * @returns the TransformNode.
  14125. */
  14126. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14127. /**
  14128. * Returns the mesh position in the local space from the current World matrix values.
  14129. * @returns a new Vector3.
  14130. */
  14131. getPositionExpressedInLocalSpace(): Vector3;
  14132. /**
  14133. * Translates the mesh along the passed Vector3 in its local space.
  14134. * @param vector3 the distance to translate in localspace
  14135. * @returns the TransformNode.
  14136. */
  14137. locallyTranslate(vector3: Vector3): TransformNode;
  14138. private static _lookAtVectorCache;
  14139. /**
  14140. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14141. * @param targetPoint the position (must be in same space as current mesh) to look at
  14142. * @param yawCor optional yaw (y-axis) correction in radians
  14143. * @param pitchCor optional pitch (x-axis) correction in radians
  14144. * @param rollCor optional roll (z-axis) correction in radians
  14145. * @param space the choosen space of the target
  14146. * @returns the TransformNode.
  14147. */
  14148. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14149. /**
  14150. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14151. * This Vector3 is expressed in the World space.
  14152. * @param localAxis axis to rotate
  14153. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14154. */
  14155. getDirection(localAxis: Vector3): Vector3;
  14156. /**
  14157. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14158. * localAxis is expressed in the mesh local space.
  14159. * result is computed in the Wordl space from the mesh World matrix.
  14160. * @param localAxis axis to rotate
  14161. * @param result the resulting transformnode
  14162. * @returns this TransformNode.
  14163. */
  14164. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14165. /**
  14166. * Sets this transform node rotation to the given local axis.
  14167. * @param localAxis the axis in local space
  14168. * @param yawCor optional yaw (y-axis) correction in radians
  14169. * @param pitchCor optional pitch (x-axis) correction in radians
  14170. * @param rollCor optional roll (z-axis) correction in radians
  14171. * @returns this TransformNode
  14172. */
  14173. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14174. /**
  14175. * Sets a new pivot point to the current node
  14176. * @param point defines the new pivot point to use
  14177. * @param space defines if the point is in world or local space (local by default)
  14178. * @returns the current TransformNode
  14179. */
  14180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14181. /**
  14182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14183. * @returns the pivot point
  14184. */
  14185. getPivotPoint(): Vector3;
  14186. /**
  14187. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14188. * @param result the vector3 to store the result
  14189. * @returns this TransformNode.
  14190. */
  14191. getPivotPointToRef(result: Vector3): TransformNode;
  14192. /**
  14193. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14194. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14195. */
  14196. getAbsolutePivotPoint(): Vector3;
  14197. /**
  14198. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14199. * @param result vector3 to store the result
  14200. * @returns this TransformNode.
  14201. */
  14202. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14203. /**
  14204. * Defines the passed node as the parent of the current node.
  14205. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14206. * @see https://doc.babylonjs.com/how_to/parenting
  14207. * @param node the node ot set as the parent
  14208. * @returns this TransformNode.
  14209. */
  14210. setParent(node: Nullable<Node>): TransformNode;
  14211. private _nonUniformScaling;
  14212. /**
  14213. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14214. */
  14215. readonly nonUniformScaling: boolean;
  14216. /** @hidden */
  14217. _updateNonUniformScalingState(value: boolean): boolean;
  14218. /**
  14219. * Attach the current TransformNode to another TransformNode associated with a bone
  14220. * @param bone Bone affecting the TransformNode
  14221. * @param affectedTransformNode TransformNode associated with the bone
  14222. * @returns this object
  14223. */
  14224. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14225. /**
  14226. * Detach the transform node if its associated with a bone
  14227. * @returns this object
  14228. */
  14229. detachFromBone(): TransformNode;
  14230. private static _rotationAxisCache;
  14231. /**
  14232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14233. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14235. * The passed axis is also normalized.
  14236. * @param axis the axis to rotate around
  14237. * @param amount the amount to rotate in radians
  14238. * @param space Space to rotate in (Default: local)
  14239. * @returns the TransformNode.
  14240. */
  14241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14242. /**
  14243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14244. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14245. * The passed axis is also normalized. .
  14246. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14247. * @param point the point to rotate around
  14248. * @param axis the axis to rotate around
  14249. * @param amount the amount to rotate in radians
  14250. * @returns the TransformNode
  14251. */
  14252. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14253. /**
  14254. * Translates the mesh along the axis vector for the passed distance in the given space.
  14255. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14256. * @param axis the axis to translate in
  14257. * @param distance the distance to translate
  14258. * @param space Space to rotate in (Default: local)
  14259. * @returns the TransformNode.
  14260. */
  14261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14262. /**
  14263. * Adds a rotation step to the mesh current rotation.
  14264. * x, y, z are Euler angles expressed in radians.
  14265. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14266. * This means this rotation is made in the mesh local space only.
  14267. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14268. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14269. * ```javascript
  14270. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14271. * ```
  14272. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14273. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14274. * @param x Rotation to add
  14275. * @param y Rotation to add
  14276. * @param z Rotation to add
  14277. * @returns the TransformNode.
  14278. */
  14279. addRotation(x: number, y: number, z: number): TransformNode;
  14280. /**
  14281. * @hidden
  14282. */
  14283. protected _getEffectiveParent(): Nullable<Node>;
  14284. /**
  14285. * Computes the world matrix of the node
  14286. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14287. * @returns the world matrix
  14288. */
  14289. computeWorldMatrix(force?: boolean): Matrix;
  14290. protected _afterComputeWorldMatrix(): void;
  14291. /**
  14292. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14293. * @param func callback function to add
  14294. *
  14295. * @returns the TransformNode.
  14296. */
  14297. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14298. /**
  14299. * Removes a registered callback function.
  14300. * @param func callback function to remove
  14301. * @returns the TransformNode.
  14302. */
  14303. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14304. /**
  14305. * Gets the position of the current mesh in camera space
  14306. * @param camera defines the camera to use
  14307. * @returns a position
  14308. */
  14309. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14310. /**
  14311. * Returns the distance from the mesh to the active camera
  14312. * @param camera defines the camera to use
  14313. * @returns the distance
  14314. */
  14315. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14316. /**
  14317. * Clone the current transform node
  14318. * @param name Name of the new clone
  14319. * @param newParent New parent for the clone
  14320. * @param doNotCloneChildren Do not clone children hierarchy
  14321. * @returns the new transform node
  14322. */
  14323. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14324. /**
  14325. * Serializes the objects information.
  14326. * @param currentSerializationObject defines the object to serialize in
  14327. * @returns the serialized object
  14328. */
  14329. serialize(currentSerializationObject?: any): any;
  14330. /**
  14331. * Returns a new TransformNode object parsed from the source provided.
  14332. * @param parsedTransformNode is the source.
  14333. * @param scene the scne the object belongs to
  14334. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14335. * @returns a new TransformNode object parsed from the source provided.
  14336. */
  14337. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14338. /**
  14339. * Get all child-transformNodes of this node
  14340. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14341. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14342. * @returns an array of TransformNode
  14343. */
  14344. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14345. /**
  14346. * Releases resources associated with this transform node.
  14347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14349. */
  14350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14351. /**
  14352. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14353. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14354. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14355. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14356. * @returns the current mesh
  14357. */
  14358. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14359. private _syncAbsoluteScalingAndRotation;
  14360. }
  14361. }
  14362. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14363. import { Observable } from "babylonjs/Misc/observable";
  14364. import { Nullable } from "babylonjs/types";
  14365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14368. import { Ray } from "babylonjs/Culling/ray";
  14369. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14370. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14371. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14372. /**
  14373. * Defines the types of pose enabled controllers that are supported
  14374. */
  14375. export enum PoseEnabledControllerType {
  14376. /**
  14377. * HTC Vive
  14378. */
  14379. VIVE = 0,
  14380. /**
  14381. * Oculus Rift
  14382. */
  14383. OCULUS = 1,
  14384. /**
  14385. * Windows mixed reality
  14386. */
  14387. WINDOWS = 2,
  14388. /**
  14389. * Samsung gear VR
  14390. */
  14391. GEAR_VR = 3,
  14392. /**
  14393. * Google Daydream
  14394. */
  14395. DAYDREAM = 4,
  14396. /**
  14397. * Generic
  14398. */
  14399. GENERIC = 5
  14400. }
  14401. /**
  14402. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14403. */
  14404. export interface MutableGamepadButton {
  14405. /**
  14406. * Value of the button/trigger
  14407. */
  14408. value: number;
  14409. /**
  14410. * If the button/trigger is currently touched
  14411. */
  14412. touched: boolean;
  14413. /**
  14414. * If the button/trigger is currently pressed
  14415. */
  14416. pressed: boolean;
  14417. }
  14418. /**
  14419. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14420. * @hidden
  14421. */
  14422. export interface ExtendedGamepadButton extends GamepadButton {
  14423. /**
  14424. * If the button/trigger is currently pressed
  14425. */
  14426. readonly pressed: boolean;
  14427. /**
  14428. * If the button/trigger is currently touched
  14429. */
  14430. readonly touched: boolean;
  14431. /**
  14432. * Value of the button/trigger
  14433. */
  14434. readonly value: number;
  14435. }
  14436. /** @hidden */
  14437. export interface _GamePadFactory {
  14438. /**
  14439. * Returns wether or not the current gamepad can be created for this type of controller.
  14440. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14441. * @returns true if it can be created, otherwise false
  14442. */
  14443. canCreate(gamepadInfo: any): boolean;
  14444. /**
  14445. * Creates a new instance of the Gamepad.
  14446. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14447. * @returns the new gamepad instance
  14448. */
  14449. create(gamepadInfo: any): Gamepad;
  14450. }
  14451. /**
  14452. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14453. */
  14454. export class PoseEnabledControllerHelper {
  14455. /** @hidden */
  14456. static _ControllerFactories: _GamePadFactory[];
  14457. /** @hidden */
  14458. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14459. /**
  14460. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14461. * @param vrGamepad the gamepad to initialized
  14462. * @returns a vr controller of the type the gamepad identified as
  14463. */
  14464. static InitiateController(vrGamepad: any): Gamepad;
  14465. }
  14466. /**
  14467. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14468. */
  14469. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14470. /**
  14471. * If the controller is used in a webXR session
  14472. */
  14473. isXR: boolean;
  14474. private _deviceRoomPosition;
  14475. private _deviceRoomRotationQuaternion;
  14476. /**
  14477. * The device position in babylon space
  14478. */
  14479. devicePosition: Vector3;
  14480. /**
  14481. * The device rotation in babylon space
  14482. */
  14483. deviceRotationQuaternion: Quaternion;
  14484. /**
  14485. * The scale factor of the device in babylon space
  14486. */
  14487. deviceScaleFactor: number;
  14488. /**
  14489. * (Likely devicePosition should be used instead) The device position in its room space
  14490. */
  14491. position: Vector3;
  14492. /**
  14493. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14494. */
  14495. rotationQuaternion: Quaternion;
  14496. /**
  14497. * The type of controller (Eg. Windows mixed reality)
  14498. */
  14499. controllerType: PoseEnabledControllerType;
  14500. protected _calculatedPosition: Vector3;
  14501. private _calculatedRotation;
  14502. /**
  14503. * The raw pose from the device
  14504. */
  14505. rawPose: DevicePose;
  14506. private _trackPosition;
  14507. private _maxRotationDistFromHeadset;
  14508. private _draggedRoomRotation;
  14509. /**
  14510. * @hidden
  14511. */
  14512. _disableTrackPosition(fixedPosition: Vector3): void;
  14513. /**
  14514. * Internal, the mesh attached to the controller
  14515. * @hidden
  14516. */
  14517. _mesh: Nullable<AbstractMesh>;
  14518. private _poseControlledCamera;
  14519. private _leftHandSystemQuaternion;
  14520. /**
  14521. * Internal, matrix used to convert room space to babylon space
  14522. * @hidden
  14523. */
  14524. _deviceToWorld: Matrix;
  14525. /**
  14526. * Node to be used when casting a ray from the controller
  14527. * @hidden
  14528. */
  14529. _pointingPoseNode: Nullable<TransformNode>;
  14530. /**
  14531. * Name of the child mesh that can be used to cast a ray from the controller
  14532. */
  14533. static readonly POINTING_POSE: string;
  14534. /**
  14535. * Creates a new PoseEnabledController from a gamepad
  14536. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14537. */
  14538. constructor(browserGamepad: any);
  14539. private _workingMatrix;
  14540. /**
  14541. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14542. */
  14543. update(): void;
  14544. /**
  14545. * Updates only the pose device and mesh without doing any button event checking
  14546. */
  14547. protected _updatePoseAndMesh(): void;
  14548. /**
  14549. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14550. * @param poseData raw pose fromthe device
  14551. */
  14552. updateFromDevice(poseData: DevicePose): void;
  14553. /**
  14554. * @hidden
  14555. */
  14556. _meshAttachedObservable: Observable<AbstractMesh>;
  14557. /**
  14558. * Attaches a mesh to the controller
  14559. * @param mesh the mesh to be attached
  14560. */
  14561. attachToMesh(mesh: AbstractMesh): void;
  14562. /**
  14563. * Attaches the controllers mesh to a camera
  14564. * @param camera the camera the mesh should be attached to
  14565. */
  14566. attachToPoseControlledCamera(camera: TargetCamera): void;
  14567. /**
  14568. * Disposes of the controller
  14569. */
  14570. dispose(): void;
  14571. /**
  14572. * The mesh that is attached to the controller
  14573. */
  14574. readonly mesh: Nullable<AbstractMesh>;
  14575. /**
  14576. * Gets the ray of the controller in the direction the controller is pointing
  14577. * @param length the length the resulting ray should be
  14578. * @returns a ray in the direction the controller is pointing
  14579. */
  14580. getForwardRay(length?: number): Ray;
  14581. }
  14582. }
  14583. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14584. import { Observable } from "babylonjs/Misc/observable";
  14585. import { Scene } from "babylonjs/scene";
  14586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14587. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14588. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14589. /**
  14590. * Defines the WebVRController object that represents controllers tracked in 3D space
  14591. */
  14592. export abstract class WebVRController extends PoseEnabledController {
  14593. /**
  14594. * Internal, the default controller model for the controller
  14595. */
  14596. protected _defaultModel: AbstractMesh;
  14597. /**
  14598. * Fired when the trigger state has changed
  14599. */
  14600. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14601. /**
  14602. * Fired when the main button state has changed
  14603. */
  14604. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14605. /**
  14606. * Fired when the secondary button state has changed
  14607. */
  14608. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the pad state has changed
  14611. */
  14612. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when controllers stick values have changed
  14615. */
  14616. onPadValuesChangedObservable: Observable<StickValues>;
  14617. /**
  14618. * Array of button availible on the controller
  14619. */
  14620. protected _buttons: Array<MutableGamepadButton>;
  14621. private _onButtonStateChange;
  14622. /**
  14623. * Fired when a controller button's state has changed
  14624. * @param callback the callback containing the button that was modified
  14625. */
  14626. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14627. /**
  14628. * X and Y axis corresponding to the controllers joystick
  14629. */
  14630. pad: StickValues;
  14631. /**
  14632. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14633. */
  14634. hand: string;
  14635. /**
  14636. * The default controller model for the controller
  14637. */
  14638. readonly defaultModel: AbstractMesh;
  14639. /**
  14640. * Creates a new WebVRController from a gamepad
  14641. * @param vrGamepad the gamepad that the WebVRController should be created from
  14642. */
  14643. constructor(vrGamepad: any);
  14644. /**
  14645. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14646. */
  14647. update(): void;
  14648. /**
  14649. * Function to be called when a button is modified
  14650. */
  14651. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14652. /**
  14653. * Loads a mesh and attaches it to the controller
  14654. * @param scene the scene the mesh should be added to
  14655. * @param meshLoaded callback for when the mesh has been loaded
  14656. */
  14657. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14658. private _setButtonValue;
  14659. private _changes;
  14660. private _checkChanges;
  14661. /**
  14662. * Disposes of th webVRCOntroller
  14663. */
  14664. dispose(): void;
  14665. }
  14666. }
  14667. declare module "babylonjs/Lights/hemisphericLight" {
  14668. import { Nullable } from "babylonjs/types";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14671. import { Color3 } from "babylonjs/Maths/math.color";
  14672. import { Effect } from "babylonjs/Materials/effect";
  14673. import { Light } from "babylonjs/Lights/light";
  14674. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14675. /**
  14676. * The HemisphericLight simulates the ambient environment light,
  14677. * so the passed direction is the light reflection direction, not the incoming direction.
  14678. */
  14679. export class HemisphericLight extends Light {
  14680. /**
  14681. * The groundColor is the light in the opposite direction to the one specified during creation.
  14682. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14683. */
  14684. groundColor: Color3;
  14685. /**
  14686. * The light reflection direction, not the incoming direction.
  14687. */
  14688. direction: Vector3;
  14689. /**
  14690. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14691. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14692. * The HemisphericLight can't cast shadows.
  14693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14694. * @param name The friendly name of the light
  14695. * @param direction The direction of the light reflection
  14696. * @param scene The scene the light belongs to
  14697. */
  14698. constructor(name: string, direction: Vector3, scene: Scene);
  14699. protected _buildUniformLayout(): void;
  14700. /**
  14701. * Returns the string "HemisphericLight".
  14702. * @return The class name
  14703. */
  14704. getClassName(): string;
  14705. /**
  14706. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14707. * Returns the updated direction.
  14708. * @param target The target the direction should point to
  14709. * @return The computed direction
  14710. */
  14711. setDirectionToTarget(target: Vector3): Vector3;
  14712. /**
  14713. * Returns the shadow generator associated to the light.
  14714. * @returns Always null for hemispheric lights because it does not support shadows.
  14715. */
  14716. getShadowGenerator(): Nullable<IShadowGenerator>;
  14717. /**
  14718. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14719. * @param effect The effect to update
  14720. * @param lightIndex The index of the light in the effect to update
  14721. * @returns The hemispheric light
  14722. */
  14723. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14724. /**
  14725. * Computes the world matrix of the node
  14726. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14727. * @param useWasUpdatedFlag defines a reserved property
  14728. * @returns the world matrix
  14729. */
  14730. computeWorldMatrix(): Matrix;
  14731. /**
  14732. * Returns the integer 3.
  14733. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14734. */
  14735. getTypeID(): number;
  14736. /**
  14737. * Prepares the list of defines specific to the light type.
  14738. * @param defines the list of defines
  14739. * @param lightIndex defines the index of the light for the effect
  14740. */
  14741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14745. /** @hidden */
  14746. export var vrMultiviewToSingleviewPixelShader: {
  14747. name: string;
  14748. shader: string;
  14749. };
  14750. }
  14751. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14753. import { Scene } from "babylonjs/scene";
  14754. /**
  14755. * Renders to multiple views with a single draw call
  14756. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14757. */
  14758. export class MultiviewRenderTarget extends RenderTargetTexture {
  14759. /**
  14760. * Creates a multiview render target
  14761. * @param scene scene used with the render target
  14762. * @param size the size of the render target (used for each view)
  14763. */
  14764. constructor(scene: Scene, size?: number | {
  14765. width: number;
  14766. height: number;
  14767. } | {
  14768. ratio: number;
  14769. });
  14770. /**
  14771. * @hidden
  14772. * @param faceIndex the face index, if its a cube texture
  14773. */
  14774. _bindFrameBuffer(faceIndex?: number): void;
  14775. /**
  14776. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14777. * @returns the view count
  14778. */
  14779. getViewCount(): number;
  14780. }
  14781. }
  14782. declare module "babylonjs/Maths/math.frustum" {
  14783. import { Matrix } from "babylonjs/Maths/math.vector";
  14784. import { DeepImmutable } from "babylonjs/types";
  14785. import { Plane } from "babylonjs/Maths/math.plane";
  14786. /**
  14787. * Reprasents a camera frustum
  14788. */
  14789. export class Frustum {
  14790. /**
  14791. * Gets the planes representing the frustum
  14792. * @param transform matrix to be applied to the returned planes
  14793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14794. */
  14795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14796. /**
  14797. * Gets the near frustum plane transformed by the transform matrix
  14798. * @param transform transformation matrix to be applied to the resulting frustum plane
  14799. * @param frustumPlane the resuling frustum plane
  14800. */
  14801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14802. /**
  14803. * Gets the far frustum plane transformed by the transform matrix
  14804. * @param transform transformation matrix to be applied to the resulting frustum plane
  14805. * @param frustumPlane the resuling frustum plane
  14806. */
  14807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14808. /**
  14809. * Gets the left frustum plane transformed by the transform matrix
  14810. * @param transform transformation matrix to be applied to the resulting frustum plane
  14811. * @param frustumPlane the resuling frustum plane
  14812. */
  14813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14814. /**
  14815. * Gets the right frustum plane transformed by the transform matrix
  14816. * @param transform transformation matrix to be applied to the resulting frustum plane
  14817. * @param frustumPlane the resuling frustum plane
  14818. */
  14819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14820. /**
  14821. * Gets the top frustum plane transformed by the transform matrix
  14822. * @param transform transformation matrix to be applied to the resulting frustum plane
  14823. * @param frustumPlane the resuling frustum plane
  14824. */
  14825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14826. /**
  14827. * Gets the bottom frustum plane transformed by the transform matrix
  14828. * @param transform transformation matrix to be applied to the resulting frustum plane
  14829. * @param frustumPlane the resuling frustum plane
  14830. */
  14831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14832. /**
  14833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14834. * @param transform transformation matrix to be applied to the resulting frustum planes
  14835. * @param frustumPlanes the resuling frustum planes
  14836. */
  14837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14838. }
  14839. }
  14840. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14841. import { Camera } from "babylonjs/Cameras/camera";
  14842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14843. import { Nullable } from "babylonjs/types";
  14844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14845. import { Matrix } from "babylonjs/Maths/math.vector";
  14846. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14847. module "babylonjs/Engines/engine" {
  14848. interface Engine {
  14849. /**
  14850. * Creates a new multiview render target
  14851. * @param width defines the width of the texture
  14852. * @param height defines the height of the texture
  14853. * @returns the created multiview texture
  14854. */
  14855. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14856. /**
  14857. * Binds a multiview framebuffer to be drawn to
  14858. * @param multiviewTexture texture to bind
  14859. */
  14860. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14861. }
  14862. }
  14863. module "babylonjs/Cameras/camera" {
  14864. interface Camera {
  14865. /**
  14866. * @hidden
  14867. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14868. */
  14869. _useMultiviewToSingleView: boolean;
  14870. /**
  14871. * @hidden
  14872. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14873. */
  14874. _multiviewTexture: Nullable<RenderTargetTexture>;
  14875. /**
  14876. * @hidden
  14877. * ensures the multiview texture of the camera exists and has the specified width/height
  14878. * @param width height to set on the multiview texture
  14879. * @param height width to set on the multiview texture
  14880. */
  14881. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14882. }
  14883. }
  14884. module "babylonjs/scene" {
  14885. interface Scene {
  14886. /** @hidden */
  14887. _transformMatrixR: Matrix;
  14888. /** @hidden */
  14889. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14890. /** @hidden */
  14891. _createMultiviewUbo(): void;
  14892. /** @hidden */
  14893. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14894. /** @hidden */
  14895. _renderMultiviewToSingleView(camera: Camera): void;
  14896. }
  14897. }
  14898. }
  14899. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14900. import { Camera } from "babylonjs/Cameras/camera";
  14901. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14902. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14903. import "babylonjs/Engines/Extensions/engine.multiview";
  14904. /**
  14905. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14906. * This will not be used for webXR as it supports displaying texture arrays directly
  14907. */
  14908. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14909. /**
  14910. * Initializes a VRMultiviewToSingleview
  14911. * @param name name of the post process
  14912. * @param camera camera to be applied to
  14913. * @param scaleFactor scaling factor to the size of the output texture
  14914. */
  14915. constructor(name: string, camera: Camera, scaleFactor: number);
  14916. }
  14917. }
  14918. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14919. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Size } from "babylonjs/Maths/math.size";
  14922. import { Observable } from "babylonjs/Misc/observable";
  14923. module "babylonjs/Engines/engine" {
  14924. interface Engine {
  14925. /** @hidden */
  14926. _vrDisplay: any;
  14927. /** @hidden */
  14928. _vrSupported: boolean;
  14929. /** @hidden */
  14930. _oldSize: Size;
  14931. /** @hidden */
  14932. _oldHardwareScaleFactor: number;
  14933. /** @hidden */
  14934. _vrExclusivePointerMode: boolean;
  14935. /** @hidden */
  14936. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14937. /** @hidden */
  14938. _onVRDisplayPointerRestricted: () => void;
  14939. /** @hidden */
  14940. _onVRDisplayPointerUnrestricted: () => void;
  14941. /** @hidden */
  14942. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14943. /** @hidden */
  14944. _onVrDisplayDisconnect: Nullable<() => void>;
  14945. /** @hidden */
  14946. _onVrDisplayPresentChange: Nullable<() => void>;
  14947. /**
  14948. * Observable signaled when VR display mode changes
  14949. */
  14950. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14951. /**
  14952. * Observable signaled when VR request present is complete
  14953. */
  14954. onVRRequestPresentComplete: Observable<boolean>;
  14955. /**
  14956. * Observable signaled when VR request present starts
  14957. */
  14958. onVRRequestPresentStart: Observable<Engine>;
  14959. /**
  14960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14962. */
  14963. isInVRExclusivePointerMode: boolean;
  14964. /**
  14965. * Gets a boolean indicating if a webVR device was detected
  14966. * @returns true if a webVR device was detected
  14967. */
  14968. isVRDevicePresent(): boolean;
  14969. /**
  14970. * Gets the current webVR device
  14971. * @returns the current webVR device (or null)
  14972. */
  14973. getVRDevice(): any;
  14974. /**
  14975. * Initializes a webVR display and starts listening to display change events
  14976. * The onVRDisplayChangedObservable will be notified upon these changes
  14977. * @returns A promise containing a VRDisplay and if vr is supported
  14978. */
  14979. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14980. /** @hidden */
  14981. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14982. /**
  14983. * Call this function to switch to webVR mode
  14984. * Will do nothing if webVR is not supported or if there is no webVR device
  14985. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14986. */
  14987. enableVR(): void;
  14988. /** @hidden */
  14989. _onVRFullScreenTriggered(): void;
  14990. }
  14991. }
  14992. }
  14993. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14994. import { Nullable } from "babylonjs/types";
  14995. import { Observable } from "babylonjs/Misc/observable";
  14996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14997. import { Scene } from "babylonjs/scene";
  14998. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14999. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15000. import { Node } from "babylonjs/node";
  15001. import { Ray } from "babylonjs/Culling/ray";
  15002. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15003. import "babylonjs/Engines/Extensions/engine.webVR";
  15004. /**
  15005. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15006. * IMPORTANT!! The data is right-hand data.
  15007. * @export
  15008. * @interface DevicePose
  15009. */
  15010. export interface DevicePose {
  15011. /**
  15012. * The position of the device, values in array are [x,y,z].
  15013. */
  15014. readonly position: Nullable<Float32Array>;
  15015. /**
  15016. * The linearVelocity of the device, values in array are [x,y,z].
  15017. */
  15018. readonly linearVelocity: Nullable<Float32Array>;
  15019. /**
  15020. * The linearAcceleration of the device, values in array are [x,y,z].
  15021. */
  15022. readonly linearAcceleration: Nullable<Float32Array>;
  15023. /**
  15024. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15025. */
  15026. readonly orientation: Nullable<Float32Array>;
  15027. /**
  15028. * The angularVelocity of the device, values in array are [x,y,z].
  15029. */
  15030. readonly angularVelocity: Nullable<Float32Array>;
  15031. /**
  15032. * The angularAcceleration of the device, values in array are [x,y,z].
  15033. */
  15034. readonly angularAcceleration: Nullable<Float32Array>;
  15035. }
  15036. /**
  15037. * Interface representing a pose controlled object in Babylon.
  15038. * A pose controlled object has both regular pose values as well as pose values
  15039. * from an external device such as a VR head mounted display
  15040. */
  15041. export interface PoseControlled {
  15042. /**
  15043. * The position of the object in babylon space.
  15044. */
  15045. position: Vector3;
  15046. /**
  15047. * The rotation quaternion of the object in babylon space.
  15048. */
  15049. rotationQuaternion: Quaternion;
  15050. /**
  15051. * The position of the device in babylon space.
  15052. */
  15053. devicePosition?: Vector3;
  15054. /**
  15055. * The rotation quaternion of the device in babylon space.
  15056. */
  15057. deviceRotationQuaternion: Quaternion;
  15058. /**
  15059. * The raw pose coming from the device.
  15060. */
  15061. rawPose: Nullable<DevicePose>;
  15062. /**
  15063. * The scale of the device to be used when translating from device space to babylon space.
  15064. */
  15065. deviceScaleFactor: number;
  15066. /**
  15067. * Updates the poseControlled values based on the input device pose.
  15068. * @param poseData the pose data to update the object with
  15069. */
  15070. updateFromDevice(poseData: DevicePose): void;
  15071. }
  15072. /**
  15073. * Set of options to customize the webVRCamera
  15074. */
  15075. export interface WebVROptions {
  15076. /**
  15077. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15078. */
  15079. trackPosition?: boolean;
  15080. /**
  15081. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15082. */
  15083. positionScale?: number;
  15084. /**
  15085. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15086. */
  15087. displayName?: string;
  15088. /**
  15089. * Should the native controller meshes be initialized. (default: true)
  15090. */
  15091. controllerMeshes?: boolean;
  15092. /**
  15093. * Creating a default HemiLight only on controllers. (default: true)
  15094. */
  15095. defaultLightingOnControllers?: boolean;
  15096. /**
  15097. * If you don't want to use the default VR button of the helper. (default: false)
  15098. */
  15099. useCustomVRButton?: boolean;
  15100. /**
  15101. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15102. */
  15103. customVRButton?: HTMLButtonElement;
  15104. /**
  15105. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15106. */
  15107. rayLength?: number;
  15108. /**
  15109. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15110. */
  15111. defaultHeight?: number;
  15112. /**
  15113. * If multiview should be used if availible (default: false)
  15114. */
  15115. useMultiview?: boolean;
  15116. }
  15117. /**
  15118. * This represents a WebVR camera.
  15119. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15120. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15121. */
  15122. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15123. private webVROptions;
  15124. /**
  15125. * @hidden
  15126. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15127. */
  15128. _vrDevice: any;
  15129. /**
  15130. * The rawPose of the vrDevice.
  15131. */
  15132. rawPose: Nullable<DevicePose>;
  15133. private _onVREnabled;
  15134. private _specsVersion;
  15135. private _attached;
  15136. private _frameData;
  15137. protected _descendants: Array<Node>;
  15138. private _deviceRoomPosition;
  15139. /** @hidden */
  15140. _deviceRoomRotationQuaternion: Quaternion;
  15141. private _standingMatrix;
  15142. /**
  15143. * Represents device position in babylon space.
  15144. */
  15145. devicePosition: Vector3;
  15146. /**
  15147. * Represents device rotation in babylon space.
  15148. */
  15149. deviceRotationQuaternion: Quaternion;
  15150. /**
  15151. * The scale of the device to be used when translating from device space to babylon space.
  15152. */
  15153. deviceScaleFactor: number;
  15154. private _deviceToWorld;
  15155. private _worldToDevice;
  15156. /**
  15157. * References to the webVR controllers for the vrDevice.
  15158. */
  15159. controllers: Array<WebVRController>;
  15160. /**
  15161. * Emits an event when a controller is attached.
  15162. */
  15163. onControllersAttachedObservable: Observable<WebVRController[]>;
  15164. /**
  15165. * Emits an event when a controller's mesh has been loaded;
  15166. */
  15167. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15168. /**
  15169. * Emits an event when the HMD's pose has been updated.
  15170. */
  15171. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15172. private _poseSet;
  15173. /**
  15174. * If the rig cameras be used as parent instead of this camera.
  15175. */
  15176. rigParenting: boolean;
  15177. private _lightOnControllers;
  15178. private _defaultHeight?;
  15179. /**
  15180. * Instantiates a WebVRFreeCamera.
  15181. * @param name The name of the WebVRFreeCamera
  15182. * @param position The starting anchor position for the camera
  15183. * @param scene The scene the camera belongs to
  15184. * @param webVROptions a set of customizable options for the webVRCamera
  15185. */
  15186. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15187. /**
  15188. * Gets the device distance from the ground in meters.
  15189. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15190. */
  15191. deviceDistanceToRoomGround(): number;
  15192. /**
  15193. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15194. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15195. */
  15196. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15197. /**
  15198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15199. * @returns A promise with a boolean set to if the standing matrix is supported.
  15200. */
  15201. useStandingMatrixAsync(): Promise<boolean>;
  15202. /**
  15203. * Disposes the camera
  15204. */
  15205. dispose(): void;
  15206. /**
  15207. * Gets a vrController by name.
  15208. * @param name The name of the controller to retreive
  15209. * @returns the controller matching the name specified or null if not found
  15210. */
  15211. getControllerByName(name: string): Nullable<WebVRController>;
  15212. private _leftController;
  15213. /**
  15214. * The controller corresponding to the users left hand.
  15215. */
  15216. readonly leftController: Nullable<WebVRController>;
  15217. private _rightController;
  15218. /**
  15219. * The controller corresponding to the users right hand.
  15220. */
  15221. readonly rightController: Nullable<WebVRController>;
  15222. /**
  15223. * Casts a ray forward from the vrCamera's gaze.
  15224. * @param length Length of the ray (default: 100)
  15225. * @returns the ray corresponding to the gaze
  15226. */
  15227. getForwardRay(length?: number): Ray;
  15228. /**
  15229. * @hidden
  15230. * Updates the camera based on device's frame data
  15231. */
  15232. _checkInputs(): void;
  15233. /**
  15234. * Updates the poseControlled values based on the input device pose.
  15235. * @param poseData Pose coming from the device
  15236. */
  15237. updateFromDevice(poseData: DevicePose): void;
  15238. private _htmlElementAttached;
  15239. private _detachIfAttached;
  15240. /**
  15241. * WebVR's attach control will start broadcasting frames to the device.
  15242. * Note that in certain browsers (chrome for example) this function must be called
  15243. * within a user-interaction callback. Example:
  15244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15245. *
  15246. * @param element html element to attach the vrDevice to
  15247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15248. */
  15249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15250. /**
  15251. * Detaches the camera from the html element and disables VR
  15252. *
  15253. * @param element html element to detach from
  15254. */
  15255. detachControl(element: HTMLElement): void;
  15256. /**
  15257. * @returns the name of this class
  15258. */
  15259. getClassName(): string;
  15260. /**
  15261. * Calls resetPose on the vrDisplay
  15262. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15263. */
  15264. resetToCurrentRotation(): void;
  15265. /**
  15266. * @hidden
  15267. * Updates the rig cameras (left and right eye)
  15268. */
  15269. _updateRigCameras(): void;
  15270. private _workingVector;
  15271. private _oneVector;
  15272. private _workingMatrix;
  15273. private updateCacheCalled;
  15274. private _correctPositionIfNotTrackPosition;
  15275. /**
  15276. * @hidden
  15277. * Updates the cached values of the camera
  15278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15279. */
  15280. _updateCache(ignoreParentClass?: boolean): void;
  15281. /**
  15282. * @hidden
  15283. * Get current device position in babylon world
  15284. */
  15285. _computeDevicePosition(): void;
  15286. /**
  15287. * Updates the current device position and rotation in the babylon world
  15288. */
  15289. update(): void;
  15290. /**
  15291. * @hidden
  15292. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15293. * @returns an identity matrix
  15294. */
  15295. _getViewMatrix(): Matrix;
  15296. private _tmpMatrix;
  15297. /**
  15298. * This function is called by the two RIG cameras.
  15299. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15300. * @hidden
  15301. */
  15302. _getWebVRViewMatrix(): Matrix;
  15303. /** @hidden */
  15304. _getWebVRProjectionMatrix(): Matrix;
  15305. private _onGamepadConnectedObserver;
  15306. private _onGamepadDisconnectedObserver;
  15307. private _updateCacheWhenTrackingDisabledObserver;
  15308. /**
  15309. * Initializes the controllers and their meshes
  15310. */
  15311. initControllers(): void;
  15312. }
  15313. }
  15314. declare module "babylonjs/PostProcesses/postProcess" {
  15315. import { Nullable } from "babylonjs/types";
  15316. import { SmartArray } from "babylonjs/Misc/smartArray";
  15317. import { Observable } from "babylonjs/Misc/observable";
  15318. import { Vector2 } from "babylonjs/Maths/math.vector";
  15319. import { Camera } from "babylonjs/Cameras/camera";
  15320. import { Effect } from "babylonjs/Materials/effect";
  15321. import "babylonjs/Shaders/postprocess.vertex";
  15322. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15323. import { Engine } from "babylonjs/Engines/engine";
  15324. import { Color4 } from "babylonjs/Maths/math.color";
  15325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15326. /**
  15327. * Size options for a post process
  15328. */
  15329. export type PostProcessOptions = {
  15330. width: number;
  15331. height: number;
  15332. };
  15333. /**
  15334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15336. */
  15337. export class PostProcess {
  15338. /** Name of the PostProcess. */
  15339. name: string;
  15340. /**
  15341. * Gets or sets the unique id of the post process
  15342. */
  15343. uniqueId: number;
  15344. /**
  15345. * Width of the texture to apply the post process on
  15346. */
  15347. width: number;
  15348. /**
  15349. * Height of the texture to apply the post process on
  15350. */
  15351. height: number;
  15352. /**
  15353. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15354. * @hidden
  15355. */
  15356. _outputTexture: Nullable<InternalTexture>;
  15357. /**
  15358. * Sampling mode used by the shader
  15359. * See https://doc.babylonjs.com/classes/3.1/texture
  15360. */
  15361. renderTargetSamplingMode: number;
  15362. /**
  15363. * Clear color to use when screen clearing
  15364. */
  15365. clearColor: Color4;
  15366. /**
  15367. * If the buffer needs to be cleared before applying the post process. (default: true)
  15368. * Should be set to false if shader will overwrite all previous pixels.
  15369. */
  15370. autoClear: boolean;
  15371. /**
  15372. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15373. */
  15374. alphaMode: number;
  15375. /**
  15376. * Sets the setAlphaBlendConstants of the babylon engine
  15377. */
  15378. alphaConstants: Color4;
  15379. /**
  15380. * Animations to be used for the post processing
  15381. */
  15382. animations: import("babylonjs/Animations/animation").Animation[];
  15383. /**
  15384. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15385. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15386. */
  15387. enablePixelPerfectMode: boolean;
  15388. /**
  15389. * Force the postprocess to be applied without taking in account viewport
  15390. */
  15391. forceFullscreenViewport: boolean;
  15392. /**
  15393. * List of inspectable custom properties (used by the Inspector)
  15394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15395. */
  15396. inspectableCustomProperties: IInspectable[];
  15397. /**
  15398. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15399. *
  15400. * | Value | Type | Description |
  15401. * | ----- | ----------------------------------- | ----------- |
  15402. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15403. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15404. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15405. *
  15406. */
  15407. scaleMode: number;
  15408. /**
  15409. * Force textures to be a power of two (default: false)
  15410. */
  15411. alwaysForcePOT: boolean;
  15412. private _samples;
  15413. /**
  15414. * Number of sample textures (default: 1)
  15415. */
  15416. samples: number;
  15417. /**
  15418. * Modify the scale of the post process to be the same as the viewport (default: false)
  15419. */
  15420. adaptScaleToCurrentViewport: boolean;
  15421. private _camera;
  15422. private _scene;
  15423. private _engine;
  15424. private _options;
  15425. private _reusable;
  15426. private _textureType;
  15427. /**
  15428. * Smart array of input and output textures for the post process.
  15429. * @hidden
  15430. */
  15431. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15432. /**
  15433. * The index in _textures that corresponds to the output texture.
  15434. * @hidden
  15435. */
  15436. _currentRenderTextureInd: number;
  15437. private _effect;
  15438. private _samplers;
  15439. private _fragmentUrl;
  15440. private _vertexUrl;
  15441. private _parameters;
  15442. private _scaleRatio;
  15443. protected _indexParameters: any;
  15444. private _shareOutputWithPostProcess;
  15445. private _texelSize;
  15446. private _forcedOutputTexture;
  15447. /**
  15448. * Returns the fragment url or shader name used in the post process.
  15449. * @returns the fragment url or name in the shader store.
  15450. */
  15451. getEffectName(): string;
  15452. /**
  15453. * An event triggered when the postprocess is activated.
  15454. */
  15455. onActivateObservable: Observable<Camera>;
  15456. private _onActivateObserver;
  15457. /**
  15458. * A function that is added to the onActivateObservable
  15459. */
  15460. onActivate: Nullable<(camera: Camera) => void>;
  15461. /**
  15462. * An event triggered when the postprocess changes its size.
  15463. */
  15464. onSizeChangedObservable: Observable<PostProcess>;
  15465. private _onSizeChangedObserver;
  15466. /**
  15467. * A function that is added to the onSizeChangedObservable
  15468. */
  15469. onSizeChanged: (postProcess: PostProcess) => void;
  15470. /**
  15471. * An event triggered when the postprocess applies its effect.
  15472. */
  15473. onApplyObservable: Observable<Effect>;
  15474. private _onApplyObserver;
  15475. /**
  15476. * A function that is added to the onApplyObservable
  15477. */
  15478. onApply: (effect: Effect) => void;
  15479. /**
  15480. * An event triggered before rendering the postprocess
  15481. */
  15482. onBeforeRenderObservable: Observable<Effect>;
  15483. private _onBeforeRenderObserver;
  15484. /**
  15485. * A function that is added to the onBeforeRenderObservable
  15486. */
  15487. onBeforeRender: (effect: Effect) => void;
  15488. /**
  15489. * An event triggered after rendering the postprocess
  15490. */
  15491. onAfterRenderObservable: Observable<Effect>;
  15492. private _onAfterRenderObserver;
  15493. /**
  15494. * A function that is added to the onAfterRenderObservable
  15495. */
  15496. onAfterRender: (efect: Effect) => void;
  15497. /**
  15498. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15499. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15500. */
  15501. inputTexture: InternalTexture;
  15502. /**
  15503. * Gets the camera which post process is applied to.
  15504. * @returns The camera the post process is applied to.
  15505. */
  15506. getCamera(): Camera;
  15507. /**
  15508. * Gets the texel size of the postprocess.
  15509. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15510. */
  15511. readonly texelSize: Vector2;
  15512. /**
  15513. * Creates a new instance PostProcess
  15514. * @param name The name of the PostProcess.
  15515. * @param fragmentUrl The url of the fragment shader to be used.
  15516. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15517. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15518. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15519. * @param camera The camera to apply the render pass to.
  15520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15521. * @param engine The engine which the post process will be applied. (default: current engine)
  15522. * @param reusable If the post process can be reused on the same frame. (default: false)
  15523. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15524. * @param textureType Type of textures used when performing the post process. (default: 0)
  15525. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15526. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15527. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15528. */
  15529. constructor(
  15530. /** Name of the PostProcess. */
  15531. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15532. /**
  15533. * Gets a string idenfifying the name of the class
  15534. * @returns "PostProcess" string
  15535. */
  15536. getClassName(): string;
  15537. /**
  15538. * Gets the engine which this post process belongs to.
  15539. * @returns The engine the post process was enabled with.
  15540. */
  15541. getEngine(): Engine;
  15542. /**
  15543. * The effect that is created when initializing the post process.
  15544. * @returns The created effect corresponding the the postprocess.
  15545. */
  15546. getEffect(): Effect;
  15547. /**
  15548. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15549. * @param postProcess The post process to share the output with.
  15550. * @returns This post process.
  15551. */
  15552. shareOutputWith(postProcess: PostProcess): PostProcess;
  15553. /**
  15554. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15555. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15556. */
  15557. useOwnOutput(): void;
  15558. /**
  15559. * Updates the effect with the current post process compile time values and recompiles the shader.
  15560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15563. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15564. * @param onCompiled Called when the shader has been compiled.
  15565. * @param onError Called if there is an error when compiling a shader.
  15566. */
  15567. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15568. /**
  15569. * The post process is reusable if it can be used multiple times within one frame.
  15570. * @returns If the post process is reusable
  15571. */
  15572. isReusable(): boolean;
  15573. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15574. markTextureDirty(): void;
  15575. /**
  15576. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15577. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15578. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15579. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15580. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15581. * @returns The target texture that was bound to be written to.
  15582. */
  15583. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15584. /**
  15585. * If the post process is supported.
  15586. */
  15587. readonly isSupported: boolean;
  15588. /**
  15589. * The aspect ratio of the output texture.
  15590. */
  15591. readonly aspectRatio: number;
  15592. /**
  15593. * Get a value indicating if the post-process is ready to be used
  15594. * @returns true if the post-process is ready (shader is compiled)
  15595. */
  15596. isReady(): boolean;
  15597. /**
  15598. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15599. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15600. */
  15601. apply(): Nullable<Effect>;
  15602. private _disposeTextures;
  15603. /**
  15604. * Disposes the post process.
  15605. * @param camera The camera to dispose the post process on.
  15606. */
  15607. dispose(camera?: Camera): void;
  15608. }
  15609. }
  15610. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15611. /** @hidden */
  15612. export var kernelBlurVaryingDeclaration: {
  15613. name: string;
  15614. shader: string;
  15615. };
  15616. }
  15617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15618. /** @hidden */
  15619. export var kernelBlurFragment: {
  15620. name: string;
  15621. shader: string;
  15622. };
  15623. }
  15624. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15625. /** @hidden */
  15626. export var kernelBlurFragment2: {
  15627. name: string;
  15628. shader: string;
  15629. };
  15630. }
  15631. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15632. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15633. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15634. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15635. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15636. /** @hidden */
  15637. export var kernelBlurPixelShader: {
  15638. name: string;
  15639. shader: string;
  15640. };
  15641. }
  15642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15643. /** @hidden */
  15644. export var kernelBlurVertex: {
  15645. name: string;
  15646. shader: string;
  15647. };
  15648. }
  15649. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15651. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15652. /** @hidden */
  15653. export var kernelBlurVertexShader: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15659. import { Vector2 } from "babylonjs/Maths/math.vector";
  15660. import { Nullable } from "babylonjs/types";
  15661. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15662. import { Camera } from "babylonjs/Cameras/camera";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Engine } from "babylonjs/Engines/engine";
  15665. import "babylonjs/Shaders/kernelBlur.fragment";
  15666. import "babylonjs/Shaders/kernelBlur.vertex";
  15667. /**
  15668. * The Blur Post Process which blurs an image based on a kernel and direction.
  15669. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15670. */
  15671. export class BlurPostProcess extends PostProcess {
  15672. /** The direction in which to blur the image. */
  15673. direction: Vector2;
  15674. private blockCompilation;
  15675. protected _kernel: number;
  15676. protected _idealKernel: number;
  15677. protected _packedFloat: boolean;
  15678. private _staticDefines;
  15679. /**
  15680. * Sets the length in pixels of the blur sample region
  15681. */
  15682. /**
  15683. * Gets the length in pixels of the blur sample region
  15684. */
  15685. kernel: number;
  15686. /**
  15687. * Sets wether or not the blur needs to unpack/repack floats
  15688. */
  15689. /**
  15690. * Gets wether or not the blur is unpacking/repacking floats
  15691. */
  15692. packedFloat: boolean;
  15693. /**
  15694. * Creates a new instance BlurPostProcess
  15695. * @param name The name of the effect.
  15696. * @param direction The direction in which to blur the image.
  15697. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15698. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15699. * @param camera The camera to apply the render pass to.
  15700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15701. * @param engine The engine which the post process will be applied. (default: current engine)
  15702. * @param reusable If the post process can be reused on the same frame. (default: false)
  15703. * @param textureType Type of textures used when performing the post process. (default: 0)
  15704. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15705. */
  15706. constructor(name: string,
  15707. /** The direction in which to blur the image. */
  15708. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15709. /**
  15710. * Updates the effect with the current post process compile time values and recompiles the shader.
  15711. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15712. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15713. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15714. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15715. * @param onCompiled Called when the shader has been compiled.
  15716. * @param onError Called if there is an error when compiling a shader.
  15717. */
  15718. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15720. /**
  15721. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15722. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15723. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15724. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15725. * The gaps between physical kernels are compensated for in the weighting of the samples
  15726. * @param idealKernel Ideal blur kernel.
  15727. * @return Nearest best kernel.
  15728. */
  15729. protected _nearestBestKernel(idealKernel: number): number;
  15730. /**
  15731. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15732. * @param x The point on the Gaussian distribution to sample.
  15733. * @return the value of the Gaussian function at x.
  15734. */
  15735. protected _gaussianWeight(x: number): number;
  15736. /**
  15737. * Generates a string that can be used as a floating point number in GLSL.
  15738. * @param x Value to print.
  15739. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15740. * @return GLSL float string.
  15741. */
  15742. protected _glslFloat(x: number, decimalFigures?: number): string;
  15743. }
  15744. }
  15745. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15746. import { Scene } from "babylonjs/scene";
  15747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15748. import { Plane } from "babylonjs/Maths/math.plane";
  15749. /**
  15750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15752. * You can then easily use it as a reflectionTexture on a flat surface.
  15753. * In case the surface is not a plane, please consider relying on reflection probes.
  15754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15755. */
  15756. export class MirrorTexture extends RenderTargetTexture {
  15757. private scene;
  15758. /**
  15759. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15760. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15762. */
  15763. mirrorPlane: Plane;
  15764. /**
  15765. * Define the blur ratio used to blur the reflection if needed.
  15766. */
  15767. blurRatio: number;
  15768. /**
  15769. * Define the adaptive blur kernel used to blur the reflection if needed.
  15770. * This will autocompute the closest best match for the `blurKernel`
  15771. */
  15772. adaptiveBlurKernel: number;
  15773. /**
  15774. * Define the blur kernel used to blur the reflection if needed.
  15775. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15776. */
  15777. blurKernel: number;
  15778. /**
  15779. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15781. */
  15782. blurKernelX: number;
  15783. /**
  15784. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15786. */
  15787. blurKernelY: number;
  15788. private _autoComputeBlurKernel;
  15789. protected _onRatioRescale(): void;
  15790. private _updateGammaSpace;
  15791. private _imageProcessingConfigChangeObserver;
  15792. private _transformMatrix;
  15793. private _mirrorMatrix;
  15794. private _savedViewMatrix;
  15795. private _blurX;
  15796. private _blurY;
  15797. private _adaptiveBlurKernel;
  15798. private _blurKernelX;
  15799. private _blurKernelY;
  15800. private _blurRatio;
  15801. /**
  15802. * Instantiates a Mirror Texture.
  15803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15805. * You can then easily use it as a reflectionTexture on a flat surface.
  15806. * In case the surface is not a plane, please consider relying on reflection probes.
  15807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15808. * @param name
  15809. * @param size
  15810. * @param scene
  15811. * @param generateMipMaps
  15812. * @param type
  15813. * @param samplingMode
  15814. * @param generateDepthBuffer
  15815. */
  15816. constructor(name: string, size: number | {
  15817. width: number;
  15818. height: number;
  15819. } | {
  15820. ratio: number;
  15821. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15822. private _preparePostProcesses;
  15823. /**
  15824. * Clone the mirror texture.
  15825. * @returns the cloned texture
  15826. */
  15827. clone(): MirrorTexture;
  15828. /**
  15829. * Serialize the texture to a JSON representation you could use in Parse later on
  15830. * @returns the serialized JSON representation
  15831. */
  15832. serialize(): any;
  15833. /**
  15834. * Dispose the texture and release its associated resources.
  15835. */
  15836. dispose(): void;
  15837. }
  15838. }
  15839. declare module "babylonjs/Materials/Textures/texture" {
  15840. import { Observable } from "babylonjs/Misc/observable";
  15841. import { Nullable } from "babylonjs/types";
  15842. import { Scene } from "babylonjs/scene";
  15843. import { Matrix } from "babylonjs/Maths/math.vector";
  15844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15845. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15846. import { Engine } from "babylonjs/Engines/engine";
  15847. /**
  15848. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15849. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15850. */
  15851. export class Texture extends BaseTexture {
  15852. /** @hidden */
  15853. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15854. /** @hidden */
  15855. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15856. /** @hidden */
  15857. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15858. /** nearest is mag = nearest and min = nearest and mip = linear */
  15859. static readonly NEAREST_SAMPLINGMODE: number;
  15860. /** nearest is mag = nearest and min = nearest and mip = linear */
  15861. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15863. static readonly BILINEAR_SAMPLINGMODE: number;
  15864. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15865. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15866. /** Trilinear is mag = linear and min = linear and mip = linear */
  15867. static readonly TRILINEAR_SAMPLINGMODE: number;
  15868. /** Trilinear is mag = linear and min = linear and mip = linear */
  15869. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15870. /** mag = nearest and min = nearest and mip = nearest */
  15871. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15872. /** mag = nearest and min = linear and mip = nearest */
  15873. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15874. /** mag = nearest and min = linear and mip = linear */
  15875. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15876. /** mag = nearest and min = linear and mip = none */
  15877. static readonly NEAREST_LINEAR: number;
  15878. /** mag = nearest and min = nearest and mip = none */
  15879. static readonly NEAREST_NEAREST: number;
  15880. /** mag = linear and min = nearest and mip = nearest */
  15881. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15882. /** mag = linear and min = nearest and mip = linear */
  15883. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15884. /** mag = linear and min = linear and mip = none */
  15885. static readonly LINEAR_LINEAR: number;
  15886. /** mag = linear and min = nearest and mip = none */
  15887. static readonly LINEAR_NEAREST: number;
  15888. /** Explicit coordinates mode */
  15889. static readonly EXPLICIT_MODE: number;
  15890. /** Spherical coordinates mode */
  15891. static readonly SPHERICAL_MODE: number;
  15892. /** Planar coordinates mode */
  15893. static readonly PLANAR_MODE: number;
  15894. /** Cubic coordinates mode */
  15895. static readonly CUBIC_MODE: number;
  15896. /** Projection coordinates mode */
  15897. static readonly PROJECTION_MODE: number;
  15898. /** Inverse Cubic coordinates mode */
  15899. static readonly SKYBOX_MODE: number;
  15900. /** Inverse Cubic coordinates mode */
  15901. static readonly INVCUBIC_MODE: number;
  15902. /** Equirectangular coordinates mode */
  15903. static readonly EQUIRECTANGULAR_MODE: number;
  15904. /** Equirectangular Fixed coordinates mode */
  15905. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15906. /** Equirectangular Fixed Mirrored coordinates mode */
  15907. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15908. /** Texture is not repeating outside of 0..1 UVs */
  15909. static readonly CLAMP_ADDRESSMODE: number;
  15910. /** Texture is repeating outside of 0..1 UVs */
  15911. static readonly WRAP_ADDRESSMODE: number;
  15912. /** Texture is repeating and mirrored */
  15913. static readonly MIRROR_ADDRESSMODE: number;
  15914. /**
  15915. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  15916. */
  15917. static UseSerializedUrlIfAny: boolean;
  15918. /**
  15919. * Define the url of the texture.
  15920. */
  15921. url: Nullable<string>;
  15922. /**
  15923. * Define an offset on the texture to offset the u coordinates of the UVs
  15924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15925. */
  15926. uOffset: number;
  15927. /**
  15928. * Define an offset on the texture to offset the v coordinates of the UVs
  15929. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15930. */
  15931. vOffset: number;
  15932. /**
  15933. * Define an offset on the texture to scale the u coordinates of the UVs
  15934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15935. */
  15936. uScale: number;
  15937. /**
  15938. * Define an offset on the texture to scale the v coordinates of the UVs
  15939. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15940. */
  15941. vScale: number;
  15942. /**
  15943. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15944. * @see http://doc.babylonjs.com/how_to/more_materials
  15945. */
  15946. uAng: number;
  15947. /**
  15948. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15949. * @see http://doc.babylonjs.com/how_to/more_materials
  15950. */
  15951. vAng: number;
  15952. /**
  15953. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15954. * @see http://doc.babylonjs.com/how_to/more_materials
  15955. */
  15956. wAng: number;
  15957. /**
  15958. * Defines the center of rotation (U)
  15959. */
  15960. uRotationCenter: number;
  15961. /**
  15962. * Defines the center of rotation (V)
  15963. */
  15964. vRotationCenter: number;
  15965. /**
  15966. * Defines the center of rotation (W)
  15967. */
  15968. wRotationCenter: number;
  15969. /**
  15970. * Are mip maps generated for this texture or not.
  15971. */
  15972. readonly noMipmap: boolean;
  15973. /**
  15974. * List of inspectable custom properties (used by the Inspector)
  15975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15976. */
  15977. inspectableCustomProperties: Nullable<IInspectable[]>;
  15978. private _noMipmap;
  15979. /** @hidden */
  15980. _invertY: boolean;
  15981. private _rowGenerationMatrix;
  15982. private _cachedTextureMatrix;
  15983. private _projectionModeMatrix;
  15984. private _t0;
  15985. private _t1;
  15986. private _t2;
  15987. private _cachedUOffset;
  15988. private _cachedVOffset;
  15989. private _cachedUScale;
  15990. private _cachedVScale;
  15991. private _cachedUAng;
  15992. private _cachedVAng;
  15993. private _cachedWAng;
  15994. private _cachedProjectionMatrixId;
  15995. private _cachedCoordinatesMode;
  15996. /** @hidden */
  15997. protected _initialSamplingMode: number;
  15998. /** @hidden */
  15999. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16000. private _deleteBuffer;
  16001. protected _format: Nullable<number>;
  16002. private _delayedOnLoad;
  16003. private _delayedOnError;
  16004. /**
  16005. * Observable triggered once the texture has been loaded.
  16006. */
  16007. onLoadObservable: Observable<Texture>;
  16008. protected _isBlocking: boolean;
  16009. /**
  16010. * Is the texture preventing material to render while loading.
  16011. * If false, a default texture will be used instead of the loading one during the preparation step.
  16012. */
  16013. isBlocking: boolean;
  16014. /**
  16015. * Get the current sampling mode associated with the texture.
  16016. */
  16017. readonly samplingMode: number;
  16018. /**
  16019. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16020. */
  16021. readonly invertY: boolean;
  16022. /**
  16023. * Instantiates a new texture.
  16024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16025. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16026. * @param url define the url of the picture to load as a texture
  16027. * @param scene define the scene or engine the texture will belong to
  16028. * @param noMipmap define if the texture will require mip maps or not
  16029. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16030. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16031. * @param onLoad define a callback triggered when the texture has been loaded
  16032. * @param onError define a callback triggered when an error occurred during the loading session
  16033. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16034. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16035. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16036. */
  16037. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16038. /**
  16039. * Update the url (and optional buffer) of this texture if url was null during construction.
  16040. * @param url the url of the texture
  16041. * @param buffer the buffer of the texture (defaults to null)
  16042. * @param onLoad callback called when the texture is loaded (defaults to null)
  16043. */
  16044. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16045. /**
  16046. * Finish the loading sequence of a texture flagged as delayed load.
  16047. * @hidden
  16048. */
  16049. delayLoad(): void;
  16050. private _prepareRowForTextureGeneration;
  16051. /**
  16052. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16053. * @returns the transform matrix of the texture.
  16054. */
  16055. getTextureMatrix(): Matrix;
  16056. /**
  16057. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16058. * @returns The reflection texture transform
  16059. */
  16060. getReflectionTextureMatrix(): Matrix;
  16061. /**
  16062. * Clones the texture.
  16063. * @returns the cloned texture
  16064. */
  16065. clone(): Texture;
  16066. /**
  16067. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16068. * @returns The JSON representation of the texture
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Get the current class name of the texture useful for serialization or dynamic coding.
  16073. * @returns "Texture"
  16074. */
  16075. getClassName(): string;
  16076. /**
  16077. * Dispose the texture and release its associated resources.
  16078. */
  16079. dispose(): void;
  16080. /**
  16081. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16082. * @param parsedTexture Define the JSON representation of the texture
  16083. * @param scene Define the scene the parsed texture should be instantiated in
  16084. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16085. * @returns The parsed texture if successful
  16086. */
  16087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16088. /**
  16089. * Creates a texture from its base 64 representation.
  16090. * @param data Define the base64 payload without the data: prefix
  16091. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16092. * @param scene Define the scene the texture should belong to
  16093. * @param noMipmap Forces the texture to not create mip map information if true
  16094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16096. * @param onLoad define a callback triggered when the texture has been loaded
  16097. * @param onError define a callback triggered when an error occurred during the loading session
  16098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16099. * @returns the created texture
  16100. */
  16101. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16102. /**
  16103. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16104. * @param data Define the base64 payload without the data: prefix
  16105. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16106. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16107. * @param scene Define the scene the texture should belong to
  16108. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16109. * @param noMipmap Forces the texture to not create mip map information if true
  16110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16112. * @param onLoad define a callback triggered when the texture has been loaded
  16113. * @param onError define a callback triggered when an error occurred during the loading session
  16114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16115. * @returns the created texture
  16116. */
  16117. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16118. }
  16119. }
  16120. declare module "babylonjs/PostProcesses/postProcessManager" {
  16121. import { Nullable } from "babylonjs/types";
  16122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16124. import { Scene } from "babylonjs/scene";
  16125. /**
  16126. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16127. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16128. */
  16129. export class PostProcessManager {
  16130. private _scene;
  16131. private _indexBuffer;
  16132. private _vertexBuffers;
  16133. /**
  16134. * Creates a new instance PostProcess
  16135. * @param scene The scene that the post process is associated with.
  16136. */
  16137. constructor(scene: Scene);
  16138. private _prepareBuffers;
  16139. private _buildIndexBuffer;
  16140. /**
  16141. * Rebuilds the vertex buffers of the manager.
  16142. * @hidden
  16143. */
  16144. _rebuild(): void;
  16145. /**
  16146. * Prepares a frame to be run through a post process.
  16147. * @param sourceTexture The input texture to the post procesess. (default: null)
  16148. * @param postProcesses An array of post processes to be run. (default: null)
  16149. * @returns True if the post processes were able to be run.
  16150. * @hidden
  16151. */
  16152. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16153. /**
  16154. * Manually render a set of post processes to a texture.
  16155. * @param postProcesses An array of post processes to be run.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16158. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16159. * @param lodLevel defines which lod of the texture to render to
  16160. */
  16161. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16162. /**
  16163. * Finalize the result of the output of the postprocesses.
  16164. * @param doNotPresent If true the result will not be displayed to the screen.
  16165. * @param targetTexture The target texture to render to.
  16166. * @param faceIndex The index of the face to bind the target texture to.
  16167. * @param postProcesses The array of post processes to render.
  16168. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16169. * @hidden
  16170. */
  16171. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16172. /**
  16173. * Disposes of the post process manager.
  16174. */
  16175. dispose(): void;
  16176. }
  16177. }
  16178. declare module "babylonjs/Misc/gradients" {
  16179. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16180. /** Interface used by value gradients (color, factor, ...) */
  16181. export interface IValueGradient {
  16182. /**
  16183. * Gets or sets the gradient value (between 0 and 1)
  16184. */
  16185. gradient: number;
  16186. }
  16187. /** Class used to store color4 gradient */
  16188. export class ColorGradient implements IValueGradient {
  16189. /**
  16190. * Gets or sets the gradient value (between 0 and 1)
  16191. */
  16192. gradient: number;
  16193. /**
  16194. * Gets or sets first associated color
  16195. */
  16196. color1: Color4;
  16197. /**
  16198. * Gets or sets second associated color
  16199. */
  16200. color2?: Color4;
  16201. /**
  16202. * Will get a color picked randomly between color1 and color2.
  16203. * If color2 is undefined then color1 will be used
  16204. * @param result defines the target Color4 to store the result in
  16205. */
  16206. getColorToRef(result: Color4): void;
  16207. }
  16208. /** Class used to store color 3 gradient */
  16209. export class Color3Gradient implements IValueGradient {
  16210. /**
  16211. * Gets or sets the gradient value (between 0 and 1)
  16212. */
  16213. gradient: number;
  16214. /**
  16215. * Gets or sets the associated color
  16216. */
  16217. color: Color3;
  16218. }
  16219. /** Class used to store factor gradient */
  16220. export class FactorGradient implements IValueGradient {
  16221. /**
  16222. * Gets or sets the gradient value (between 0 and 1)
  16223. */
  16224. gradient: number;
  16225. /**
  16226. * Gets or sets first associated factor
  16227. */
  16228. factor1: number;
  16229. /**
  16230. * Gets or sets second associated factor
  16231. */
  16232. factor2?: number;
  16233. /**
  16234. * Will get a number picked randomly between factor1 and factor2.
  16235. * If factor2 is undefined then factor1 will be used
  16236. * @returns the picked number
  16237. */
  16238. getFactor(): number;
  16239. }
  16240. /**
  16241. * Helper used to simplify some generic gradient tasks
  16242. */
  16243. export class GradientHelper {
  16244. /**
  16245. * Gets the current gradient from an array of IValueGradient
  16246. * @param ratio defines the current ratio to get
  16247. * @param gradients defines the array of IValueGradient
  16248. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16249. */
  16250. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16251. }
  16252. }
  16253. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16254. import { Scene } from "babylonjs/scene";
  16255. import { ISceneComponent } from "babylonjs/sceneComponent";
  16256. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16257. module "babylonjs/abstractScene" {
  16258. interface AbstractScene {
  16259. /**
  16260. * The list of procedural textures added to the scene
  16261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16262. */
  16263. proceduralTextures: Array<ProceduralTexture>;
  16264. }
  16265. }
  16266. /**
  16267. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16268. * in a given scene.
  16269. */
  16270. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16271. /**
  16272. * The component name helpfull to identify the component in the list of scene components.
  16273. */
  16274. readonly name: string;
  16275. /**
  16276. * The scene the component belongs to.
  16277. */
  16278. scene: Scene;
  16279. /**
  16280. * Creates a new instance of the component for the given scene
  16281. * @param scene Defines the scene to register the component in
  16282. */
  16283. constructor(scene: Scene);
  16284. /**
  16285. * Registers the component in a given scene
  16286. */
  16287. register(): void;
  16288. /**
  16289. * Rebuilds the elements related to this component in case of
  16290. * context lost for instance.
  16291. */
  16292. rebuild(): void;
  16293. /**
  16294. * Disposes the component and the associated ressources.
  16295. */
  16296. dispose(): void;
  16297. private _beforeClear;
  16298. }
  16299. }
  16300. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16302. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16303. module "babylonjs/Engines/engine" {
  16304. interface Engine {
  16305. /**
  16306. * Creates a new render target cube texture
  16307. * @param size defines the size of the texture
  16308. * @param options defines the options used to create the texture
  16309. * @returns a new render target cube texture stored in an InternalTexture
  16310. */
  16311. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16312. }
  16313. }
  16314. }
  16315. declare module "babylonjs/Shaders/procedural.vertex" {
  16316. /** @hidden */
  16317. export var proceduralVertexShader: {
  16318. name: string;
  16319. shader: string;
  16320. };
  16321. }
  16322. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16323. import { Observable } from "babylonjs/Misc/observable";
  16324. import { Nullable } from "babylonjs/types";
  16325. import { Scene } from "babylonjs/scene";
  16326. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16327. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16328. import { Effect } from "babylonjs/Materials/effect";
  16329. import { Texture } from "babylonjs/Materials/Textures/texture";
  16330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16331. import "babylonjs/Shaders/procedural.vertex";
  16332. /**
  16333. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16334. * This is the base class of any Procedural texture and contains most of the shareable code.
  16335. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16336. */
  16337. export class ProceduralTexture extends Texture {
  16338. isCube: boolean;
  16339. /**
  16340. * Define if the texture is enabled or not (disabled texture will not render)
  16341. */
  16342. isEnabled: boolean;
  16343. /**
  16344. * Define if the texture must be cleared before rendering (default is true)
  16345. */
  16346. autoClear: boolean;
  16347. /**
  16348. * Callback called when the texture is generated
  16349. */
  16350. onGenerated: () => void;
  16351. /**
  16352. * Event raised when the texture is generated
  16353. */
  16354. onGeneratedObservable: Observable<ProceduralTexture>;
  16355. /** @hidden */
  16356. _generateMipMaps: boolean;
  16357. /** @hidden **/
  16358. _effect: Effect;
  16359. /** @hidden */
  16360. _textures: {
  16361. [key: string]: Texture;
  16362. };
  16363. private _size;
  16364. private _currentRefreshId;
  16365. private _refreshRate;
  16366. private _vertexBuffers;
  16367. private _indexBuffer;
  16368. private _uniforms;
  16369. private _samplers;
  16370. private _fragment;
  16371. private _floats;
  16372. private _ints;
  16373. private _floatsArrays;
  16374. private _colors3;
  16375. private _colors4;
  16376. private _vectors2;
  16377. private _vectors3;
  16378. private _matrices;
  16379. private _fallbackTexture;
  16380. private _fallbackTextureUsed;
  16381. private _engine;
  16382. private _cachedDefines;
  16383. private _contentUpdateId;
  16384. private _contentData;
  16385. /**
  16386. * Instantiates a new procedural texture.
  16387. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16388. * This is the base class of any Procedural texture and contains most of the shareable code.
  16389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16390. * @param name Define the name of the texture
  16391. * @param size Define the size of the texture to create
  16392. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16393. * @param scene Define the scene the texture belongs to
  16394. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16395. * @param generateMipMaps Define if the texture should creates mip maps or not
  16396. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16397. */
  16398. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16399. /**
  16400. * The effect that is created when initializing the post process.
  16401. * @returns The created effect corresponding the the postprocess.
  16402. */
  16403. getEffect(): Effect;
  16404. /**
  16405. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16406. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16407. */
  16408. getContent(): Nullable<ArrayBufferView>;
  16409. private _createIndexBuffer;
  16410. /** @hidden */
  16411. _rebuild(): void;
  16412. /**
  16413. * Resets the texture in order to recreate its associated resources.
  16414. * This can be called in case of context loss
  16415. */
  16416. reset(): void;
  16417. protected _getDefines(): string;
  16418. /**
  16419. * Is the texture ready to be used ? (rendered at least once)
  16420. * @returns true if ready, otherwise, false.
  16421. */
  16422. isReady(): boolean;
  16423. /**
  16424. * Resets the refresh counter of the texture and start bak from scratch.
  16425. * Could be useful to regenerate the texture if it is setup to render only once.
  16426. */
  16427. resetRefreshCounter(): void;
  16428. /**
  16429. * Set the fragment shader to use in order to render the texture.
  16430. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16431. */
  16432. setFragment(fragment: any): void;
  16433. /**
  16434. * Define the refresh rate of the texture or the rendering frequency.
  16435. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16436. */
  16437. refreshRate: number;
  16438. /** @hidden */
  16439. _shouldRender(): boolean;
  16440. /**
  16441. * Get the size the texture is rendering at.
  16442. * @returns the size (texture is always squared)
  16443. */
  16444. getRenderSize(): number;
  16445. /**
  16446. * Resize the texture to new value.
  16447. * @param size Define the new size the texture should have
  16448. * @param generateMipMaps Define whether the new texture should create mip maps
  16449. */
  16450. resize(size: number, generateMipMaps: boolean): void;
  16451. private _checkUniform;
  16452. /**
  16453. * Set a texture in the shader program used to render.
  16454. * @param name Define the name of the uniform samplers as defined in the shader
  16455. * @param texture Define the texture to bind to this sampler
  16456. * @return the texture itself allowing "fluent" like uniform updates
  16457. */
  16458. setTexture(name: string, texture: Texture): ProceduralTexture;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the texture itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ProceduralTexture;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the texture itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ProceduralTexture;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the texture itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ProceduralTexture;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the texture itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ProceduralTexture;
  16487. /**
  16488. * Set a vec4 in the shader from a Color4.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the texture itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor4(name: string, value: Color4): ProceduralTexture;
  16494. /**
  16495. * Set a vec2 in the shader from a Vector2.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the texture itself allowing "fluent" like uniform updates
  16499. */
  16500. setVector2(name: string, value: Vector2): ProceduralTexture;
  16501. /**
  16502. * Set a vec3 in the shader from a Vector3.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the texture itself allowing "fluent" like uniform updates
  16506. */
  16507. setVector3(name: string, value: Vector3): ProceduralTexture;
  16508. /**
  16509. * Set a mat4 in the shader from a MAtrix.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the texture itself allowing "fluent" like uniform updates
  16513. */
  16514. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16515. /**
  16516. * Render the texture to its associated render target.
  16517. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16518. */
  16519. render(useCameraPostProcess?: boolean): void;
  16520. /**
  16521. * Clone the texture.
  16522. * @returns the cloned texture
  16523. */
  16524. clone(): ProceduralTexture;
  16525. /**
  16526. * Dispose the texture and release its asoociated resources.
  16527. */
  16528. dispose(): void;
  16529. }
  16530. }
  16531. declare module "babylonjs/Particles/baseParticleSystem" {
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16535. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16536. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16537. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16538. import { Scene } from "babylonjs/scene";
  16539. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16540. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16541. import { Texture } from "babylonjs/Materials/Textures/texture";
  16542. import { Color4 } from "babylonjs/Maths/math.color";
  16543. import { Animation } from "babylonjs/Animations/animation";
  16544. /**
  16545. * This represents the base class for particle system in Babylon.
  16546. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16547. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16548. * @example https://doc.babylonjs.com/babylon101/particles
  16549. */
  16550. export class BaseParticleSystem {
  16551. /**
  16552. * Source color is added to the destination color without alpha affecting the result
  16553. */
  16554. static BLENDMODE_ONEONE: number;
  16555. /**
  16556. * Blend current color and particle color using particle’s alpha
  16557. */
  16558. static BLENDMODE_STANDARD: number;
  16559. /**
  16560. * Add current color and particle color multiplied by particle’s alpha
  16561. */
  16562. static BLENDMODE_ADD: number;
  16563. /**
  16564. * Multiply current color with particle color
  16565. */
  16566. static BLENDMODE_MULTIPLY: number;
  16567. /**
  16568. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_MULTIPLYADD: number;
  16571. /**
  16572. * List of animations used by the particle system.
  16573. */
  16574. animations: Animation[];
  16575. /**
  16576. * The id of the Particle system.
  16577. */
  16578. id: string;
  16579. /**
  16580. * The friendly name of the Particle system.
  16581. */
  16582. name: string;
  16583. /**
  16584. * The rendering group used by the Particle system to chose when to render.
  16585. */
  16586. renderingGroupId: number;
  16587. /**
  16588. * The emitter represents the Mesh or position we are attaching the particle system to.
  16589. */
  16590. emitter: Nullable<AbstractMesh | Vector3>;
  16591. /**
  16592. * The maximum number of particles to emit per frame
  16593. */
  16594. emitRate: number;
  16595. /**
  16596. * If you want to launch only a few particles at once, that can be done, as well.
  16597. */
  16598. manualEmitCount: number;
  16599. /**
  16600. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16601. */
  16602. updateSpeed: number;
  16603. /**
  16604. * The amount of time the particle system is running (depends of the overall update speed).
  16605. */
  16606. targetStopDuration: number;
  16607. /**
  16608. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16609. */
  16610. disposeOnStop: boolean;
  16611. /**
  16612. * Minimum power of emitting particles.
  16613. */
  16614. minEmitPower: number;
  16615. /**
  16616. * Maximum power of emitting particles.
  16617. */
  16618. maxEmitPower: number;
  16619. /**
  16620. * Minimum life time of emitting particles.
  16621. */
  16622. minLifeTime: number;
  16623. /**
  16624. * Maximum life time of emitting particles.
  16625. */
  16626. maxLifeTime: number;
  16627. /**
  16628. * Minimum Size of emitting particles.
  16629. */
  16630. minSize: number;
  16631. /**
  16632. * Maximum Size of emitting particles.
  16633. */
  16634. maxSize: number;
  16635. /**
  16636. * Minimum scale of emitting particles on X axis.
  16637. */
  16638. minScaleX: number;
  16639. /**
  16640. * Maximum scale of emitting particles on X axis.
  16641. */
  16642. maxScaleX: number;
  16643. /**
  16644. * Minimum scale of emitting particles on Y axis.
  16645. */
  16646. minScaleY: number;
  16647. /**
  16648. * Maximum scale of emitting particles on Y axis.
  16649. */
  16650. maxScaleY: number;
  16651. /**
  16652. * Gets or sets the minimal initial rotation in radians.
  16653. */
  16654. minInitialRotation: number;
  16655. /**
  16656. * Gets or sets the maximal initial rotation in radians.
  16657. */
  16658. maxInitialRotation: number;
  16659. /**
  16660. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16661. */
  16662. minAngularSpeed: number;
  16663. /**
  16664. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16665. */
  16666. maxAngularSpeed: number;
  16667. /**
  16668. * The texture used to render each particle. (this can be a spritesheet)
  16669. */
  16670. particleTexture: Nullable<Texture>;
  16671. /**
  16672. * The layer mask we are rendering the particles through.
  16673. */
  16674. layerMask: number;
  16675. /**
  16676. * This can help using your own shader to render the particle system.
  16677. * The according effect will be created
  16678. */
  16679. customShader: any;
  16680. /**
  16681. * By default particle system starts as soon as they are created. This prevents the
  16682. * automatic start to happen and let you decide when to start emitting particles.
  16683. */
  16684. preventAutoStart: boolean;
  16685. private _noiseTexture;
  16686. /**
  16687. * Gets or sets a texture used to add random noise to particle positions
  16688. */
  16689. noiseTexture: Nullable<ProceduralTexture>;
  16690. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16691. noiseStrength: Vector3;
  16692. /**
  16693. * Callback triggered when the particle animation is ending.
  16694. */
  16695. onAnimationEnd: Nullable<() => void>;
  16696. /**
  16697. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16698. */
  16699. blendMode: number;
  16700. /**
  16701. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16702. * to override the particles.
  16703. */
  16704. forceDepthWrite: boolean;
  16705. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16706. preWarmCycles: number;
  16707. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16708. preWarmStepOffset: number;
  16709. /**
  16710. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16711. */
  16712. spriteCellChangeSpeed: number;
  16713. /**
  16714. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16715. */
  16716. startSpriteCellID: number;
  16717. /**
  16718. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16719. */
  16720. endSpriteCellID: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16723. */
  16724. spriteCellWidth: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16727. */
  16728. spriteCellHeight: number;
  16729. /**
  16730. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16731. */
  16732. spriteRandomStartCell: boolean;
  16733. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16734. translationPivot: Vector2;
  16735. /** @hidden */
  16736. protected _isAnimationSheetEnabled: boolean;
  16737. /**
  16738. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16739. */
  16740. beginAnimationOnStart: boolean;
  16741. /**
  16742. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16743. */
  16744. beginAnimationFrom: number;
  16745. /**
  16746. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16747. */
  16748. beginAnimationTo: number;
  16749. /**
  16750. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationLoop: boolean;
  16753. /**
  16754. * Gets or sets a world offset applied to all particles
  16755. */
  16756. worldOffset: Vector3;
  16757. /**
  16758. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16759. */
  16760. isAnimationSheetEnabled: boolean;
  16761. /**
  16762. * Get hosting scene
  16763. * @returns the scene
  16764. */
  16765. getScene(): Scene;
  16766. /**
  16767. * You can use gravity if you want to give an orientation to your particles.
  16768. */
  16769. gravity: Vector3;
  16770. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16771. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16772. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16773. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16774. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16775. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16776. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16777. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16778. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16779. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16780. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16781. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16782. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16783. /**
  16784. * Defines the delay in milliseconds before starting the system (0 by default)
  16785. */
  16786. startDelay: number;
  16787. /**
  16788. * Gets the current list of drag gradients.
  16789. * You must use addDragGradient and removeDragGradient to udpate this list
  16790. * @returns the list of drag gradients
  16791. */
  16792. getDragGradients(): Nullable<Array<FactorGradient>>;
  16793. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16794. limitVelocityDamping: number;
  16795. /**
  16796. * Gets the current list of limit velocity gradients.
  16797. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16798. * @returns the list of limit velocity gradients
  16799. */
  16800. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16801. /**
  16802. * Gets the current list of color gradients.
  16803. * You must use addColorGradient and removeColorGradient to udpate this list
  16804. * @returns the list of color gradients
  16805. */
  16806. getColorGradients(): Nullable<Array<ColorGradient>>;
  16807. /**
  16808. * Gets the current list of size gradients.
  16809. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16810. * @returns the list of size gradients
  16811. */
  16812. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Gets the current list of color remap gradients.
  16815. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16816. * @returns the list of color remap gradients
  16817. */
  16818. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16819. /**
  16820. * Gets the current list of alpha remap gradients.
  16821. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16822. * @returns the list of alpha remap gradients
  16823. */
  16824. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16825. /**
  16826. * Gets the current list of life time gradients.
  16827. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16828. * @returns the list of life time gradients
  16829. */
  16830. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16831. /**
  16832. * Gets the current list of angular speed gradients.
  16833. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16834. * @returns the list of angular speed gradients
  16835. */
  16836. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Gets the current list of velocity gradients.
  16839. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16840. * @returns the list of velocity gradients
  16841. */
  16842. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16843. /**
  16844. * Gets the current list of start size gradients.
  16845. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16846. * @returns the list of start size gradients
  16847. */
  16848. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16849. /**
  16850. * Gets the current list of emit rate gradients.
  16851. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16852. * @returns the list of emit rate gradients
  16853. */
  16854. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16855. /**
  16856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16857. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16858. */
  16859. direction1: Vector3;
  16860. /**
  16861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16862. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16863. */
  16864. direction2: Vector3;
  16865. /**
  16866. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16868. */
  16869. minEmitBox: Vector3;
  16870. /**
  16871. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16872. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16873. */
  16874. maxEmitBox: Vector3;
  16875. /**
  16876. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16877. */
  16878. color1: Color4;
  16879. /**
  16880. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16881. */
  16882. color2: Color4;
  16883. /**
  16884. * Color the particle will have at the end of its lifetime
  16885. */
  16886. colorDead: Color4;
  16887. /**
  16888. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16889. */
  16890. textureMask: Color4;
  16891. /**
  16892. * The particle emitter type defines the emitter used by the particle system.
  16893. * It can be for example box, sphere, or cone...
  16894. */
  16895. particleEmitterType: IParticleEmitterType;
  16896. /** @hidden */
  16897. _isSubEmitter: boolean;
  16898. /**
  16899. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16900. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16901. */
  16902. billboardMode: number;
  16903. protected _isBillboardBased: boolean;
  16904. /**
  16905. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16906. */
  16907. isBillboardBased: boolean;
  16908. /**
  16909. * The scene the particle system belongs to.
  16910. */
  16911. protected _scene: Scene;
  16912. /**
  16913. * Local cache of defines for image processing.
  16914. */
  16915. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16916. /**
  16917. * Default configuration related to image processing available in the standard Material.
  16918. */
  16919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16920. /**
  16921. * Gets the image processing configuration used either in this material.
  16922. */
  16923. /**
  16924. * Sets the Default image processing configuration used either in the this material.
  16925. *
  16926. * If sets to null, the scene one is in use.
  16927. */
  16928. imageProcessingConfiguration: ImageProcessingConfiguration;
  16929. /**
  16930. * Attaches a new image processing configuration to the Standard Material.
  16931. * @param configuration
  16932. */
  16933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16934. /** @hidden */
  16935. protected _reset(): void;
  16936. /** @hidden */
  16937. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16938. /**
  16939. * Instantiates a particle system.
  16940. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16941. * @param name The name of the particle system
  16942. */
  16943. constructor(name: string);
  16944. /**
  16945. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16946. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16947. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16948. * @returns the emitter
  16949. */
  16950. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16951. /**
  16952. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16953. * @param radius The radius of the hemisphere to emit from
  16954. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16955. * @returns the emitter
  16956. */
  16957. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16958. /**
  16959. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16960. * @param radius The radius of the sphere to emit from
  16961. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16962. * @returns the emitter
  16963. */
  16964. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16965. /**
  16966. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16967. * @param radius The radius of the sphere to emit from
  16968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16970. * @returns the emitter
  16971. */
  16972. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16973. /**
  16974. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16975. * @param radius The radius of the emission cylinder
  16976. * @param height The height of the emission cylinder
  16977. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16978. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16979. * @returns the emitter
  16980. */
  16981. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16982. /**
  16983. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16984. * @param radius The radius of the cylinder to emit from
  16985. * @param height The height of the emission cylinder
  16986. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16987. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16988. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16989. * @returns the emitter
  16990. */
  16991. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16992. /**
  16993. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16994. * @param radius The radius of the cone to emit from
  16995. * @param angle The base angle of the cone
  16996. * @returns the emitter
  16997. */
  16998. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16999. /**
  17000. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17003. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17004. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17005. * @returns the emitter
  17006. */
  17007. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/subEmitter" {
  17011. import { Scene } from "babylonjs/scene";
  17012. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17013. /**
  17014. * Type of sub emitter
  17015. */
  17016. export enum SubEmitterType {
  17017. /**
  17018. * Attached to the particle over it's lifetime
  17019. */
  17020. ATTACHED = 0,
  17021. /**
  17022. * Created when the particle dies
  17023. */
  17024. END = 1
  17025. }
  17026. /**
  17027. * Sub emitter class used to emit particles from an existing particle
  17028. */
  17029. export class SubEmitter {
  17030. /**
  17031. * the particle system to be used by the sub emitter
  17032. */
  17033. particleSystem: ParticleSystem;
  17034. /**
  17035. * Type of the submitter (Default: END)
  17036. */
  17037. type: SubEmitterType;
  17038. /**
  17039. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17040. * Note: This only is supported when using an emitter of type Mesh
  17041. */
  17042. inheritDirection: boolean;
  17043. /**
  17044. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17045. */
  17046. inheritedVelocityAmount: number;
  17047. /**
  17048. * Creates a sub emitter
  17049. * @param particleSystem the particle system to be used by the sub emitter
  17050. */
  17051. constructor(
  17052. /**
  17053. * the particle system to be used by the sub emitter
  17054. */
  17055. particleSystem: ParticleSystem);
  17056. /**
  17057. * Clones the sub emitter
  17058. * @returns the cloned sub emitter
  17059. */
  17060. clone(): SubEmitter;
  17061. /**
  17062. * Serialize current object to a JSON object
  17063. * @returns the serialized object
  17064. */
  17065. serialize(): any;
  17066. /** @hidden */
  17067. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17068. /**
  17069. * Creates a new SubEmitter from a serialized JSON version
  17070. * @param serializationObject defines the JSON object to read from
  17071. * @param scene defines the hosting scene
  17072. * @param rootUrl defines the rootUrl for data loading
  17073. * @returns a new SubEmitter
  17074. */
  17075. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17076. /** Release associated resources */
  17077. dispose(): void;
  17078. }
  17079. }
  17080. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17081. /** @hidden */
  17082. export var clipPlaneFragmentDeclaration: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17088. /** @hidden */
  17089. export var imageProcessingDeclaration: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17095. /** @hidden */
  17096. export var imageProcessingFunctions: {
  17097. name: string;
  17098. shader: string;
  17099. };
  17100. }
  17101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17102. /** @hidden */
  17103. export var clipPlaneFragment: {
  17104. name: string;
  17105. shader: string;
  17106. };
  17107. }
  17108. declare module "babylonjs/Shaders/particles.fragment" {
  17109. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17110. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17111. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17112. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17113. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17114. /** @hidden */
  17115. export var particlesPixelShader: {
  17116. name: string;
  17117. shader: string;
  17118. };
  17119. }
  17120. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17121. /** @hidden */
  17122. export var clipPlaneVertexDeclaration: {
  17123. name: string;
  17124. shader: string;
  17125. };
  17126. }
  17127. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17128. /** @hidden */
  17129. export var clipPlaneVertex: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/particles.vertex" {
  17135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17136. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17137. /** @hidden */
  17138. export var particlesVertexShader: {
  17139. name: string;
  17140. shader: string;
  17141. };
  17142. }
  17143. declare module "babylonjs/Particles/particleSystem" {
  17144. import { Nullable } from "babylonjs/types";
  17145. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17146. import { Observable } from "babylonjs/Misc/observable";
  17147. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17148. import { Effect } from "babylonjs/Materials/effect";
  17149. import { Scene, IDisposable } from "babylonjs/scene";
  17150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17151. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17152. import { Particle } from "babylonjs/Particles/particle";
  17153. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17155. import "babylonjs/Shaders/particles.fragment";
  17156. import "babylonjs/Shaders/particles.vertex";
  17157. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17158. /**
  17159. * This represents a particle system in Babylon.
  17160. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17161. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17162. * @example https://doc.babylonjs.com/babylon101/particles
  17163. */
  17164. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17165. /**
  17166. * Billboard mode will only apply to Y axis
  17167. */
  17168. static readonly BILLBOARDMODE_Y: number;
  17169. /**
  17170. * Billboard mode will apply to all axes
  17171. */
  17172. static readonly BILLBOARDMODE_ALL: number;
  17173. /**
  17174. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17175. */
  17176. static readonly BILLBOARDMODE_STRETCHED: number;
  17177. /**
  17178. * This function can be defined to provide custom update for active particles.
  17179. * This function will be called instead of regular update (age, position, color, etc.).
  17180. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17181. */
  17182. updateFunction: (particles: Particle[]) => void;
  17183. private _emitterWorldMatrix;
  17184. /**
  17185. * This function can be defined to specify initial direction for every new particle.
  17186. * It by default use the emitterType defined function
  17187. */
  17188. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17189. /**
  17190. * This function can be defined to specify initial position for every new particle.
  17191. * It by default use the emitterType defined function
  17192. */
  17193. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17194. /**
  17195. * @hidden
  17196. */
  17197. _inheritedVelocityOffset: Vector3;
  17198. /**
  17199. * An event triggered when the system is disposed
  17200. */
  17201. onDisposeObservable: Observable<ParticleSystem>;
  17202. private _onDisposeObserver;
  17203. /**
  17204. * Sets a callback that will be triggered when the system is disposed
  17205. */
  17206. onDispose: () => void;
  17207. private _particles;
  17208. private _epsilon;
  17209. private _capacity;
  17210. private _stockParticles;
  17211. private _newPartsExcess;
  17212. private _vertexData;
  17213. private _vertexBuffer;
  17214. private _vertexBuffers;
  17215. private _spriteBuffer;
  17216. private _indexBuffer;
  17217. private _effect;
  17218. private _customEffect;
  17219. private _cachedDefines;
  17220. private _scaledColorStep;
  17221. private _colorDiff;
  17222. private _scaledDirection;
  17223. private _scaledGravity;
  17224. private _currentRenderId;
  17225. private _alive;
  17226. private _useInstancing;
  17227. private _started;
  17228. private _stopped;
  17229. private _actualFrame;
  17230. private _scaledUpdateSpeed;
  17231. private _vertexBufferSize;
  17232. /** @hidden */
  17233. _currentEmitRateGradient: Nullable<FactorGradient>;
  17234. /** @hidden */
  17235. _currentEmitRate1: number;
  17236. /** @hidden */
  17237. _currentEmitRate2: number;
  17238. /** @hidden */
  17239. _currentStartSizeGradient: Nullable<FactorGradient>;
  17240. /** @hidden */
  17241. _currentStartSize1: number;
  17242. /** @hidden */
  17243. _currentStartSize2: number;
  17244. private readonly _rawTextureWidth;
  17245. private _rampGradientsTexture;
  17246. private _useRampGradients;
  17247. /** Gets or sets a boolean indicating that ramp gradients must be used
  17248. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17249. */
  17250. useRampGradients: boolean;
  17251. /**
  17252. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17253. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17254. */
  17255. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17256. private _subEmitters;
  17257. /**
  17258. * @hidden
  17259. * If the particle systems emitter should be disposed when the particle system is disposed
  17260. */
  17261. _disposeEmitterOnDispose: boolean;
  17262. /**
  17263. * The current active Sub-systems, this property is used by the root particle system only.
  17264. */
  17265. activeSubSystems: Array<ParticleSystem>;
  17266. private _rootParticleSystem;
  17267. /**
  17268. * Gets the current list of active particles
  17269. */
  17270. readonly particles: Particle[];
  17271. /**
  17272. * Returns the string "ParticleSystem"
  17273. * @returns a string containing the class name
  17274. */
  17275. getClassName(): string;
  17276. /**
  17277. * Instantiates a particle system.
  17278. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17279. * @param name The name of the particle system
  17280. * @param capacity The max number of particles alive at the same time
  17281. * @param scene The scene the particle system belongs to
  17282. * @param customEffect a custom effect used to change the way particles are rendered by default
  17283. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17284. * @param epsilon Offset used to render the particles
  17285. */
  17286. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17287. private _addFactorGradient;
  17288. private _removeFactorGradient;
  17289. /**
  17290. * Adds a new life time gradient
  17291. * @param gradient defines the gradient to use (between 0 and 1)
  17292. * @param factor defines the life time factor to affect to the specified gradient
  17293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17294. * @returns the current particle system
  17295. */
  17296. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17297. /**
  17298. * Remove a specific life time gradient
  17299. * @param gradient defines the gradient to remove
  17300. * @returns the current particle system
  17301. */
  17302. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17303. /**
  17304. * Adds a new size gradient
  17305. * @param gradient defines the gradient to use (between 0 and 1)
  17306. * @param factor defines the size factor to affect to the specified gradient
  17307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17308. * @returns the current particle system
  17309. */
  17310. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17311. /**
  17312. * Remove a specific size gradient
  17313. * @param gradient defines the gradient to remove
  17314. * @returns the current particle system
  17315. */
  17316. removeSizeGradient(gradient: number): IParticleSystem;
  17317. /**
  17318. * Adds a new color remap gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param min defines the color remap minimal range
  17321. * @param max defines the color remap maximal range
  17322. * @returns the current particle system
  17323. */
  17324. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific color remap gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeColorRemapGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Adds a new alpha remap gradient
  17333. * @param gradient defines the gradient to use (between 0 and 1)
  17334. * @param min defines the alpha remap minimal range
  17335. * @param max defines the alpha remap maximal range
  17336. * @returns the current particle system
  17337. */
  17338. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17339. /**
  17340. * Remove a specific alpha remap gradient
  17341. * @param gradient defines the gradient to remove
  17342. * @returns the current particle system
  17343. */
  17344. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17345. /**
  17346. * Adds a new angular speed gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the angular speed to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific angular speed gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new velocity gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the velocity to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific velocity gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeVelocityGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new limit velocity gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param factor defines the limit velocity value to affect to the specified gradient
  17377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17378. * @returns the current particle system
  17379. */
  17380. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific limit velocity gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new drag gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param factor defines the drag value to affect to the specified gradient
  17391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17392. * @returns the current particle system
  17393. */
  17394. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific drag gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeDragGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the emit rate value to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific emit rate gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeEmitRateGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the start size value to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific start size gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeStartSizeGradient(gradient: number): IParticleSystem;
  17429. private _createRampGradientTexture;
  17430. /**
  17431. * Gets the current list of ramp gradients.
  17432. * You must use addRampGradient and removeRampGradient to udpate this list
  17433. * @returns the list of ramp gradients
  17434. */
  17435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17436. /**
  17437. * Adds a new ramp gradient used to remap particle colors
  17438. * @param gradient defines the gradient to use (between 0 and 1)
  17439. * @param color defines the color to affect to the specified gradient
  17440. * @returns the current particle system
  17441. */
  17442. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17443. /**
  17444. * Remove a specific ramp gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeRampGradient(gradient: number): ParticleSystem;
  17449. /**
  17450. * Adds a new color gradient
  17451. * @param gradient defines the gradient to use (between 0 and 1)
  17452. * @param color1 defines the color to affect to the specified gradient
  17453. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17454. * @returns this particle system
  17455. */
  17456. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17457. /**
  17458. * Remove a specific color gradient
  17459. * @param gradient defines the gradient to remove
  17460. * @returns this particle system
  17461. */
  17462. removeColorGradient(gradient: number): IParticleSystem;
  17463. private _fetchR;
  17464. protected _reset(): void;
  17465. private _resetEffect;
  17466. private _createVertexBuffers;
  17467. private _createIndexBuffer;
  17468. /**
  17469. * Gets the maximum number of particles active at the same time.
  17470. * @returns The max number of active particles.
  17471. */
  17472. getCapacity(): number;
  17473. /**
  17474. * Gets whether there are still active particles in the system.
  17475. * @returns True if it is alive, otherwise false.
  17476. */
  17477. isAlive(): boolean;
  17478. /**
  17479. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17480. * @returns True if it has been started, otherwise false.
  17481. */
  17482. isStarted(): boolean;
  17483. private _prepareSubEmitterInternalArray;
  17484. /**
  17485. * Starts the particle system and begins to emit
  17486. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17487. */
  17488. start(delay?: number): void;
  17489. /**
  17490. * Stops the particle system.
  17491. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17492. */
  17493. stop(stopSubEmitters?: boolean): void;
  17494. /**
  17495. * Remove all active particles
  17496. */
  17497. reset(): void;
  17498. /**
  17499. * @hidden (for internal use only)
  17500. */
  17501. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17502. /**
  17503. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17504. * Its lifetime will start back at 0.
  17505. */
  17506. recycleParticle: (particle: Particle) => void;
  17507. private _stopSubEmitters;
  17508. private _createParticle;
  17509. private _removeFromRoot;
  17510. private _emitFromParticle;
  17511. private _update;
  17512. /** @hidden */
  17513. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17514. /** @hidden */
  17515. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17516. /** @hidden */
  17517. private _getEffect;
  17518. /**
  17519. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17520. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17521. */
  17522. animate(preWarmOnly?: boolean): void;
  17523. private _appendParticleVertices;
  17524. /**
  17525. * Rebuilds the particle system.
  17526. */
  17527. rebuild(): void;
  17528. /**
  17529. * Is this system ready to be used/rendered
  17530. * @return true if the system is ready
  17531. */
  17532. isReady(): boolean;
  17533. private _render;
  17534. /**
  17535. * Renders the particle system in its current state.
  17536. * @returns the current number of particles
  17537. */
  17538. render(): number;
  17539. /**
  17540. * Disposes the particle system and free the associated resources
  17541. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17542. */
  17543. dispose(disposeTexture?: boolean): void;
  17544. /**
  17545. * Clones the particle system.
  17546. * @param name The name of the cloned object
  17547. * @param newEmitter The new emitter to use
  17548. * @returns the cloned particle system
  17549. */
  17550. clone(name: string, newEmitter: any): ParticleSystem;
  17551. /**
  17552. * Serializes the particle system to a JSON object.
  17553. * @returns the JSON object
  17554. */
  17555. serialize(): any;
  17556. /** @hidden */
  17557. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17558. /** @hidden */
  17559. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17560. /**
  17561. * Parses a JSON object to create a particle system.
  17562. * @param parsedParticleSystem The JSON object to parse
  17563. * @param scene The scene to create the particle system in
  17564. * @param rootUrl The root url to use to load external dependencies like texture
  17565. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17566. * @returns the Parsed particle system
  17567. */
  17568. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17569. }
  17570. }
  17571. declare module "babylonjs/Particles/particle" {
  17572. import { Nullable } from "babylonjs/types";
  17573. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17574. import { Color4 } from "babylonjs/Maths/math.color";
  17575. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17576. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17577. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17578. /**
  17579. * A particle represents one of the element emitted by a particle system.
  17580. * This is mainly define by its coordinates, direction, velocity and age.
  17581. */
  17582. export class Particle {
  17583. /**
  17584. * The particle system the particle belongs to.
  17585. */
  17586. particleSystem: ParticleSystem;
  17587. private static _Count;
  17588. /**
  17589. * Unique ID of the particle
  17590. */
  17591. id: number;
  17592. /**
  17593. * The world position of the particle in the scene.
  17594. */
  17595. position: Vector3;
  17596. /**
  17597. * The world direction of the particle in the scene.
  17598. */
  17599. direction: Vector3;
  17600. /**
  17601. * The color of the particle.
  17602. */
  17603. color: Color4;
  17604. /**
  17605. * The color change of the particle per step.
  17606. */
  17607. colorStep: Color4;
  17608. /**
  17609. * Defines how long will the life of the particle be.
  17610. */
  17611. lifeTime: number;
  17612. /**
  17613. * The current age of the particle.
  17614. */
  17615. age: number;
  17616. /**
  17617. * The current size of the particle.
  17618. */
  17619. size: number;
  17620. /**
  17621. * The current scale of the particle.
  17622. */
  17623. scale: Vector2;
  17624. /**
  17625. * The current angle of the particle.
  17626. */
  17627. angle: number;
  17628. /**
  17629. * Defines how fast is the angle changing.
  17630. */
  17631. angularSpeed: number;
  17632. /**
  17633. * Defines the cell index used by the particle to be rendered from a sprite.
  17634. */
  17635. cellIndex: number;
  17636. /**
  17637. * The information required to support color remapping
  17638. */
  17639. remapData: Vector4;
  17640. /** @hidden */
  17641. _randomCellOffset?: number;
  17642. /** @hidden */
  17643. _initialDirection: Nullable<Vector3>;
  17644. /** @hidden */
  17645. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17646. /** @hidden */
  17647. _initialStartSpriteCellID: number;
  17648. /** @hidden */
  17649. _initialEndSpriteCellID: number;
  17650. /** @hidden */
  17651. _currentColorGradient: Nullable<ColorGradient>;
  17652. /** @hidden */
  17653. _currentColor1: Color4;
  17654. /** @hidden */
  17655. _currentColor2: Color4;
  17656. /** @hidden */
  17657. _currentSizeGradient: Nullable<FactorGradient>;
  17658. /** @hidden */
  17659. _currentSize1: number;
  17660. /** @hidden */
  17661. _currentSize2: number;
  17662. /** @hidden */
  17663. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17664. /** @hidden */
  17665. _currentAngularSpeed1: number;
  17666. /** @hidden */
  17667. _currentAngularSpeed2: number;
  17668. /** @hidden */
  17669. _currentVelocityGradient: Nullable<FactorGradient>;
  17670. /** @hidden */
  17671. _currentVelocity1: number;
  17672. /** @hidden */
  17673. _currentVelocity2: number;
  17674. /** @hidden */
  17675. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17676. /** @hidden */
  17677. _currentLimitVelocity1: number;
  17678. /** @hidden */
  17679. _currentLimitVelocity2: number;
  17680. /** @hidden */
  17681. _currentDragGradient: Nullable<FactorGradient>;
  17682. /** @hidden */
  17683. _currentDrag1: number;
  17684. /** @hidden */
  17685. _currentDrag2: number;
  17686. /** @hidden */
  17687. _randomNoiseCoordinates1: Vector3;
  17688. /** @hidden */
  17689. _randomNoiseCoordinates2: Vector3;
  17690. /**
  17691. * Creates a new instance Particle
  17692. * @param particleSystem the particle system the particle belongs to
  17693. */
  17694. constructor(
  17695. /**
  17696. * The particle system the particle belongs to.
  17697. */
  17698. particleSystem: ParticleSystem);
  17699. private updateCellInfoFromSystem;
  17700. /**
  17701. * Defines how the sprite cell index is updated for the particle
  17702. */
  17703. updateCellIndex(): void;
  17704. /** @hidden */
  17705. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17706. /** @hidden */
  17707. _inheritParticleInfoToSubEmitters(): void;
  17708. /** @hidden */
  17709. _reset(): void;
  17710. /**
  17711. * Copy the properties of particle to another one.
  17712. * @param other the particle to copy the information to.
  17713. */
  17714. copyTo(other: Particle): void;
  17715. }
  17716. }
  17717. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17718. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17719. import { Effect } from "babylonjs/Materials/effect";
  17720. import { Particle } from "babylonjs/Particles/particle";
  17721. /**
  17722. * Particle emitter represents a volume emitting particles.
  17723. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17724. */
  17725. export interface IParticleEmitterType {
  17726. /**
  17727. * Called by the particle System when the direction is computed for the created particle.
  17728. * @param worldMatrix is the world matrix of the particle system
  17729. * @param directionToUpdate is the direction vector to update with the result
  17730. * @param particle is the particle we are computed the direction for
  17731. */
  17732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17733. /**
  17734. * Called by the particle System when the position is computed for the created particle.
  17735. * @param worldMatrix is the world matrix of the particle system
  17736. * @param positionToUpdate is the position vector to update with the result
  17737. * @param particle is the particle we are computed the position for
  17738. */
  17739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17740. /**
  17741. * Clones the current emitter and returns a copy of it
  17742. * @returns the new emitter
  17743. */
  17744. clone(): IParticleEmitterType;
  17745. /**
  17746. * Called by the GPUParticleSystem to setup the update shader
  17747. * @param effect defines the update shader
  17748. */
  17749. applyToShader(effect: Effect): void;
  17750. /**
  17751. * Returns a string to use to update the GPU particles update shader
  17752. * @returns the effect defines string
  17753. */
  17754. getEffectDefines(): string;
  17755. /**
  17756. * Returns a string representing the class name
  17757. * @returns a string containing the class name
  17758. */
  17759. getClassName(): string;
  17760. /**
  17761. * Serializes the particle system to a JSON object.
  17762. * @returns the JSON object
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Parse properties from a JSON object
  17767. * @param serializationObject defines the JSON object
  17768. */
  17769. parse(serializationObject: any): void;
  17770. }
  17771. }
  17772. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17774. import { Effect } from "babylonjs/Materials/effect";
  17775. import { Particle } from "babylonjs/Particles/particle";
  17776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17777. /**
  17778. * Particle emitter emitting particles from the inside of a box.
  17779. * It emits the particles randomly between 2 given directions.
  17780. */
  17781. export class BoxParticleEmitter implements IParticleEmitterType {
  17782. /**
  17783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17784. */
  17785. direction1: Vector3;
  17786. /**
  17787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17788. */
  17789. direction2: Vector3;
  17790. /**
  17791. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17792. */
  17793. minEmitBox: Vector3;
  17794. /**
  17795. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17796. */
  17797. maxEmitBox: Vector3;
  17798. /**
  17799. * Creates a new instance BoxParticleEmitter
  17800. */
  17801. constructor();
  17802. /**
  17803. * Called by the particle System when the direction is computed for the created particle.
  17804. * @param worldMatrix is the world matrix of the particle system
  17805. * @param directionToUpdate is the direction vector to update with the result
  17806. * @param particle is the particle we are computed the direction for
  17807. */
  17808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17809. /**
  17810. * Called by the particle System when the position is computed for the created particle.
  17811. * @param worldMatrix is the world matrix of the particle system
  17812. * @param positionToUpdate is the position vector to update with the result
  17813. * @param particle is the particle we are computed the position for
  17814. */
  17815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17816. /**
  17817. * Clones the current emitter and returns a copy of it
  17818. * @returns the new emitter
  17819. */
  17820. clone(): BoxParticleEmitter;
  17821. /**
  17822. * Called by the GPUParticleSystem to setup the update shader
  17823. * @param effect defines the update shader
  17824. */
  17825. applyToShader(effect: Effect): void;
  17826. /**
  17827. * Returns a string to use to update the GPU particles update shader
  17828. * @returns a string containng the defines string
  17829. */
  17830. getEffectDefines(): string;
  17831. /**
  17832. * Returns the string "BoxParticleEmitter"
  17833. * @returns a string containing the class name
  17834. */
  17835. getClassName(): string;
  17836. /**
  17837. * Serializes the particle system to a JSON object.
  17838. * @returns the JSON object
  17839. */
  17840. serialize(): any;
  17841. /**
  17842. * Parse properties from a JSON object
  17843. * @param serializationObject defines the JSON object
  17844. */
  17845. parse(serializationObject: any): void;
  17846. }
  17847. }
  17848. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17849. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17850. import { Effect } from "babylonjs/Materials/effect";
  17851. import { Particle } from "babylonjs/Particles/particle";
  17852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17853. /**
  17854. * Particle emitter emitting particles from the inside of a cone.
  17855. * It emits the particles alongside the cone volume from the base to the particle.
  17856. * The emission direction might be randomized.
  17857. */
  17858. export class ConeParticleEmitter implements IParticleEmitterType {
  17859. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17860. directionRandomizer: number;
  17861. private _radius;
  17862. private _angle;
  17863. private _height;
  17864. /**
  17865. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17866. */
  17867. radiusRange: number;
  17868. /**
  17869. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17870. */
  17871. heightRange: number;
  17872. /**
  17873. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17874. */
  17875. emitFromSpawnPointOnly: boolean;
  17876. /**
  17877. * Gets or sets the radius of the emission cone
  17878. */
  17879. radius: number;
  17880. /**
  17881. * Gets or sets the angle of the emission cone
  17882. */
  17883. angle: number;
  17884. private _buildHeight;
  17885. /**
  17886. * Creates a new instance ConeParticleEmitter
  17887. * @param radius the radius of the emission cone (1 by default)
  17888. * @param angle the cone base angle (PI by default)
  17889. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17890. */
  17891. constructor(radius?: number, angle?: number,
  17892. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17893. directionRandomizer?: number);
  17894. /**
  17895. * Called by the particle System when the direction is computed for the created particle.
  17896. * @param worldMatrix is the world matrix of the particle system
  17897. * @param directionToUpdate is the direction vector to update with the result
  17898. * @param particle is the particle we are computed the direction for
  17899. */
  17900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17901. /**
  17902. * Called by the particle System when the position is computed for the created particle.
  17903. * @param worldMatrix is the world matrix of the particle system
  17904. * @param positionToUpdate is the position vector to update with the result
  17905. * @param particle is the particle we are computed the position for
  17906. */
  17907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17908. /**
  17909. * Clones the current emitter and returns a copy of it
  17910. * @returns the new emitter
  17911. */
  17912. clone(): ConeParticleEmitter;
  17913. /**
  17914. * Called by the GPUParticleSystem to setup the update shader
  17915. * @param effect defines the update shader
  17916. */
  17917. applyToShader(effect: Effect): void;
  17918. /**
  17919. * Returns a string to use to update the GPU particles update shader
  17920. * @returns a string containng the defines string
  17921. */
  17922. getEffectDefines(): string;
  17923. /**
  17924. * Returns the string "ConeParticleEmitter"
  17925. * @returns a string containing the class name
  17926. */
  17927. getClassName(): string;
  17928. /**
  17929. * Serializes the particle system to a JSON object.
  17930. * @returns the JSON object
  17931. */
  17932. serialize(): any;
  17933. /**
  17934. * Parse properties from a JSON object
  17935. * @param serializationObject defines the JSON object
  17936. */
  17937. parse(serializationObject: any): void;
  17938. }
  17939. }
  17940. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17941. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17942. import { Effect } from "babylonjs/Materials/effect";
  17943. import { Particle } from "babylonjs/Particles/particle";
  17944. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17945. /**
  17946. * Particle emitter emitting particles from the inside of a cylinder.
  17947. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17948. */
  17949. export class CylinderParticleEmitter implements IParticleEmitterType {
  17950. /**
  17951. * The radius of the emission cylinder.
  17952. */
  17953. radius: number;
  17954. /**
  17955. * The height of the emission cylinder.
  17956. */
  17957. height: number;
  17958. /**
  17959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17960. */
  17961. radiusRange: number;
  17962. /**
  17963. * How much to randomize the particle direction [0-1].
  17964. */
  17965. directionRandomizer: number;
  17966. /**
  17967. * Creates a new instance CylinderParticleEmitter
  17968. * @param radius the radius of the emission cylinder (1 by default)
  17969. * @param height the height of the emission cylinder (1 by default)
  17970. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17972. */
  17973. constructor(
  17974. /**
  17975. * The radius of the emission cylinder.
  17976. */
  17977. radius?: number,
  17978. /**
  17979. * The height of the emission cylinder.
  17980. */
  17981. height?: number,
  17982. /**
  17983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17984. */
  17985. radiusRange?: number,
  17986. /**
  17987. * How much to randomize the particle direction [0-1].
  17988. */
  17989. directionRandomizer?: number);
  17990. /**
  17991. * Called by the particle System when the direction is computed for the created particle.
  17992. * @param worldMatrix is the world matrix of the particle system
  17993. * @param directionToUpdate is the direction vector to update with the result
  17994. * @param particle is the particle we are computed the direction for
  17995. */
  17996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17997. /**
  17998. * Called by the particle System when the position is computed for the created particle.
  17999. * @param worldMatrix is the world matrix of the particle system
  18000. * @param positionToUpdate is the position vector to update with the result
  18001. * @param particle is the particle we are computed the position for
  18002. */
  18003. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18004. /**
  18005. * Clones the current emitter and returns a copy of it
  18006. * @returns the new emitter
  18007. */
  18008. clone(): CylinderParticleEmitter;
  18009. /**
  18010. * Called by the GPUParticleSystem to setup the update shader
  18011. * @param effect defines the update shader
  18012. */
  18013. applyToShader(effect: Effect): void;
  18014. /**
  18015. * Returns a string to use to update the GPU particles update shader
  18016. * @returns a string containng the defines string
  18017. */
  18018. getEffectDefines(): string;
  18019. /**
  18020. * Returns the string "CylinderParticleEmitter"
  18021. * @returns a string containing the class name
  18022. */
  18023. getClassName(): string;
  18024. /**
  18025. * Serializes the particle system to a JSON object.
  18026. * @returns the JSON object
  18027. */
  18028. serialize(): any;
  18029. /**
  18030. * Parse properties from a JSON object
  18031. * @param serializationObject defines the JSON object
  18032. */
  18033. parse(serializationObject: any): void;
  18034. }
  18035. /**
  18036. * Particle emitter emitting particles from the inside of a cylinder.
  18037. * It emits the particles randomly between two vectors.
  18038. */
  18039. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18040. /**
  18041. * The min limit of the emission direction.
  18042. */
  18043. direction1: Vector3;
  18044. /**
  18045. * The max limit of the emission direction.
  18046. */
  18047. direction2: Vector3;
  18048. /**
  18049. * Creates a new instance CylinderDirectedParticleEmitter
  18050. * @param radius the radius of the emission cylinder (1 by default)
  18051. * @param height the height of the emission cylinder (1 by default)
  18052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18053. * @param direction1 the min limit of the emission direction (up vector by default)
  18054. * @param direction2 the max limit of the emission direction (up vector by default)
  18055. */
  18056. constructor(radius?: number, height?: number, radiusRange?: number,
  18057. /**
  18058. * The min limit of the emission direction.
  18059. */
  18060. direction1?: Vector3,
  18061. /**
  18062. * The max limit of the emission direction.
  18063. */
  18064. direction2?: Vector3);
  18065. /**
  18066. * Called by the particle System when the direction is computed for the created particle.
  18067. * @param worldMatrix is the world matrix of the particle system
  18068. * @param directionToUpdate is the direction vector to update with the result
  18069. * @param particle is the particle we are computed the direction for
  18070. */
  18071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18072. /**
  18073. * Clones the current emitter and returns a copy of it
  18074. * @returns the new emitter
  18075. */
  18076. clone(): CylinderDirectedParticleEmitter;
  18077. /**
  18078. * Called by the GPUParticleSystem to setup the update shader
  18079. * @param effect defines the update shader
  18080. */
  18081. applyToShader(effect: Effect): void;
  18082. /**
  18083. * Returns a string to use to update the GPU particles update shader
  18084. * @returns a string containng the defines string
  18085. */
  18086. getEffectDefines(): string;
  18087. /**
  18088. * Returns the string "CylinderDirectedParticleEmitter"
  18089. * @returns a string containing the class name
  18090. */
  18091. getClassName(): string;
  18092. /**
  18093. * Serializes the particle system to a JSON object.
  18094. * @returns the JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parse properties from a JSON object
  18099. * @param serializationObject defines the JSON object
  18100. */
  18101. parse(serializationObject: any): void;
  18102. }
  18103. }
  18104. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18105. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18106. import { Effect } from "babylonjs/Materials/effect";
  18107. import { Particle } from "babylonjs/Particles/particle";
  18108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18109. /**
  18110. * Particle emitter emitting particles from the inside of a hemisphere.
  18111. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18112. */
  18113. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18114. /**
  18115. * The radius of the emission hemisphere.
  18116. */
  18117. radius: number;
  18118. /**
  18119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18120. */
  18121. radiusRange: number;
  18122. /**
  18123. * How much to randomize the particle direction [0-1].
  18124. */
  18125. directionRandomizer: number;
  18126. /**
  18127. * Creates a new instance HemisphericParticleEmitter
  18128. * @param radius the radius of the emission hemisphere (1 by default)
  18129. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18130. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18131. */
  18132. constructor(
  18133. /**
  18134. * The radius of the emission hemisphere.
  18135. */
  18136. radius?: number,
  18137. /**
  18138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18139. */
  18140. radiusRange?: number,
  18141. /**
  18142. * How much to randomize the particle direction [0-1].
  18143. */
  18144. directionRandomizer?: number);
  18145. /**
  18146. * Called by the particle System when the direction is computed for the created particle.
  18147. * @param worldMatrix is the world matrix of the particle system
  18148. * @param directionToUpdate is the direction vector to update with the result
  18149. * @param particle is the particle we are computed the direction for
  18150. */
  18151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18152. /**
  18153. * Called by the particle System when the position is computed for the created particle.
  18154. * @param worldMatrix is the world matrix of the particle system
  18155. * @param positionToUpdate is the position vector to update with the result
  18156. * @param particle is the particle we are computed the position for
  18157. */
  18158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18159. /**
  18160. * Clones the current emitter and returns a copy of it
  18161. * @returns the new emitter
  18162. */
  18163. clone(): HemisphericParticleEmitter;
  18164. /**
  18165. * Called by the GPUParticleSystem to setup the update shader
  18166. * @param effect defines the update shader
  18167. */
  18168. applyToShader(effect: Effect): void;
  18169. /**
  18170. * Returns a string to use to update the GPU particles update shader
  18171. * @returns a string containng the defines string
  18172. */
  18173. getEffectDefines(): string;
  18174. /**
  18175. * Returns the string "HemisphericParticleEmitter"
  18176. * @returns a string containing the class name
  18177. */
  18178. getClassName(): string;
  18179. /**
  18180. * Serializes the particle system to a JSON object.
  18181. * @returns the JSON object
  18182. */
  18183. serialize(): any;
  18184. /**
  18185. * Parse properties from a JSON object
  18186. * @param serializationObject defines the JSON object
  18187. */
  18188. parse(serializationObject: any): void;
  18189. }
  18190. }
  18191. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18192. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18193. import { Effect } from "babylonjs/Materials/effect";
  18194. import { Particle } from "babylonjs/Particles/particle";
  18195. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18196. /**
  18197. * Particle emitter emitting particles from a point.
  18198. * It emits the particles randomly between 2 given directions.
  18199. */
  18200. export class PointParticleEmitter implements IParticleEmitterType {
  18201. /**
  18202. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18203. */
  18204. direction1: Vector3;
  18205. /**
  18206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18207. */
  18208. direction2: Vector3;
  18209. /**
  18210. * Creates a new instance PointParticleEmitter
  18211. */
  18212. constructor();
  18213. /**
  18214. * Called by the particle System when the direction is computed for the created particle.
  18215. * @param worldMatrix is the world matrix of the particle system
  18216. * @param directionToUpdate is the direction vector to update with the result
  18217. * @param particle is the particle we are computed the direction for
  18218. */
  18219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18220. /**
  18221. * Called by the particle System when the position is computed for the created particle.
  18222. * @param worldMatrix is the world matrix of the particle system
  18223. * @param positionToUpdate is the position vector to update with the result
  18224. * @param particle is the particle we are computed the position for
  18225. */
  18226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18227. /**
  18228. * Clones the current emitter and returns a copy of it
  18229. * @returns the new emitter
  18230. */
  18231. clone(): PointParticleEmitter;
  18232. /**
  18233. * Called by the GPUParticleSystem to setup the update shader
  18234. * @param effect defines the update shader
  18235. */
  18236. applyToShader(effect: Effect): void;
  18237. /**
  18238. * Returns a string to use to update the GPU particles update shader
  18239. * @returns a string containng the defines string
  18240. */
  18241. getEffectDefines(): string;
  18242. /**
  18243. * Returns the string "PointParticleEmitter"
  18244. * @returns a string containing the class name
  18245. */
  18246. getClassName(): string;
  18247. /**
  18248. * Serializes the particle system to a JSON object.
  18249. * @returns the JSON object
  18250. */
  18251. serialize(): any;
  18252. /**
  18253. * Parse properties from a JSON object
  18254. * @param serializationObject defines the JSON object
  18255. */
  18256. parse(serializationObject: any): void;
  18257. }
  18258. }
  18259. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18260. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18261. import { Effect } from "babylonjs/Materials/effect";
  18262. import { Particle } from "babylonjs/Particles/particle";
  18263. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18264. /**
  18265. * Particle emitter emitting particles from the inside of a sphere.
  18266. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18267. */
  18268. export class SphereParticleEmitter implements IParticleEmitterType {
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius: number;
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange: number;
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer: number;
  18281. /**
  18282. * Creates a new instance SphereParticleEmitter
  18283. * @param radius the radius of the emission sphere (1 by default)
  18284. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18285. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18286. */
  18287. constructor(
  18288. /**
  18289. * The radius of the emission sphere.
  18290. */
  18291. radius?: number,
  18292. /**
  18293. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18294. */
  18295. radiusRange?: number,
  18296. /**
  18297. * How much to randomize the particle direction [0-1].
  18298. */
  18299. directionRandomizer?: number);
  18300. /**
  18301. * Called by the particle System when the direction is computed for the created particle.
  18302. * @param worldMatrix is the world matrix of the particle system
  18303. * @param directionToUpdate is the direction vector to update with the result
  18304. * @param particle is the particle we are computed the direction for
  18305. */
  18306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18307. /**
  18308. * Called by the particle System when the position is computed for the created particle.
  18309. * @param worldMatrix is the world matrix of the particle system
  18310. * @param positionToUpdate is the position vector to update with the result
  18311. * @param particle is the particle we are computed the position for
  18312. */
  18313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18314. /**
  18315. * Clones the current emitter and returns a copy of it
  18316. * @returns the new emitter
  18317. */
  18318. clone(): SphereParticleEmitter;
  18319. /**
  18320. * Called by the GPUParticleSystem to setup the update shader
  18321. * @param effect defines the update shader
  18322. */
  18323. applyToShader(effect: Effect): void;
  18324. /**
  18325. * Returns a string to use to update the GPU particles update shader
  18326. * @returns a string containng the defines string
  18327. */
  18328. getEffectDefines(): string;
  18329. /**
  18330. * Returns the string "SphereParticleEmitter"
  18331. * @returns a string containing the class name
  18332. */
  18333. getClassName(): string;
  18334. /**
  18335. * Serializes the particle system to a JSON object.
  18336. * @returns the JSON object
  18337. */
  18338. serialize(): any;
  18339. /**
  18340. * Parse properties from a JSON object
  18341. * @param serializationObject defines the JSON object
  18342. */
  18343. parse(serializationObject: any): void;
  18344. }
  18345. /**
  18346. * Particle emitter emitting particles from the inside of a sphere.
  18347. * It emits the particles randomly between two vectors.
  18348. */
  18349. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18350. /**
  18351. * The min limit of the emission direction.
  18352. */
  18353. direction1: Vector3;
  18354. /**
  18355. * The max limit of the emission direction.
  18356. */
  18357. direction2: Vector3;
  18358. /**
  18359. * Creates a new instance SphereDirectedParticleEmitter
  18360. * @param radius the radius of the emission sphere (1 by default)
  18361. * @param direction1 the min limit of the emission direction (up vector by default)
  18362. * @param direction2 the max limit of the emission direction (up vector by default)
  18363. */
  18364. constructor(radius?: number,
  18365. /**
  18366. * The min limit of the emission direction.
  18367. */
  18368. direction1?: Vector3,
  18369. /**
  18370. * The max limit of the emission direction.
  18371. */
  18372. direction2?: Vector3);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Clones the current emitter and returns a copy of it
  18382. * @returns the new emitter
  18383. */
  18384. clone(): SphereDirectedParticleEmitter;
  18385. /**
  18386. * Called by the GPUParticleSystem to setup the update shader
  18387. * @param effect defines the update shader
  18388. */
  18389. applyToShader(effect: Effect): void;
  18390. /**
  18391. * Returns a string to use to update the GPU particles update shader
  18392. * @returns a string containng the defines string
  18393. */
  18394. getEffectDefines(): string;
  18395. /**
  18396. * Returns the string "SphereDirectedParticleEmitter"
  18397. * @returns a string containing the class name
  18398. */
  18399. getClassName(): string;
  18400. /**
  18401. * Serializes the particle system to a JSON object.
  18402. * @returns the JSON object
  18403. */
  18404. serialize(): any;
  18405. /**
  18406. * Parse properties from a JSON object
  18407. * @param serializationObject defines the JSON object
  18408. */
  18409. parse(serializationObject: any): void;
  18410. }
  18411. }
  18412. declare module "babylonjs/Particles/EmitterTypes/index" {
  18413. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18414. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18415. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18416. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18417. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18418. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18419. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18420. }
  18421. declare module "babylonjs/Particles/IParticleSystem" {
  18422. import { Nullable } from "babylonjs/types";
  18423. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18424. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18427. import { Texture } from "babylonjs/Materials/Textures/texture";
  18428. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18429. import { Scene } from "babylonjs/scene";
  18430. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18431. import { Animation } from "babylonjs/Animations/animation";
  18432. /**
  18433. * Interface representing a particle system in Babylon.js.
  18434. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18435. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18436. */
  18437. export interface IParticleSystem {
  18438. /**
  18439. * List of animations used by the particle system.
  18440. */
  18441. animations: Animation[];
  18442. /**
  18443. * The id of the Particle system.
  18444. */
  18445. id: string;
  18446. /**
  18447. * The name of the Particle system.
  18448. */
  18449. name: string;
  18450. /**
  18451. * The emitter represents the Mesh or position we are attaching the particle system to.
  18452. */
  18453. emitter: Nullable<AbstractMesh | Vector3>;
  18454. /**
  18455. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18456. */
  18457. isBillboardBased: boolean;
  18458. /**
  18459. * The rendering group used by the Particle system to chose when to render.
  18460. */
  18461. renderingGroupId: number;
  18462. /**
  18463. * The layer mask we are rendering the particles through.
  18464. */
  18465. layerMask: number;
  18466. /**
  18467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18468. */
  18469. updateSpeed: number;
  18470. /**
  18471. * The amount of time the particle system is running (depends of the overall update speed).
  18472. */
  18473. targetStopDuration: number;
  18474. /**
  18475. * The texture used to render each particle. (this can be a spritesheet)
  18476. */
  18477. particleTexture: Nullable<Texture>;
  18478. /**
  18479. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18480. */
  18481. blendMode: number;
  18482. /**
  18483. * Minimum life time of emitting particles.
  18484. */
  18485. minLifeTime: number;
  18486. /**
  18487. * Maximum life time of emitting particles.
  18488. */
  18489. maxLifeTime: number;
  18490. /**
  18491. * Minimum Size of emitting particles.
  18492. */
  18493. minSize: number;
  18494. /**
  18495. * Maximum Size of emitting particles.
  18496. */
  18497. maxSize: number;
  18498. /**
  18499. * Minimum scale of emitting particles on X axis.
  18500. */
  18501. minScaleX: number;
  18502. /**
  18503. * Maximum scale of emitting particles on X axis.
  18504. */
  18505. maxScaleX: number;
  18506. /**
  18507. * Minimum scale of emitting particles on Y axis.
  18508. */
  18509. minScaleY: number;
  18510. /**
  18511. * Maximum scale of emitting particles on Y axis.
  18512. */
  18513. maxScaleY: number;
  18514. /**
  18515. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18516. */
  18517. color1: Color4;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color2: Color4;
  18522. /**
  18523. * Color the particle will have at the end of its lifetime.
  18524. */
  18525. colorDead: Color4;
  18526. /**
  18527. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18528. */
  18529. emitRate: number;
  18530. /**
  18531. * You can use gravity if you want to give an orientation to your particles.
  18532. */
  18533. gravity: Vector3;
  18534. /**
  18535. * Minimum power of emitting particles.
  18536. */
  18537. minEmitPower: number;
  18538. /**
  18539. * Maximum power of emitting particles.
  18540. */
  18541. maxEmitPower: number;
  18542. /**
  18543. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18544. */
  18545. minAngularSpeed: number;
  18546. /**
  18547. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. maxAngularSpeed: number;
  18550. /**
  18551. * Gets or sets the minimal initial rotation in radians.
  18552. */
  18553. minInitialRotation: number;
  18554. /**
  18555. * Gets or sets the maximal initial rotation in radians.
  18556. */
  18557. maxInitialRotation: number;
  18558. /**
  18559. * The particle emitter type defines the emitter used by the particle system.
  18560. * It can be for example box, sphere, or cone...
  18561. */
  18562. particleEmitterType: Nullable<IParticleEmitterType>;
  18563. /**
  18564. * Defines the delay in milliseconds before starting the system (0 by default)
  18565. */
  18566. startDelay: number;
  18567. /**
  18568. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18569. */
  18570. preWarmCycles: number;
  18571. /**
  18572. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18573. */
  18574. preWarmStepOffset: number;
  18575. /**
  18576. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18577. */
  18578. spriteCellChangeSpeed: number;
  18579. /**
  18580. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18581. */
  18582. startSpriteCellID: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18585. */
  18586. endSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18589. */
  18590. spriteCellWidth: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18593. */
  18594. spriteCellHeight: number;
  18595. /**
  18596. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18597. */
  18598. spriteRandomStartCell: boolean;
  18599. /**
  18600. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18601. */
  18602. isAnimationSheetEnabled: boolean;
  18603. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18604. translationPivot: Vector2;
  18605. /**
  18606. * Gets or sets a texture used to add random noise to particle positions
  18607. */
  18608. noiseTexture: Nullable<BaseTexture>;
  18609. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18610. noiseStrength: Vector3;
  18611. /**
  18612. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18613. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18614. */
  18615. billboardMode: number;
  18616. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18617. limitVelocityDamping: number;
  18618. /**
  18619. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18620. */
  18621. beginAnimationOnStart: boolean;
  18622. /**
  18623. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18624. */
  18625. beginAnimationFrom: number;
  18626. /**
  18627. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationTo: number;
  18630. /**
  18631. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationLoop: boolean;
  18634. /**
  18635. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18636. */
  18637. disposeOnStop: boolean;
  18638. /**
  18639. * Gets the maximum number of particles active at the same time.
  18640. * @returns The max number of active particles.
  18641. */
  18642. getCapacity(): number;
  18643. /**
  18644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18645. * @returns True if it has been started, otherwise false.
  18646. */
  18647. isStarted(): boolean;
  18648. /**
  18649. * Animates the particle system for this frame.
  18650. */
  18651. animate(): void;
  18652. /**
  18653. * Renders the particle system in its current state.
  18654. * @returns the current number of particles
  18655. */
  18656. render(): number;
  18657. /**
  18658. * Dispose the particle system and frees its associated resources.
  18659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18660. */
  18661. dispose(disposeTexture?: boolean): void;
  18662. /**
  18663. * Clones the particle system.
  18664. * @param name The name of the cloned object
  18665. * @param newEmitter The new emitter to use
  18666. * @returns the cloned particle system
  18667. */
  18668. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18669. /**
  18670. * Serializes the particle system to a JSON object.
  18671. * @returns the JSON object
  18672. */
  18673. serialize(): any;
  18674. /**
  18675. * Rebuild the particle system
  18676. */
  18677. rebuild(): void;
  18678. /**
  18679. * Starts the particle system and begins to emit
  18680. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18681. */
  18682. start(delay?: number): void;
  18683. /**
  18684. * Stops the particle system.
  18685. */
  18686. stop(): void;
  18687. /**
  18688. * Remove all active particles
  18689. */
  18690. reset(): void;
  18691. /**
  18692. * Is this system ready to be used/rendered
  18693. * @return true if the system is ready
  18694. */
  18695. isReady(): boolean;
  18696. /**
  18697. * Adds a new color gradient
  18698. * @param gradient defines the gradient to use (between 0 and 1)
  18699. * @param color1 defines the color to affect to the specified gradient
  18700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18701. * @returns the current particle system
  18702. */
  18703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18704. /**
  18705. * Remove a specific color gradient
  18706. * @param gradient defines the gradient to remove
  18707. * @returns the current particle system
  18708. */
  18709. removeColorGradient(gradient: number): IParticleSystem;
  18710. /**
  18711. * Adds a new size gradient
  18712. * @param gradient defines the gradient to use (between 0 and 1)
  18713. * @param factor defines the size factor to affect to the specified gradient
  18714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18715. * @returns the current particle system
  18716. */
  18717. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18718. /**
  18719. * Remove a specific size gradient
  18720. * @param gradient defines the gradient to remove
  18721. * @returns the current particle system
  18722. */
  18723. removeSizeGradient(gradient: number): IParticleSystem;
  18724. /**
  18725. * Gets the current list of color gradients.
  18726. * You must use addColorGradient and removeColorGradient to udpate this list
  18727. * @returns the list of color gradients
  18728. */
  18729. getColorGradients(): Nullable<Array<ColorGradient>>;
  18730. /**
  18731. * Gets the current list of size gradients.
  18732. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18733. * @returns the list of size gradients
  18734. */
  18735. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18736. /**
  18737. * Gets the current list of angular speed gradients.
  18738. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18739. * @returns the list of angular speed gradients
  18740. */
  18741. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18742. /**
  18743. * Adds a new angular speed gradient
  18744. * @param gradient defines the gradient to use (between 0 and 1)
  18745. * @param factor defines the angular speed to affect to the specified gradient
  18746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18747. * @returns the current particle system
  18748. */
  18749. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18750. /**
  18751. * Remove a specific angular speed gradient
  18752. * @param gradient defines the gradient to remove
  18753. * @returns the current particle system
  18754. */
  18755. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18756. /**
  18757. * Gets the current list of velocity gradients.
  18758. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18759. * @returns the list of velocity gradients
  18760. */
  18761. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18762. /**
  18763. * Adds a new velocity gradient
  18764. * @param gradient defines the gradient to use (between 0 and 1)
  18765. * @param factor defines the velocity to affect to the specified gradient
  18766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18767. * @returns the current particle system
  18768. */
  18769. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18770. /**
  18771. * Remove a specific velocity gradient
  18772. * @param gradient defines the gradient to remove
  18773. * @returns the current particle system
  18774. */
  18775. removeVelocityGradient(gradient: number): IParticleSystem;
  18776. /**
  18777. * Gets the current list of limit velocity gradients.
  18778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18779. * @returns the list of limit velocity gradients
  18780. */
  18781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18782. /**
  18783. * Adds a new limit velocity gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the limit velocity to affect to the specified gradient
  18786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18787. * @returns the current particle system
  18788. */
  18789. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific limit velocity gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Adds a new drag gradient
  18798. * @param gradient defines the gradient to use (between 0 and 1)
  18799. * @param factor defines the drag to affect to the specified gradient
  18800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18801. * @returns the current particle system
  18802. */
  18803. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18804. /**
  18805. * Remove a specific drag gradient
  18806. * @param gradient defines the gradient to remove
  18807. * @returns the current particle system
  18808. */
  18809. removeDragGradient(gradient: number): IParticleSystem;
  18810. /**
  18811. * Gets the current list of drag gradients.
  18812. * You must use addDragGradient and removeDragGradient to udpate this list
  18813. * @returns the list of drag gradients
  18814. */
  18815. getDragGradients(): Nullable<Array<FactorGradient>>;
  18816. /**
  18817. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18818. * @param gradient defines the gradient to use (between 0 and 1)
  18819. * @param factor defines the emit rate to affect to the specified gradient
  18820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18821. * @returns the current particle system
  18822. */
  18823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18824. /**
  18825. * Remove a specific emit rate gradient
  18826. * @param gradient defines the gradient to remove
  18827. * @returns the current particle system
  18828. */
  18829. removeEmitRateGradient(gradient: number): IParticleSystem;
  18830. /**
  18831. * Gets the current list of emit rate gradients.
  18832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18833. * @returns the list of emit rate gradients
  18834. */
  18835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18836. /**
  18837. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18838. * @param gradient defines the gradient to use (between 0 and 1)
  18839. * @param factor defines the start size to affect to the specified gradient
  18840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18841. * @returns the current particle system
  18842. */
  18843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18844. /**
  18845. * Remove a specific start size gradient
  18846. * @param gradient defines the gradient to remove
  18847. * @returns the current particle system
  18848. */
  18849. removeStartSizeGradient(gradient: number): IParticleSystem;
  18850. /**
  18851. * Gets the current list of start size gradients.
  18852. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18853. * @returns the list of start size gradients
  18854. */
  18855. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18856. /**
  18857. * Adds a new life time gradient
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the life time factor to affect to the specified gradient
  18860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18861. * @returns the current particle system
  18862. */
  18863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific life time gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of life time gradients.
  18872. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18873. * @returns the list of life time gradients
  18874. */
  18875. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Gets the current list of color gradients.
  18878. * You must use addColorGradient and removeColorGradient to udpate this list
  18879. * @returns the list of color gradients
  18880. */
  18881. getColorGradients(): Nullable<Array<ColorGradient>>;
  18882. /**
  18883. * Adds a new ramp gradient used to remap particle colors
  18884. * @param gradient defines the gradient to use (between 0 and 1)
  18885. * @param color defines the color to affect to the specified gradient
  18886. * @returns the current particle system
  18887. */
  18888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18889. /**
  18890. * Gets the current list of ramp gradients.
  18891. * You must use addRampGradient and removeRampGradient to udpate this list
  18892. * @returns the list of ramp gradients
  18893. */
  18894. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18895. /** Gets or sets a boolean indicating that ramp gradients must be used
  18896. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18897. */
  18898. useRampGradients: boolean;
  18899. /**
  18900. * Adds a new color remap gradient
  18901. * @param gradient defines the gradient to use (between 0 and 1)
  18902. * @param min defines the color remap minimal range
  18903. * @param max defines the color remap maximal range
  18904. * @returns the current particle system
  18905. */
  18906. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18907. /**
  18908. * Gets the current list of color remap gradients.
  18909. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18910. * @returns the list of color remap gradients
  18911. */
  18912. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18913. /**
  18914. * Adds a new alpha remap gradient
  18915. * @param gradient defines the gradient to use (between 0 and 1)
  18916. * @param min defines the alpha remap minimal range
  18917. * @param max defines the alpha remap maximal range
  18918. * @returns the current particle system
  18919. */
  18920. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18921. /**
  18922. * Gets the current list of alpha remap gradients.
  18923. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18924. * @returns the list of alpha remap gradients
  18925. */
  18926. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18927. /**
  18928. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18931. * @returns the emitter
  18932. */
  18933. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18934. /**
  18935. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18936. * @param radius The radius of the hemisphere to emit from
  18937. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18938. * @returns the emitter
  18939. */
  18940. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18941. /**
  18942. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18943. * @param radius The radius of the sphere to emit from
  18944. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18945. * @returns the emitter
  18946. */
  18947. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18948. /**
  18949. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18950. * @param radius The radius of the sphere to emit from
  18951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18953. * @returns the emitter
  18954. */
  18955. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18956. /**
  18957. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18958. * @param radius The radius of the emission cylinder
  18959. * @param height The height of the emission cylinder
  18960. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18961. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18962. * @returns the emitter
  18963. */
  18964. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18965. /**
  18966. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18967. * @param radius The radius of the cylinder to emit from
  18968. * @param height The height of the emission cylinder
  18969. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18970. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18971. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18972. * @returns the emitter
  18973. */
  18974. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18975. /**
  18976. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18977. * @param radius The radius of the cone to emit from
  18978. * @param angle The base angle of the cone
  18979. * @returns the emitter
  18980. */
  18981. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18982. /**
  18983. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18986. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18987. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18988. * @returns the emitter
  18989. */
  18990. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18991. /**
  18992. * Get hosting scene
  18993. * @returns the scene
  18994. */
  18995. getScene(): Scene;
  18996. }
  18997. }
  18998. declare module "babylonjs/Meshes/instancedMesh" {
  18999. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19000. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19001. import { Camera } from "babylonjs/Cameras/camera";
  19002. import { Node } from "babylonjs/node";
  19003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19004. import { Mesh } from "babylonjs/Meshes/mesh";
  19005. import { Material } from "babylonjs/Materials/material";
  19006. import { Skeleton } from "babylonjs/Bones/skeleton";
  19007. import { Light } from "babylonjs/Lights/light";
  19008. /**
  19009. * Creates an instance based on a source mesh.
  19010. */
  19011. export class InstancedMesh extends AbstractMesh {
  19012. private _sourceMesh;
  19013. private _currentLOD;
  19014. /** @hidden */
  19015. _indexInSourceMeshInstanceArray: number;
  19016. constructor(name: string, source: Mesh);
  19017. /**
  19018. * Returns the string "InstancedMesh".
  19019. */
  19020. getClassName(): string;
  19021. /** Gets the list of lights affecting that mesh */
  19022. readonly lightSources: Light[];
  19023. _resyncLightSources(): void;
  19024. _resyncLighSource(light: Light): void;
  19025. _removeLightSource(light: Light): void;
  19026. /**
  19027. * If the source mesh receives shadows
  19028. */
  19029. readonly receiveShadows: boolean;
  19030. /**
  19031. * The material of the source mesh
  19032. */
  19033. readonly material: Nullable<Material>;
  19034. /**
  19035. * Visibility of the source mesh
  19036. */
  19037. readonly visibility: number;
  19038. /**
  19039. * Skeleton of the source mesh
  19040. */
  19041. readonly skeleton: Nullable<Skeleton>;
  19042. /**
  19043. * Rendering ground id of the source mesh
  19044. */
  19045. renderingGroupId: number;
  19046. /**
  19047. * Returns the total number of vertices (integer).
  19048. */
  19049. getTotalVertices(): number;
  19050. /**
  19051. * Returns a positive integer : the total number of indices in this mesh geometry.
  19052. * @returns the numner of indices or zero if the mesh has no geometry.
  19053. */
  19054. getTotalIndices(): number;
  19055. /**
  19056. * The source mesh of the instance
  19057. */
  19058. readonly sourceMesh: Mesh;
  19059. /**
  19060. * Is this node ready to be used/rendered
  19061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19062. * @return {boolean} is it ready
  19063. */
  19064. isReady(completeCheck?: boolean): boolean;
  19065. /**
  19066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19067. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19068. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19069. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19070. */
  19071. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19072. /**
  19073. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19074. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19075. * The `data` are either a numeric array either a Float32Array.
  19076. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19077. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19078. * Note that a new underlying VertexBuffer object is created each call.
  19079. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19080. *
  19081. * Possible `kind` values :
  19082. * - VertexBuffer.PositionKind
  19083. * - VertexBuffer.UVKind
  19084. * - VertexBuffer.UV2Kind
  19085. * - VertexBuffer.UV3Kind
  19086. * - VertexBuffer.UV4Kind
  19087. * - VertexBuffer.UV5Kind
  19088. * - VertexBuffer.UV6Kind
  19089. * - VertexBuffer.ColorKind
  19090. * - VertexBuffer.MatricesIndicesKind
  19091. * - VertexBuffer.MatricesIndicesExtraKind
  19092. * - VertexBuffer.MatricesWeightsKind
  19093. * - VertexBuffer.MatricesWeightsExtraKind
  19094. *
  19095. * Returns the Mesh.
  19096. */
  19097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19098. /**
  19099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19100. * If the mesh has no geometry, it is simply returned as it is.
  19101. * The `data` are either a numeric array either a Float32Array.
  19102. * No new underlying VertexBuffer object is created.
  19103. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19104. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19105. *
  19106. * Possible `kind` values :
  19107. * - VertexBuffer.PositionKind
  19108. * - VertexBuffer.UVKind
  19109. * - VertexBuffer.UV2Kind
  19110. * - VertexBuffer.UV3Kind
  19111. * - VertexBuffer.UV4Kind
  19112. * - VertexBuffer.UV5Kind
  19113. * - VertexBuffer.UV6Kind
  19114. * - VertexBuffer.ColorKind
  19115. * - VertexBuffer.MatricesIndicesKind
  19116. * - VertexBuffer.MatricesIndicesExtraKind
  19117. * - VertexBuffer.MatricesWeightsKind
  19118. * - VertexBuffer.MatricesWeightsExtraKind
  19119. *
  19120. * Returns the Mesh.
  19121. */
  19122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19123. /**
  19124. * Sets the mesh indices.
  19125. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19127. * This method creates a new index buffer each call.
  19128. * Returns the Mesh.
  19129. */
  19130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19131. /**
  19132. * Boolean : True if the mesh owns the requested kind of data.
  19133. */
  19134. isVerticesDataPresent(kind: string): boolean;
  19135. /**
  19136. * Returns an array of indices (IndicesArray).
  19137. */
  19138. getIndices(): Nullable<IndicesArray>;
  19139. readonly _positions: Nullable<Vector3[]>;
  19140. /**
  19141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19142. * This means the mesh underlying bounding box and sphere are recomputed.
  19143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19144. * @returns the current mesh
  19145. */
  19146. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19147. /** @hidden */
  19148. _preActivate(): InstancedMesh;
  19149. /** @hidden */
  19150. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19151. /** @hidden */
  19152. _postActivate(): void;
  19153. getWorldMatrix(): Matrix;
  19154. readonly isAnInstance: boolean;
  19155. /**
  19156. * Returns the current associated LOD AbstractMesh.
  19157. */
  19158. getLOD(camera: Camera): AbstractMesh;
  19159. /** @hidden */
  19160. _syncSubMeshes(): InstancedMesh;
  19161. /** @hidden */
  19162. _generatePointsArray(): boolean;
  19163. /**
  19164. * Creates a new InstancedMesh from the current mesh.
  19165. * - name (string) : the cloned mesh name
  19166. * - newParent (optional Node) : the optional Node to parent the clone to.
  19167. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19168. *
  19169. * Returns the clone.
  19170. */
  19171. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19172. /**
  19173. * Disposes the InstancedMesh.
  19174. * Returns nothing.
  19175. */
  19176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19177. }
  19178. }
  19179. declare module "babylonjs/Materials/shaderMaterial" {
  19180. import { Scene } from "babylonjs/scene";
  19181. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19183. import { Mesh } from "babylonjs/Meshes/mesh";
  19184. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19186. import { Texture } from "babylonjs/Materials/Textures/texture";
  19187. import { Material } from "babylonjs/Materials/material";
  19188. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19189. /**
  19190. * Defines the options associated with the creation of a shader material.
  19191. */
  19192. export interface IShaderMaterialOptions {
  19193. /**
  19194. * Does the material work in alpha blend mode
  19195. */
  19196. needAlphaBlending: boolean;
  19197. /**
  19198. * Does the material work in alpha test mode
  19199. */
  19200. needAlphaTesting: boolean;
  19201. /**
  19202. * The list of attribute names used in the shader
  19203. */
  19204. attributes: string[];
  19205. /**
  19206. * The list of unifrom names used in the shader
  19207. */
  19208. uniforms: string[];
  19209. /**
  19210. * The list of UBO names used in the shader
  19211. */
  19212. uniformBuffers: string[];
  19213. /**
  19214. * The list of sampler names used in the shader
  19215. */
  19216. samplers: string[];
  19217. /**
  19218. * The list of defines used in the shader
  19219. */
  19220. defines: string[];
  19221. }
  19222. /**
  19223. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19224. *
  19225. * This returned material effects how the mesh will look based on the code in the shaders.
  19226. *
  19227. * @see http://doc.babylonjs.com/how_to/shader_material
  19228. */
  19229. export class ShaderMaterial extends Material {
  19230. private _shaderPath;
  19231. private _options;
  19232. private _textures;
  19233. private _textureArrays;
  19234. private _floats;
  19235. private _ints;
  19236. private _floatsArrays;
  19237. private _colors3;
  19238. private _colors3Arrays;
  19239. private _colors4;
  19240. private _colors4Arrays;
  19241. private _vectors2;
  19242. private _vectors3;
  19243. private _vectors4;
  19244. private _matrices;
  19245. private _matrices3x3;
  19246. private _matrices2x2;
  19247. private _vectors2Arrays;
  19248. private _vectors3Arrays;
  19249. private _vectors4Arrays;
  19250. private _cachedWorldViewMatrix;
  19251. private _cachedWorldViewProjectionMatrix;
  19252. private _renderId;
  19253. /**
  19254. * Instantiate a new shader material.
  19255. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19256. * This returned material effects how the mesh will look based on the code in the shaders.
  19257. * @see http://doc.babylonjs.com/how_to/shader_material
  19258. * @param name Define the name of the material in the scene
  19259. * @param scene Define the scene the material belongs to
  19260. * @param shaderPath Defines the route to the shader code in one of three ways:
  19261. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19262. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19263. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19264. * @param options Define the options used to create the shader
  19265. */
  19266. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19267. /**
  19268. * Gets the options used to compile the shader.
  19269. * They can be modified to trigger a new compilation
  19270. */
  19271. readonly options: IShaderMaterialOptions;
  19272. /**
  19273. * Gets the current class name of the material e.g. "ShaderMaterial"
  19274. * Mainly use in serialization.
  19275. * @returns the class name
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * Specifies if the material will require alpha blending
  19280. * @returns a boolean specifying if alpha blending is needed
  19281. */
  19282. needAlphaBlending(): boolean;
  19283. /**
  19284. * Specifies if this material should be rendered in alpha test mode
  19285. * @returns a boolean specifying if an alpha test is needed.
  19286. */
  19287. needAlphaTesting(): boolean;
  19288. private _checkUniform;
  19289. /**
  19290. * Set a texture in the shader.
  19291. * @param name Define the name of the uniform samplers as defined in the shader
  19292. * @param texture Define the texture to bind to this sampler
  19293. * @return the material itself allowing "fluent" like uniform updates
  19294. */
  19295. setTexture(name: string, texture: Texture): ShaderMaterial;
  19296. /**
  19297. * Set a texture array in the shader.
  19298. * @param name Define the name of the uniform sampler array as defined in the shader
  19299. * @param textures Define the list of textures to bind to this sampler
  19300. * @return the material itself allowing "fluent" like uniform updates
  19301. */
  19302. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19303. /**
  19304. * Set a float in the shader.
  19305. * @param name Define the name of the uniform as defined in the shader
  19306. * @param value Define the value to give to the uniform
  19307. * @return the material itself allowing "fluent" like uniform updates
  19308. */
  19309. setFloat(name: string, value: number): ShaderMaterial;
  19310. /**
  19311. * Set a int in the shader.
  19312. * @param name Define the name of the uniform as defined in the shader
  19313. * @param value Define the value to give to the uniform
  19314. * @return the material itself allowing "fluent" like uniform updates
  19315. */
  19316. setInt(name: string, value: number): ShaderMaterial;
  19317. /**
  19318. * Set an array of floats in the shader.
  19319. * @param name Define the name of the uniform as defined in the shader
  19320. * @param value Define the value to give to the uniform
  19321. * @return the material itself allowing "fluent" like uniform updates
  19322. */
  19323. setFloats(name: string, value: number[]): ShaderMaterial;
  19324. /**
  19325. * Set a vec3 in the shader from a Color3.
  19326. * @param name Define the name of the uniform as defined in the shader
  19327. * @param value Define the value to give to the uniform
  19328. * @return the material itself allowing "fluent" like uniform updates
  19329. */
  19330. setColor3(name: string, value: Color3): ShaderMaterial;
  19331. /**
  19332. * Set a vec3 array in the shader from a Color3 array.
  19333. * @param name Define the name of the uniform as defined in the shader
  19334. * @param value Define the value to give to the uniform
  19335. * @return the material itself allowing "fluent" like uniform updates
  19336. */
  19337. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19338. /**
  19339. * Set a vec4 in the shader from a Color4.
  19340. * @param name Define the name of the uniform as defined in the shader
  19341. * @param value Define the value to give to the uniform
  19342. * @return the material itself allowing "fluent" like uniform updates
  19343. */
  19344. setColor4(name: string, value: Color4): ShaderMaterial;
  19345. /**
  19346. * Set a vec4 array in the shader from a Color4 array.
  19347. * @param name Define the name of the uniform as defined in the shader
  19348. * @param value Define the value to give to the uniform
  19349. * @return the material itself allowing "fluent" like uniform updates
  19350. */
  19351. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19352. /**
  19353. * Set a vec2 in the shader from a Vector2.
  19354. * @param name Define the name of the uniform as defined in the shader
  19355. * @param value Define the value to give to the uniform
  19356. * @return the material itself allowing "fluent" like uniform updates
  19357. */
  19358. setVector2(name: string, value: Vector2): ShaderMaterial;
  19359. /**
  19360. * Set a vec3 in the shader from a Vector3.
  19361. * @param name Define the name of the uniform as defined in the shader
  19362. * @param value Define the value to give to the uniform
  19363. * @return the material itself allowing "fluent" like uniform updates
  19364. */
  19365. setVector3(name: string, value: Vector3): ShaderMaterial;
  19366. /**
  19367. * Set a vec4 in the shader from a Vector4.
  19368. * @param name Define the name of the uniform as defined in the shader
  19369. * @param value Define the value to give to the uniform
  19370. * @return the material itself allowing "fluent" like uniform updates
  19371. */
  19372. setVector4(name: string, value: Vector4): ShaderMaterial;
  19373. /**
  19374. * Set a mat4 in the shader from a Matrix.
  19375. * @param name Define the name of the uniform as defined in the shader
  19376. * @param value Define the value to give to the uniform
  19377. * @return the material itself allowing "fluent" like uniform updates
  19378. */
  19379. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19380. /**
  19381. * Set a mat3 in the shader from a Float32Array.
  19382. * @param name Define the name of the uniform as defined in the shader
  19383. * @param value Define the value to give to the uniform
  19384. * @return the material itself allowing "fluent" like uniform updates
  19385. */
  19386. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19387. /**
  19388. * Set a mat2 in the shader from a Float32Array.
  19389. * @param name Define the name of the uniform as defined in the shader
  19390. * @param value Define the value to give to the uniform
  19391. * @return the material itself allowing "fluent" like uniform updates
  19392. */
  19393. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19394. /**
  19395. * Set a vec2 array in the shader from a number array.
  19396. * @param name Define the name of the uniform as defined in the shader
  19397. * @param value Define the value to give to the uniform
  19398. * @return the material itself allowing "fluent" like uniform updates
  19399. */
  19400. setArray2(name: string, value: number[]): ShaderMaterial;
  19401. /**
  19402. * Set a vec3 array in the shader from a number array.
  19403. * @param name Define the name of the uniform as defined in the shader
  19404. * @param value Define the value to give to the uniform
  19405. * @return the material itself allowing "fluent" like uniform updates
  19406. */
  19407. setArray3(name: string, value: number[]): ShaderMaterial;
  19408. /**
  19409. * Set a vec4 array in the shader from a number array.
  19410. * @param name Define the name of the uniform as defined in the shader
  19411. * @param value Define the value to give to the uniform
  19412. * @return the material itself allowing "fluent" like uniform updates
  19413. */
  19414. setArray4(name: string, value: number[]): ShaderMaterial;
  19415. private _checkCache;
  19416. /**
  19417. * Specifies that the submesh is ready to be used
  19418. * @param mesh defines the mesh to check
  19419. * @param subMesh defines which submesh to check
  19420. * @param useInstances specifies that instances should be used
  19421. * @returns a boolean indicating that the submesh is ready or not
  19422. */
  19423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19424. /**
  19425. * Checks if the material is ready to render the requested mesh
  19426. * @param mesh Define the mesh to render
  19427. * @param useInstances Define whether or not the material is used with instances
  19428. * @returns true if ready, otherwise false
  19429. */
  19430. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19431. /**
  19432. * Binds the world matrix to the material
  19433. * @param world defines the world transformation matrix
  19434. */
  19435. bindOnlyWorldMatrix(world: Matrix): void;
  19436. /**
  19437. * Binds the material to the mesh
  19438. * @param world defines the world transformation matrix
  19439. * @param mesh defines the mesh to bind the material to
  19440. */
  19441. bind(world: Matrix, mesh?: Mesh): void;
  19442. /**
  19443. * Gets the active textures from the material
  19444. * @returns an array of textures
  19445. */
  19446. getActiveTextures(): BaseTexture[];
  19447. /**
  19448. * Specifies if the material uses a texture
  19449. * @param texture defines the texture to check against the material
  19450. * @returns a boolean specifying if the material uses the texture
  19451. */
  19452. hasTexture(texture: BaseTexture): boolean;
  19453. /**
  19454. * Makes a duplicate of the material, and gives it a new name
  19455. * @param name defines the new name for the duplicated material
  19456. * @returns the cloned material
  19457. */
  19458. clone(name: string): ShaderMaterial;
  19459. /**
  19460. * Disposes the material
  19461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19464. */
  19465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19466. /**
  19467. * Serializes this material in a JSON representation
  19468. * @returns the serialized material object
  19469. */
  19470. serialize(): any;
  19471. /**
  19472. * Creates a shader material from parsed shader material data
  19473. * @param source defines the JSON represnetation of the material
  19474. * @param scene defines the hosting scene
  19475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19476. * @returns a new material
  19477. */
  19478. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19479. }
  19480. }
  19481. declare module "babylonjs/Shaders/color.fragment" {
  19482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19484. /** @hidden */
  19485. export var colorPixelShader: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module "babylonjs/Shaders/color.vertex" {
  19491. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19492. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19493. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19494. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19497. /** @hidden */
  19498. export var colorVertexShader: {
  19499. name: string;
  19500. shader: string;
  19501. };
  19502. }
  19503. declare module "babylonjs/Meshes/linesMesh" {
  19504. import { Nullable } from "babylonjs/types";
  19505. import { Scene } from "babylonjs/scene";
  19506. import { Color3 } from "babylonjs/Maths/math.color";
  19507. import { Node } from "babylonjs/node";
  19508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19509. import { Mesh } from "babylonjs/Meshes/mesh";
  19510. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19511. import { Effect } from "babylonjs/Materials/effect";
  19512. import { Material } from "babylonjs/Materials/material";
  19513. import "babylonjs/Shaders/color.fragment";
  19514. import "babylonjs/Shaders/color.vertex";
  19515. /**
  19516. * Line mesh
  19517. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19518. */
  19519. export class LinesMesh extends Mesh {
  19520. /**
  19521. * If vertex color should be applied to the mesh
  19522. */
  19523. readonly useVertexColor?: boolean | undefined;
  19524. /**
  19525. * If vertex alpha should be applied to the mesh
  19526. */
  19527. readonly useVertexAlpha?: boolean | undefined;
  19528. /**
  19529. * Color of the line (Default: White)
  19530. */
  19531. color: Color3;
  19532. /**
  19533. * Alpha of the line (Default: 1)
  19534. */
  19535. alpha: number;
  19536. /**
  19537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19538. * This margin is expressed in world space coordinates, so its value may vary.
  19539. * Default value is 0.1
  19540. */
  19541. intersectionThreshold: number;
  19542. private _colorShader;
  19543. private color4;
  19544. /**
  19545. * Creates a new LinesMesh
  19546. * @param name defines the name
  19547. * @param scene defines the hosting scene
  19548. * @param parent defines the parent mesh if any
  19549. * @param source defines the optional source LinesMesh used to clone data from
  19550. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19551. * When false, achieved by calling a clone(), also passing False.
  19552. * This will make creation of children, recursive.
  19553. * @param useVertexColor defines if this LinesMesh supports vertex color
  19554. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19555. */
  19556. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19557. /**
  19558. * If vertex color should be applied to the mesh
  19559. */
  19560. useVertexColor?: boolean | undefined,
  19561. /**
  19562. * If vertex alpha should be applied to the mesh
  19563. */
  19564. useVertexAlpha?: boolean | undefined);
  19565. private _addClipPlaneDefine;
  19566. private _removeClipPlaneDefine;
  19567. isReady(): boolean;
  19568. /**
  19569. * Returns the string "LineMesh"
  19570. */
  19571. getClassName(): string;
  19572. /**
  19573. * @hidden
  19574. */
  19575. /**
  19576. * @hidden
  19577. */
  19578. material: Material;
  19579. /**
  19580. * @hidden
  19581. */
  19582. readonly checkCollisions: boolean;
  19583. /** @hidden */
  19584. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19585. /** @hidden */
  19586. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19587. /**
  19588. * Disposes of the line mesh
  19589. * @param doNotRecurse If children should be disposed
  19590. */
  19591. dispose(doNotRecurse?: boolean): void;
  19592. /**
  19593. * Returns a new LineMesh object cloned from the current one.
  19594. */
  19595. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19596. /**
  19597. * Creates a new InstancedLinesMesh object from the mesh model.
  19598. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19599. * @param name defines the name of the new instance
  19600. * @returns a new InstancedLinesMesh
  19601. */
  19602. createInstance(name: string): InstancedLinesMesh;
  19603. }
  19604. /**
  19605. * Creates an instance based on a source LinesMesh
  19606. */
  19607. export class InstancedLinesMesh extends InstancedMesh {
  19608. /**
  19609. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19610. * This margin is expressed in world space coordinates, so its value may vary.
  19611. * Initilized with the intersectionThreshold value of the source LinesMesh
  19612. */
  19613. intersectionThreshold: number;
  19614. constructor(name: string, source: LinesMesh);
  19615. /**
  19616. * Returns the string "InstancedLinesMesh".
  19617. */
  19618. getClassName(): string;
  19619. }
  19620. }
  19621. declare module "babylonjs/Shaders/line.fragment" {
  19622. /** @hidden */
  19623. export var linePixelShader: {
  19624. name: string;
  19625. shader: string;
  19626. };
  19627. }
  19628. declare module "babylonjs/Shaders/line.vertex" {
  19629. /** @hidden */
  19630. export var lineVertexShader: {
  19631. name: string;
  19632. shader: string;
  19633. };
  19634. }
  19635. declare module "babylonjs/Rendering/edgesRenderer" {
  19636. import { Nullable } from "babylonjs/types";
  19637. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Vector3 } from "babylonjs/Maths/math.vector";
  19640. import { IDisposable } from "babylonjs/scene";
  19641. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19642. import "babylonjs/Shaders/line.fragment";
  19643. import "babylonjs/Shaders/line.vertex";
  19644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19645. module "babylonjs/Meshes/abstractMesh" {
  19646. interface AbstractMesh {
  19647. /**
  19648. * Gets the edgesRenderer associated with the mesh
  19649. */
  19650. edgesRenderer: Nullable<EdgesRenderer>;
  19651. }
  19652. }
  19653. module "babylonjs/Meshes/linesMesh" {
  19654. interface LinesMesh {
  19655. /**
  19656. * Enables the edge rendering mode on the mesh.
  19657. * This mode makes the mesh edges visible
  19658. * @param epsilon defines the maximal distance between two angles to detect a face
  19659. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19660. * @returns the currentAbstractMesh
  19661. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19662. */
  19663. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19664. }
  19665. }
  19666. module "babylonjs/Meshes/linesMesh" {
  19667. interface InstancedLinesMesh {
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the current InstancedLinesMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19677. }
  19678. }
  19679. /**
  19680. * Defines the minimum contract an Edges renderer should follow.
  19681. */
  19682. export interface IEdgesRenderer extends IDisposable {
  19683. /**
  19684. * Gets or sets a boolean indicating if the edgesRenderer is active
  19685. */
  19686. isEnabled: boolean;
  19687. /**
  19688. * Renders the edges of the attached mesh,
  19689. */
  19690. render(): void;
  19691. /**
  19692. * Checks wether or not the edges renderer is ready to render.
  19693. * @return true if ready, otherwise false.
  19694. */
  19695. isReady(): boolean;
  19696. }
  19697. /**
  19698. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19699. */
  19700. export class EdgesRenderer implements IEdgesRenderer {
  19701. /**
  19702. * Define the size of the edges with an orthographic camera
  19703. */
  19704. edgesWidthScalerForOrthographic: number;
  19705. /**
  19706. * Define the size of the edges with a perspective camera
  19707. */
  19708. edgesWidthScalerForPerspective: number;
  19709. protected _source: AbstractMesh;
  19710. protected _linesPositions: number[];
  19711. protected _linesNormals: number[];
  19712. protected _linesIndices: number[];
  19713. protected _epsilon: number;
  19714. protected _indicesCount: number;
  19715. protected _lineShader: ShaderMaterial;
  19716. protected _ib: DataBuffer;
  19717. protected _buffers: {
  19718. [key: string]: Nullable<VertexBuffer>;
  19719. };
  19720. protected _checkVerticesInsteadOfIndices: boolean;
  19721. private _meshRebuildObserver;
  19722. private _meshDisposeObserver;
  19723. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19724. isEnabled: boolean;
  19725. /**
  19726. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19727. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19728. * @param source Mesh used to create edges
  19729. * @param epsilon sum of angles in adjacency to check for edge
  19730. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19731. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19732. */
  19733. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19734. protected _prepareRessources(): void;
  19735. /** @hidden */
  19736. _rebuild(): void;
  19737. /**
  19738. * Releases the required resources for the edges renderer
  19739. */
  19740. dispose(): void;
  19741. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19742. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19743. /**
  19744. * Checks if the pair of p0 and p1 is en edge
  19745. * @param faceIndex
  19746. * @param edge
  19747. * @param faceNormals
  19748. * @param p0
  19749. * @param p1
  19750. * @private
  19751. */
  19752. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19753. /**
  19754. * push line into the position, normal and index buffer
  19755. * @protected
  19756. */
  19757. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19758. /**
  19759. * Generates lines edges from adjacencjes
  19760. * @private
  19761. */
  19762. _generateEdgesLines(): void;
  19763. /**
  19764. * Checks wether or not the edges renderer is ready to render.
  19765. * @return true if ready, otherwise false.
  19766. */
  19767. isReady(): boolean;
  19768. /**
  19769. * Renders the edges of the attached mesh,
  19770. */
  19771. render(): void;
  19772. }
  19773. /**
  19774. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19775. */
  19776. export class LineEdgesRenderer extends EdgesRenderer {
  19777. /**
  19778. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19779. * @param source LineMesh used to generate edges
  19780. * @param epsilon not important (specified angle for edge detection)
  19781. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19782. */
  19783. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19784. /**
  19785. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19786. */
  19787. _generateEdgesLines(): void;
  19788. }
  19789. }
  19790. declare module "babylonjs/Rendering/renderingGroup" {
  19791. import { SmartArray } from "babylonjs/Misc/smartArray";
  19792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19794. import { Nullable } from "babylonjs/types";
  19795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19796. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19797. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19798. import { Material } from "babylonjs/Materials/material";
  19799. import { Scene } from "babylonjs/scene";
  19800. /**
  19801. * This represents the object necessary to create a rendering group.
  19802. * This is exclusively used and created by the rendering manager.
  19803. * To modify the behavior, you use the available helpers in your scene or meshes.
  19804. * @hidden
  19805. */
  19806. export class RenderingGroup {
  19807. index: number;
  19808. private static _zeroVector;
  19809. private _scene;
  19810. private _opaqueSubMeshes;
  19811. private _transparentSubMeshes;
  19812. private _alphaTestSubMeshes;
  19813. private _depthOnlySubMeshes;
  19814. private _particleSystems;
  19815. private _spriteManagers;
  19816. private _opaqueSortCompareFn;
  19817. private _alphaTestSortCompareFn;
  19818. private _transparentSortCompareFn;
  19819. private _renderOpaque;
  19820. private _renderAlphaTest;
  19821. private _renderTransparent;
  19822. /** @hidden */
  19823. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19824. onBeforeTransparentRendering: () => void;
  19825. /**
  19826. * Set the opaque sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the alpha test sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Set the transparent sort comparison function.
  19837. * If null the sub meshes will be render in the order they were created
  19838. */
  19839. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19840. /**
  19841. * Creates a new rendering group.
  19842. * @param index The rendering group index
  19843. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19844. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19845. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19846. */
  19847. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19848. /**
  19849. * Render all the sub meshes contained in the group.
  19850. * @param customRenderFunction Used to override the default render behaviour of the group.
  19851. * @returns true if rendered some submeshes.
  19852. */
  19853. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderOpaqueSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderAlphaTestSorted;
  19864. /**
  19865. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19866. * @param subMeshes The submeshes to render
  19867. */
  19868. private renderTransparentSorted;
  19869. /**
  19870. * Renders the submeshes in a specified order.
  19871. * @param subMeshes The submeshes to sort before render
  19872. * @param sortCompareFn The comparison function use to sort
  19873. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19874. * @param transparent Specifies to activate blending if true
  19875. */
  19876. private static renderSorted;
  19877. /**
  19878. * Renders the submeshes in the order they were dispatched (no sort applied).
  19879. * @param subMeshes The submeshes to render
  19880. */
  19881. private static renderUnsorted;
  19882. /**
  19883. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19884. * are rendered back to front if in the same alpha index.
  19885. *
  19886. * @param a The first submesh
  19887. * @param b The second submesh
  19888. * @returns The result of the comparison
  19889. */
  19890. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19891. /**
  19892. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19893. * are rendered back to front.
  19894. *
  19895. * @param a The first submesh
  19896. * @param b The second submesh
  19897. * @returns The result of the comparison
  19898. */
  19899. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19900. /**
  19901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19902. * are rendered front to back (prevent overdraw).
  19903. *
  19904. * @param a The first submesh
  19905. * @param b The second submesh
  19906. * @returns The result of the comparison
  19907. */
  19908. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19909. /**
  19910. * Resets the different lists of submeshes to prepare a new frame.
  19911. */
  19912. prepare(): void;
  19913. dispose(): void;
  19914. /**
  19915. * Inserts the submesh in its correct queue depending on its material.
  19916. * @param subMesh The submesh to dispatch
  19917. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19918. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19919. */
  19920. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19921. dispatchSprites(spriteManager: ISpriteManager): void;
  19922. dispatchParticles(particleSystem: IParticleSystem): void;
  19923. private _renderParticles;
  19924. private _renderSprites;
  19925. }
  19926. }
  19927. declare module "babylonjs/Rendering/renderingManager" {
  19928. import { Nullable } from "babylonjs/types";
  19929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19931. import { SmartArray } from "babylonjs/Misc/smartArray";
  19932. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19934. import { Material } from "babylonjs/Materials/material";
  19935. import { Scene } from "babylonjs/scene";
  19936. import { Camera } from "babylonjs/Cameras/camera";
  19937. /**
  19938. * Interface describing the different options available in the rendering manager
  19939. * regarding Auto Clear between groups.
  19940. */
  19941. export interface IRenderingManagerAutoClearSetup {
  19942. /**
  19943. * Defines whether or not autoclear is enable.
  19944. */
  19945. autoClear: boolean;
  19946. /**
  19947. * Defines whether or not to autoclear the depth buffer.
  19948. */
  19949. depth: boolean;
  19950. /**
  19951. * Defines whether or not to autoclear the stencil buffer.
  19952. */
  19953. stencil: boolean;
  19954. }
  19955. /**
  19956. * This class is used by the onRenderingGroupObservable
  19957. */
  19958. export class RenderingGroupInfo {
  19959. /**
  19960. * The Scene that being rendered
  19961. */
  19962. scene: Scene;
  19963. /**
  19964. * The camera currently used for the rendering pass
  19965. */
  19966. camera: Nullable<Camera>;
  19967. /**
  19968. * The ID of the renderingGroup being processed
  19969. */
  19970. renderingGroupId: number;
  19971. }
  19972. /**
  19973. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19974. * It is enable to manage the different groups as well as the different necessary sort functions.
  19975. * This should not be used directly aside of the few static configurations
  19976. */
  19977. export class RenderingManager {
  19978. /**
  19979. * The max id used for rendering groups (not included)
  19980. */
  19981. static MAX_RENDERINGGROUPS: number;
  19982. /**
  19983. * The min id used for rendering groups (included)
  19984. */
  19985. static MIN_RENDERINGGROUPS: number;
  19986. /**
  19987. * Used to globally prevent autoclearing scenes.
  19988. */
  19989. static AUTOCLEAR: boolean;
  19990. /**
  19991. * @hidden
  19992. */
  19993. _useSceneAutoClearSetup: boolean;
  19994. private _scene;
  19995. private _renderingGroups;
  19996. private _depthStencilBufferAlreadyCleaned;
  19997. private _autoClearDepthStencil;
  19998. private _customOpaqueSortCompareFn;
  19999. private _customAlphaTestSortCompareFn;
  20000. private _customTransparentSortCompareFn;
  20001. private _renderingGroupInfo;
  20002. /**
  20003. * Instantiates a new rendering group for a particular scene
  20004. * @param scene Defines the scene the groups belongs to
  20005. */
  20006. constructor(scene: Scene);
  20007. private _clearDepthStencilBuffer;
  20008. /**
  20009. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20010. * @hidden
  20011. */
  20012. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20013. /**
  20014. * Resets the different information of the group to prepare a new frame
  20015. * @hidden
  20016. */
  20017. reset(): void;
  20018. /**
  20019. * Dispose and release the group and its associated resources.
  20020. * @hidden
  20021. */
  20022. dispose(): void;
  20023. /**
  20024. * Clear the info related to rendering groups preventing retention points during dispose.
  20025. */
  20026. freeRenderingGroups(): void;
  20027. private _prepareRenderingGroup;
  20028. /**
  20029. * Add a sprite manager to the rendering manager in order to render it this frame.
  20030. * @param spriteManager Define the sprite manager to render
  20031. */
  20032. dispatchSprites(spriteManager: ISpriteManager): void;
  20033. /**
  20034. * Add a particle system to the rendering manager in order to render it this frame.
  20035. * @param particleSystem Define the particle system to render
  20036. */
  20037. dispatchParticles(particleSystem: IParticleSystem): void;
  20038. /**
  20039. * Add a submesh to the manager in order to render it this frame
  20040. * @param subMesh The submesh to dispatch
  20041. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20042. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20043. */
  20044. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20045. /**
  20046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20047. * This allowed control for front to back rendering or reversly depending of the special needs.
  20048. *
  20049. * @param renderingGroupId The rendering group id corresponding to its index
  20050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20053. */
  20054. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20055. /**
  20056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20057. *
  20058. * @param renderingGroupId The rendering group id corresponding to its index
  20059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20060. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20061. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20062. */
  20063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20064. /**
  20065. * Gets the current auto clear configuration for one rendering group of the rendering
  20066. * manager.
  20067. * @param index the rendering group index to get the information for
  20068. * @returns The auto clear setup for the requested rendering group
  20069. */
  20070. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20071. }
  20072. }
  20073. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20074. import { Observable } from "babylonjs/Misc/observable";
  20075. import { SmartArray } from "babylonjs/Misc/smartArray";
  20076. import { Nullable } from "babylonjs/types";
  20077. import { Camera } from "babylonjs/Cameras/camera";
  20078. import { Scene } from "babylonjs/scene";
  20079. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20080. import { Color4 } from "babylonjs/Maths/math.color";
  20081. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20085. import { Texture } from "babylonjs/Materials/Textures/texture";
  20086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20087. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20088. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20089. import { Engine } from "babylonjs/Engines/engine";
  20090. /**
  20091. * This Helps creating a texture that will be created from a camera in your scene.
  20092. * It is basically a dynamic texture that could be used to create special effects for instance.
  20093. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20094. */
  20095. export class RenderTargetTexture extends Texture {
  20096. isCube: boolean;
  20097. /**
  20098. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20099. */
  20100. static readonly REFRESHRATE_RENDER_ONCE: number;
  20101. /**
  20102. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20103. */
  20104. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20105. /**
  20106. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20107. * the central point of your effect and can save a lot of performances.
  20108. */
  20109. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20110. /**
  20111. * Use this predicate to dynamically define the list of mesh you want to render.
  20112. * If set, the renderList property will be overwritten.
  20113. */
  20114. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20115. private _renderList;
  20116. /**
  20117. * Use this list to define the list of mesh you want to render.
  20118. */
  20119. renderList: Nullable<Array<AbstractMesh>>;
  20120. private _hookArray;
  20121. /**
  20122. * Define if particles should be rendered in your texture.
  20123. */
  20124. renderParticles: boolean;
  20125. /**
  20126. * Define if sprites should be rendered in your texture.
  20127. */
  20128. renderSprites: boolean;
  20129. /**
  20130. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20131. */
  20132. coordinatesMode: number;
  20133. /**
  20134. * Define the camera used to render the texture.
  20135. */
  20136. activeCamera: Nullable<Camera>;
  20137. /**
  20138. * Override the render function of the texture with your own one.
  20139. */
  20140. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20141. /**
  20142. * Define if camera post processes should be use while rendering the texture.
  20143. */
  20144. useCameraPostProcesses: boolean;
  20145. /**
  20146. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20147. */
  20148. ignoreCameraViewport: boolean;
  20149. private _postProcessManager;
  20150. private _postProcesses;
  20151. private _resizeObserver;
  20152. /**
  20153. * An event triggered when the texture is unbind.
  20154. */
  20155. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20156. /**
  20157. * An event triggered when the texture is unbind.
  20158. */
  20159. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20160. private _onAfterUnbindObserver;
  20161. /**
  20162. * Set a after unbind callback in the texture.
  20163. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20164. */
  20165. onAfterUnbind: () => void;
  20166. /**
  20167. * An event triggered before rendering the texture
  20168. */
  20169. onBeforeRenderObservable: Observable<number>;
  20170. private _onBeforeRenderObserver;
  20171. /**
  20172. * Set a before render callback in the texture.
  20173. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20174. */
  20175. onBeforeRender: (faceIndex: number) => void;
  20176. /**
  20177. * An event triggered after rendering the texture
  20178. */
  20179. onAfterRenderObservable: Observable<number>;
  20180. private _onAfterRenderObserver;
  20181. /**
  20182. * Set a after render callback in the texture.
  20183. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20184. */
  20185. onAfterRender: (faceIndex: number) => void;
  20186. /**
  20187. * An event triggered after the texture clear
  20188. */
  20189. onClearObservable: Observable<Engine>;
  20190. private _onClearObserver;
  20191. /**
  20192. * Set a clear callback in the texture.
  20193. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20194. */
  20195. onClear: (Engine: Engine) => void;
  20196. /**
  20197. * An event triggered when the texture is resized.
  20198. */
  20199. onResizeObservable: Observable<RenderTargetTexture>;
  20200. /**
  20201. * Define the clear color of the Render Target if it should be different from the scene.
  20202. */
  20203. clearColor: Color4;
  20204. protected _size: number | {
  20205. width: number;
  20206. height: number;
  20207. };
  20208. protected _initialSizeParameter: number | {
  20209. width: number;
  20210. height: number;
  20211. } | {
  20212. ratio: number;
  20213. };
  20214. protected _sizeRatio: Nullable<number>;
  20215. /** @hidden */
  20216. _generateMipMaps: boolean;
  20217. protected _renderingManager: RenderingManager;
  20218. /** @hidden */
  20219. _waitingRenderList: string[];
  20220. protected _doNotChangeAspectRatio: boolean;
  20221. protected _currentRefreshId: number;
  20222. protected _refreshRate: number;
  20223. protected _textureMatrix: Matrix;
  20224. protected _samples: number;
  20225. protected _renderTargetOptions: RenderTargetCreationOptions;
  20226. /**
  20227. * Gets render target creation options that were used.
  20228. */
  20229. readonly renderTargetOptions: RenderTargetCreationOptions;
  20230. protected _engine: Engine;
  20231. protected _onRatioRescale(): void;
  20232. /**
  20233. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20234. * It must define where the camera used to render the texture is set
  20235. */
  20236. boundingBoxPosition: Vector3;
  20237. private _boundingBoxSize;
  20238. /**
  20239. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20240. * When defined, the cubemap will switch to local mode
  20241. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20242. * @example https://www.babylonjs-playground.com/#RNASML
  20243. */
  20244. boundingBoxSize: Vector3;
  20245. /**
  20246. * In case the RTT has been created with a depth texture, get the associated
  20247. * depth texture.
  20248. * Otherwise, return null.
  20249. */
  20250. depthStencilTexture: Nullable<InternalTexture>;
  20251. /**
  20252. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20253. * or used a shadow, depth texture...
  20254. * @param name The friendly name of the texture
  20255. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20256. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20257. * @param generateMipMaps True if mip maps need to be generated after render.
  20258. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20259. * @param type The type of the buffer in the RTT (int, half float, float...)
  20260. * @param isCube True if a cube texture needs to be created
  20261. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20262. * @param generateDepthBuffer True to generate a depth buffer
  20263. * @param generateStencilBuffer True to generate a stencil buffer
  20264. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20265. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20266. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20267. */
  20268. constructor(name: string, size: number | {
  20269. width: number;
  20270. height: number;
  20271. } | {
  20272. ratio: number;
  20273. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20274. /**
  20275. * Creates a depth stencil texture.
  20276. * This is only available in WebGL 2 or with the depth texture extension available.
  20277. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20278. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20279. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20280. */
  20281. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20282. private _processSizeParameter;
  20283. /**
  20284. * Define the number of samples to use in case of MSAA.
  20285. * It defaults to one meaning no MSAA has been enabled.
  20286. */
  20287. samples: number;
  20288. /**
  20289. * Resets the refresh counter of the texture and start bak from scratch.
  20290. * Could be useful to regenerate the texture if it is setup to render only once.
  20291. */
  20292. resetRefreshCounter(): void;
  20293. /**
  20294. * Define the refresh rate of the texture or the rendering frequency.
  20295. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20296. */
  20297. refreshRate: number;
  20298. /**
  20299. * Adds a post process to the render target rendering passes.
  20300. * @param postProcess define the post process to add
  20301. */
  20302. addPostProcess(postProcess: PostProcess): void;
  20303. /**
  20304. * Clear all the post processes attached to the render target
  20305. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20306. */
  20307. clearPostProcesses(dispose?: boolean): void;
  20308. /**
  20309. * Remove one of the post process from the list of attached post processes to the texture
  20310. * @param postProcess define the post process to remove from the list
  20311. */
  20312. removePostProcess(postProcess: PostProcess): void;
  20313. /** @hidden */
  20314. _shouldRender(): boolean;
  20315. /**
  20316. * Gets the actual render size of the texture.
  20317. * @returns the width of the render size
  20318. */
  20319. getRenderSize(): number;
  20320. /**
  20321. * Gets the actual render width of the texture.
  20322. * @returns the width of the render size
  20323. */
  20324. getRenderWidth(): number;
  20325. /**
  20326. * Gets the actual render height of the texture.
  20327. * @returns the height of the render size
  20328. */
  20329. getRenderHeight(): number;
  20330. /**
  20331. * Get if the texture can be rescaled or not.
  20332. */
  20333. readonly canRescale: boolean;
  20334. /**
  20335. * Resize the texture using a ratio.
  20336. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20337. */
  20338. scale(ratio: number): void;
  20339. /**
  20340. * Get the texture reflection matrix used to rotate/transform the reflection.
  20341. * @returns the reflection matrix
  20342. */
  20343. getReflectionTextureMatrix(): Matrix;
  20344. /**
  20345. * Resize the texture to a new desired size.
  20346. * Be carrefull as it will recreate all the data in the new texture.
  20347. * @param size Define the new size. It can be:
  20348. * - a number for squared texture,
  20349. * - an object containing { width: number, height: number }
  20350. * - or an object containing a ratio { ratio: number }
  20351. */
  20352. resize(size: number | {
  20353. width: number;
  20354. height: number;
  20355. } | {
  20356. ratio: number;
  20357. }): void;
  20358. /**
  20359. * Renders all the objects from the render list into the texture.
  20360. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20361. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20362. */
  20363. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20364. private _bestReflectionRenderTargetDimension;
  20365. /**
  20366. * @hidden
  20367. * @param faceIndex face index to bind to if this is a cubetexture
  20368. */
  20369. _bindFrameBuffer(faceIndex?: number): void;
  20370. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20371. private renderToTarget;
  20372. /**
  20373. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20374. * This allowed control for front to back rendering or reversly depending of the special needs.
  20375. *
  20376. * @param renderingGroupId The rendering group id corresponding to its index
  20377. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20378. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20379. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20380. */
  20381. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20382. /**
  20383. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20384. *
  20385. * @param renderingGroupId The rendering group id corresponding to its index
  20386. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20387. */
  20388. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20389. /**
  20390. * Clones the texture.
  20391. * @returns the cloned texture
  20392. */
  20393. clone(): RenderTargetTexture;
  20394. /**
  20395. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20396. * @returns The JSON representation of the texture
  20397. */
  20398. serialize(): any;
  20399. /**
  20400. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20401. */
  20402. disposeFramebufferObjects(): void;
  20403. /**
  20404. * Dispose the texture and release its associated resources.
  20405. */
  20406. dispose(): void;
  20407. /** @hidden */
  20408. _rebuild(): void;
  20409. /**
  20410. * Clear the info related to rendering groups preventing retention point in material dispose.
  20411. */
  20412. freeRenderingGroups(): void;
  20413. /**
  20414. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20415. * @returns the view count
  20416. */
  20417. getViewCount(): number;
  20418. }
  20419. }
  20420. declare module "babylonjs/Materials/material" {
  20421. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20422. import { SmartArray } from "babylonjs/Misc/smartArray";
  20423. import { Observable } from "babylonjs/Misc/observable";
  20424. import { Nullable } from "babylonjs/types";
  20425. import { Scene } from "babylonjs/scene";
  20426. import { Matrix } from "babylonjs/Maths/math.vector";
  20427. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20430. import { Effect } from "babylonjs/Materials/effect";
  20431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20433. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20434. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20435. import { Mesh } from "babylonjs/Meshes/mesh";
  20436. import { Animation } from "babylonjs/Animations/animation";
  20437. /**
  20438. * Base class for the main features of a material in Babylon.js
  20439. */
  20440. export class Material implements IAnimatable {
  20441. /**
  20442. * Returns the triangle fill mode
  20443. */
  20444. static readonly TriangleFillMode: number;
  20445. /**
  20446. * Returns the wireframe mode
  20447. */
  20448. static readonly WireFrameFillMode: number;
  20449. /**
  20450. * Returns the point fill mode
  20451. */
  20452. static readonly PointFillMode: number;
  20453. /**
  20454. * Returns the point list draw mode
  20455. */
  20456. static readonly PointListDrawMode: number;
  20457. /**
  20458. * Returns the line list draw mode
  20459. */
  20460. static readonly LineListDrawMode: number;
  20461. /**
  20462. * Returns the line loop draw mode
  20463. */
  20464. static readonly LineLoopDrawMode: number;
  20465. /**
  20466. * Returns the line strip draw mode
  20467. */
  20468. static readonly LineStripDrawMode: number;
  20469. /**
  20470. * Returns the triangle strip draw mode
  20471. */
  20472. static readonly TriangleStripDrawMode: number;
  20473. /**
  20474. * Returns the triangle fan draw mode
  20475. */
  20476. static readonly TriangleFanDrawMode: number;
  20477. /**
  20478. * Stores the clock-wise side orientation
  20479. */
  20480. static readonly ClockWiseSideOrientation: number;
  20481. /**
  20482. * Stores the counter clock-wise side orientation
  20483. */
  20484. static readonly CounterClockWiseSideOrientation: number;
  20485. /**
  20486. * The dirty texture flag value
  20487. */
  20488. static readonly TextureDirtyFlag: number;
  20489. /**
  20490. * The dirty light flag value
  20491. */
  20492. static readonly LightDirtyFlag: number;
  20493. /**
  20494. * The dirty fresnel flag value
  20495. */
  20496. static readonly FresnelDirtyFlag: number;
  20497. /**
  20498. * The dirty attribute flag value
  20499. */
  20500. static readonly AttributesDirtyFlag: number;
  20501. /**
  20502. * The dirty misc flag value
  20503. */
  20504. static readonly MiscDirtyFlag: number;
  20505. /**
  20506. * The all dirty flag value
  20507. */
  20508. static readonly AllDirtyFlag: number;
  20509. /**
  20510. * The ID of the material
  20511. */
  20512. id: string;
  20513. /**
  20514. * Gets or sets the unique id of the material
  20515. */
  20516. uniqueId: number;
  20517. /**
  20518. * The name of the material
  20519. */
  20520. name: string;
  20521. /**
  20522. * Gets or sets user defined metadata
  20523. */
  20524. metadata: any;
  20525. /**
  20526. * For internal use only. Please do not use.
  20527. */
  20528. reservedDataStore: any;
  20529. /**
  20530. * Specifies if the ready state should be checked on each call
  20531. */
  20532. checkReadyOnEveryCall: boolean;
  20533. /**
  20534. * Specifies if the ready state should be checked once
  20535. */
  20536. checkReadyOnlyOnce: boolean;
  20537. /**
  20538. * The state of the material
  20539. */
  20540. state: string;
  20541. /**
  20542. * The alpha value of the material
  20543. */
  20544. protected _alpha: number;
  20545. /**
  20546. * List of inspectable custom properties (used by the Inspector)
  20547. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20548. */
  20549. inspectableCustomProperties: IInspectable[];
  20550. /**
  20551. * Sets the alpha value of the material
  20552. */
  20553. /**
  20554. * Gets the alpha value of the material
  20555. */
  20556. alpha: number;
  20557. /**
  20558. * Specifies if back face culling is enabled
  20559. */
  20560. protected _backFaceCulling: boolean;
  20561. /**
  20562. * Sets the back-face culling state
  20563. */
  20564. /**
  20565. * Gets the back-face culling state
  20566. */
  20567. backFaceCulling: boolean;
  20568. /**
  20569. * Stores the value for side orientation
  20570. */
  20571. sideOrientation: number;
  20572. /**
  20573. * Callback triggered when the material is compiled
  20574. */
  20575. onCompiled: Nullable<(effect: Effect) => void>;
  20576. /**
  20577. * Callback triggered when an error occurs
  20578. */
  20579. onError: Nullable<(effect: Effect, errors: string) => void>;
  20580. /**
  20581. * Callback triggered to get the render target textures
  20582. */
  20583. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20584. /**
  20585. * Gets a boolean indicating that current material needs to register RTT
  20586. */
  20587. readonly hasRenderTargetTextures: boolean;
  20588. /**
  20589. * Specifies if the material should be serialized
  20590. */
  20591. doNotSerialize: boolean;
  20592. /**
  20593. * @hidden
  20594. */
  20595. _storeEffectOnSubMeshes: boolean;
  20596. /**
  20597. * Stores the animations for the material
  20598. */
  20599. animations: Nullable<Array<Animation>>;
  20600. /**
  20601. * An event triggered when the material is disposed
  20602. */
  20603. onDisposeObservable: Observable<Material>;
  20604. /**
  20605. * An observer which watches for dispose events
  20606. */
  20607. private _onDisposeObserver;
  20608. private _onUnBindObservable;
  20609. /**
  20610. * Called during a dispose event
  20611. */
  20612. onDispose: () => void;
  20613. private _onBindObservable;
  20614. /**
  20615. * An event triggered when the material is bound
  20616. */
  20617. readonly onBindObservable: Observable<AbstractMesh>;
  20618. /**
  20619. * An observer which watches for bind events
  20620. */
  20621. private _onBindObserver;
  20622. /**
  20623. * Called during a bind event
  20624. */
  20625. onBind: (Mesh: AbstractMesh) => void;
  20626. /**
  20627. * An event triggered when the material is unbound
  20628. */
  20629. readonly onUnBindObservable: Observable<Material>;
  20630. /**
  20631. * Stores the value of the alpha mode
  20632. */
  20633. private _alphaMode;
  20634. /**
  20635. * Sets the value of the alpha mode.
  20636. *
  20637. * | Value | Type | Description |
  20638. * | --- | --- | --- |
  20639. * | 0 | ALPHA_DISABLE | |
  20640. * | 1 | ALPHA_ADD | |
  20641. * | 2 | ALPHA_COMBINE | |
  20642. * | 3 | ALPHA_SUBTRACT | |
  20643. * | 4 | ALPHA_MULTIPLY | |
  20644. * | 5 | ALPHA_MAXIMIZED | |
  20645. * | 6 | ALPHA_ONEONE | |
  20646. * | 7 | ALPHA_PREMULTIPLIED | |
  20647. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20648. * | 9 | ALPHA_INTERPOLATE | |
  20649. * | 10 | ALPHA_SCREENMODE | |
  20650. *
  20651. */
  20652. /**
  20653. * Gets the value of the alpha mode
  20654. */
  20655. alphaMode: number;
  20656. /**
  20657. * Stores the state of the need depth pre-pass value
  20658. */
  20659. private _needDepthPrePass;
  20660. /**
  20661. * Sets the need depth pre-pass value
  20662. */
  20663. /**
  20664. * Gets the depth pre-pass value
  20665. */
  20666. needDepthPrePass: boolean;
  20667. /**
  20668. * Specifies if depth writing should be disabled
  20669. */
  20670. disableDepthWrite: boolean;
  20671. /**
  20672. * Specifies if depth writing should be forced
  20673. */
  20674. forceDepthWrite: boolean;
  20675. /**
  20676. * Specifies if there should be a separate pass for culling
  20677. */
  20678. separateCullingPass: boolean;
  20679. /**
  20680. * Stores the state specifing if fog should be enabled
  20681. */
  20682. private _fogEnabled;
  20683. /**
  20684. * Sets the state for enabling fog
  20685. */
  20686. /**
  20687. * Gets the value of the fog enabled state
  20688. */
  20689. fogEnabled: boolean;
  20690. /**
  20691. * Stores the size of points
  20692. */
  20693. pointSize: number;
  20694. /**
  20695. * Stores the z offset value
  20696. */
  20697. zOffset: number;
  20698. /**
  20699. * Gets a value specifying if wireframe mode is enabled
  20700. */
  20701. /**
  20702. * Sets the state of wireframe mode
  20703. */
  20704. wireframe: boolean;
  20705. /**
  20706. * Gets the value specifying if point clouds are enabled
  20707. */
  20708. /**
  20709. * Sets the state of point cloud mode
  20710. */
  20711. pointsCloud: boolean;
  20712. /**
  20713. * Gets the material fill mode
  20714. */
  20715. /**
  20716. * Sets the material fill mode
  20717. */
  20718. fillMode: number;
  20719. /**
  20720. * @hidden
  20721. * Stores the effects for the material
  20722. */
  20723. _effect: Nullable<Effect>;
  20724. /**
  20725. * @hidden
  20726. * Specifies if the material was previously ready
  20727. */
  20728. _wasPreviouslyReady: boolean;
  20729. /**
  20730. * Specifies if uniform buffers should be used
  20731. */
  20732. private _useUBO;
  20733. /**
  20734. * Stores a reference to the scene
  20735. */
  20736. private _scene;
  20737. /**
  20738. * Stores the fill mode state
  20739. */
  20740. private _fillMode;
  20741. /**
  20742. * Specifies if the depth write state should be cached
  20743. */
  20744. private _cachedDepthWriteState;
  20745. /**
  20746. * Stores the uniform buffer
  20747. */
  20748. protected _uniformBuffer: UniformBuffer;
  20749. /** @hidden */
  20750. _indexInSceneMaterialArray: number;
  20751. /** @hidden */
  20752. meshMap: Nullable<{
  20753. [id: string]: AbstractMesh | undefined;
  20754. }>;
  20755. /**
  20756. * Creates a material instance
  20757. * @param name defines the name of the material
  20758. * @param scene defines the scene to reference
  20759. * @param doNotAdd specifies if the material should be added to the scene
  20760. */
  20761. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20762. /**
  20763. * Returns a string representation of the current material
  20764. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20765. * @returns a string with material information
  20766. */
  20767. toString(fullDetails?: boolean): string;
  20768. /**
  20769. * Gets the class name of the material
  20770. * @returns a string with the class name of the material
  20771. */
  20772. getClassName(): string;
  20773. /**
  20774. * Specifies if updates for the material been locked
  20775. */
  20776. readonly isFrozen: boolean;
  20777. /**
  20778. * Locks updates for the material
  20779. */
  20780. freeze(): void;
  20781. /**
  20782. * Unlocks updates for the material
  20783. */
  20784. unfreeze(): void;
  20785. /**
  20786. * Specifies if the material is ready to be used
  20787. * @param mesh defines the mesh to check
  20788. * @param useInstances specifies if instances should be used
  20789. * @returns a boolean indicating if the material is ready to be used
  20790. */
  20791. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20792. /**
  20793. * Specifies that the submesh is ready to be used
  20794. * @param mesh defines the mesh to check
  20795. * @param subMesh defines which submesh to check
  20796. * @param useInstances specifies that instances should be used
  20797. * @returns a boolean indicating that the submesh is ready or not
  20798. */
  20799. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20800. /**
  20801. * Returns the material effect
  20802. * @returns the effect associated with the material
  20803. */
  20804. getEffect(): Nullable<Effect>;
  20805. /**
  20806. * Returns the current scene
  20807. * @returns a Scene
  20808. */
  20809. getScene(): Scene;
  20810. /**
  20811. * Specifies if the material will require alpha blending
  20812. * @returns a boolean specifying if alpha blending is needed
  20813. */
  20814. needAlphaBlending(): boolean;
  20815. /**
  20816. * Specifies if the mesh will require alpha blending
  20817. * @param mesh defines the mesh to check
  20818. * @returns a boolean specifying if alpha blending is needed for the mesh
  20819. */
  20820. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20821. /**
  20822. * Specifies if this material should be rendered in alpha test mode
  20823. * @returns a boolean specifying if an alpha test is needed.
  20824. */
  20825. needAlphaTesting(): boolean;
  20826. /**
  20827. * Gets the texture used for the alpha test
  20828. * @returns the texture to use for alpha testing
  20829. */
  20830. getAlphaTestTexture(): Nullable<BaseTexture>;
  20831. /**
  20832. * Marks the material to indicate that it needs to be re-calculated
  20833. */
  20834. markDirty(): void;
  20835. /** @hidden */
  20836. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20837. /**
  20838. * Binds the material to the mesh
  20839. * @param world defines the world transformation matrix
  20840. * @param mesh defines the mesh to bind the material to
  20841. */
  20842. bind(world: Matrix, mesh?: Mesh): void;
  20843. /**
  20844. * Binds the submesh to the material
  20845. * @param world defines the world transformation matrix
  20846. * @param mesh defines the mesh containing the submesh
  20847. * @param subMesh defines the submesh to bind the material to
  20848. */
  20849. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20850. /**
  20851. * Binds the world matrix to the material
  20852. * @param world defines the world transformation matrix
  20853. */
  20854. bindOnlyWorldMatrix(world: Matrix): void;
  20855. /**
  20856. * Binds the scene's uniform buffer to the effect.
  20857. * @param effect defines the effect to bind to the scene uniform buffer
  20858. * @param sceneUbo defines the uniform buffer storing scene data
  20859. */
  20860. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20861. /**
  20862. * Binds the view matrix to the effect
  20863. * @param effect defines the effect to bind the view matrix to
  20864. */
  20865. bindView(effect: Effect): void;
  20866. /**
  20867. * Binds the view projection matrix to the effect
  20868. * @param effect defines the effect to bind the view projection matrix to
  20869. */
  20870. bindViewProjection(effect: Effect): void;
  20871. /**
  20872. * Specifies if material alpha testing should be turned on for the mesh
  20873. * @param mesh defines the mesh to check
  20874. */
  20875. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20876. /**
  20877. * Processes to execute after binding the material to a mesh
  20878. * @param mesh defines the rendered mesh
  20879. */
  20880. protected _afterBind(mesh?: Mesh): void;
  20881. /**
  20882. * Unbinds the material from the mesh
  20883. */
  20884. unbind(): void;
  20885. /**
  20886. * Gets the active textures from the material
  20887. * @returns an array of textures
  20888. */
  20889. getActiveTextures(): BaseTexture[];
  20890. /**
  20891. * Specifies if the material uses a texture
  20892. * @param texture defines the texture to check against the material
  20893. * @returns a boolean specifying if the material uses the texture
  20894. */
  20895. hasTexture(texture: BaseTexture): boolean;
  20896. /**
  20897. * Makes a duplicate of the material, and gives it a new name
  20898. * @param name defines the new name for the duplicated material
  20899. * @returns the cloned material
  20900. */
  20901. clone(name: string): Nullable<Material>;
  20902. /**
  20903. * Gets the meshes bound to the material
  20904. * @returns an array of meshes bound to the material
  20905. */
  20906. getBindedMeshes(): AbstractMesh[];
  20907. /**
  20908. * Force shader compilation
  20909. * @param mesh defines the mesh associated with this material
  20910. * @param onCompiled defines a function to execute once the material is compiled
  20911. * @param options defines the options to configure the compilation
  20912. */
  20913. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20914. clipPlane: boolean;
  20915. }>): void;
  20916. /**
  20917. * Force shader compilation
  20918. * @param mesh defines the mesh that will use this material
  20919. * @param options defines additional options for compiling the shaders
  20920. * @returns a promise that resolves when the compilation completes
  20921. */
  20922. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20923. clipPlane: boolean;
  20924. }>): Promise<void>;
  20925. private static readonly _AllDirtyCallBack;
  20926. private static readonly _ImageProcessingDirtyCallBack;
  20927. private static readonly _TextureDirtyCallBack;
  20928. private static readonly _FresnelDirtyCallBack;
  20929. private static readonly _MiscDirtyCallBack;
  20930. private static readonly _LightsDirtyCallBack;
  20931. private static readonly _AttributeDirtyCallBack;
  20932. private static _FresnelAndMiscDirtyCallBack;
  20933. private static _TextureAndMiscDirtyCallBack;
  20934. private static readonly _DirtyCallbackArray;
  20935. private static readonly _RunDirtyCallBacks;
  20936. /**
  20937. * Marks a define in the material to indicate that it needs to be re-computed
  20938. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20939. */
  20940. markAsDirty(flag: number): void;
  20941. /**
  20942. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20943. * @param func defines a function which checks material defines against the submeshes
  20944. */
  20945. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20946. /**
  20947. * Indicates that we need to re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsAllDirty(): void;
  20950. /**
  20951. * Indicates that image processing needs to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20954. /**
  20955. * Indicates that textures need to be re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsTexturesDirty(): void;
  20958. /**
  20959. * Indicates that fresnel needs to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsFresnelDirty(): void;
  20962. /**
  20963. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20966. /**
  20967. * Indicates that lights need to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsLightsDirty(): void;
  20970. /**
  20971. * Indicates that attributes need to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsAttributesDirty(): void;
  20974. /**
  20975. * Indicates that misc needs to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsMiscDirty(): void;
  20978. /**
  20979. * Indicates that textures and misc need to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20982. /**
  20983. * Disposes the material
  20984. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20985. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20986. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20987. */
  20988. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20989. /** @hidden */
  20990. private releaseVertexArrayObject;
  20991. /**
  20992. * Serializes this material
  20993. * @returns the serialized material object
  20994. */
  20995. serialize(): any;
  20996. /**
  20997. * Creates a material from parsed material data
  20998. * @param parsedMaterial defines parsed material data
  20999. * @param scene defines the hosting scene
  21000. * @param rootUrl defines the root URL to use to load textures
  21001. * @returns a new material
  21002. */
  21003. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21004. }
  21005. }
  21006. declare module "babylonjs/Materials/multiMaterial" {
  21007. import { Nullable } from "babylonjs/types";
  21008. import { Scene } from "babylonjs/scene";
  21009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21010. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21012. import { Material } from "babylonjs/Materials/material";
  21013. /**
  21014. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21015. * separate meshes. This can be use to improve performances.
  21016. * @see http://doc.babylonjs.com/how_to/multi_materials
  21017. */
  21018. export class MultiMaterial extends Material {
  21019. private _subMaterials;
  21020. /**
  21021. * Gets or Sets the list of Materials used within the multi material.
  21022. * They need to be ordered according to the submeshes order in the associated mesh
  21023. */
  21024. subMaterials: Nullable<Material>[];
  21025. /**
  21026. * Function used to align with Node.getChildren()
  21027. * @returns the list of Materials used within the multi material
  21028. */
  21029. getChildren(): Nullable<Material>[];
  21030. /**
  21031. * Instantiates a new Multi Material
  21032. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21033. * separate meshes. This can be use to improve performances.
  21034. * @see http://doc.babylonjs.com/how_to/multi_materials
  21035. * @param name Define the name in the scene
  21036. * @param scene Define the scene the material belongs to
  21037. */
  21038. constructor(name: string, scene: Scene);
  21039. private _hookArray;
  21040. /**
  21041. * Get one of the submaterial by its index in the submaterials array
  21042. * @param index The index to look the sub material at
  21043. * @returns The Material if the index has been defined
  21044. */
  21045. getSubMaterial(index: number): Nullable<Material>;
  21046. /**
  21047. * Get the list of active textures for the whole sub materials list.
  21048. * @returns All the textures that will be used during the rendering
  21049. */
  21050. getActiveTextures(): BaseTexture[];
  21051. /**
  21052. * Gets the current class name of the material e.g. "MultiMaterial"
  21053. * Mainly use in serialization.
  21054. * @returns the class name
  21055. */
  21056. getClassName(): string;
  21057. /**
  21058. * Checks if the material is ready to render the requested sub mesh
  21059. * @param mesh Define the mesh the submesh belongs to
  21060. * @param subMesh Define the sub mesh to look readyness for
  21061. * @param useInstances Define whether or not the material is used with instances
  21062. * @returns true if ready, otherwise false
  21063. */
  21064. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21065. /**
  21066. * Clones the current material and its related sub materials
  21067. * @param name Define the name of the newly cloned material
  21068. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21069. * @returns the cloned material
  21070. */
  21071. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21072. /**
  21073. * Serializes the materials into a JSON representation.
  21074. * @returns the JSON representation
  21075. */
  21076. serialize(): any;
  21077. /**
  21078. * Dispose the material and release its associated resources
  21079. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21080. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21081. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21082. */
  21083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21084. /**
  21085. * Creates a MultiMaterial from parsed MultiMaterial data.
  21086. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21087. * @param scene defines the hosting scene
  21088. * @returns a new MultiMaterial
  21089. */
  21090. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21091. }
  21092. }
  21093. declare module "babylonjs/Meshes/subMesh" {
  21094. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21095. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21096. import { Engine } from "babylonjs/Engines/engine";
  21097. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21098. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21099. import { Effect } from "babylonjs/Materials/effect";
  21100. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21101. import { Plane } from "babylonjs/Maths/math.plane";
  21102. import { Collider } from "babylonjs/Collisions/collider";
  21103. import { Material } from "babylonjs/Materials/material";
  21104. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21106. import { Mesh } from "babylonjs/Meshes/mesh";
  21107. import { Ray } from "babylonjs/Culling/ray";
  21108. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21109. /**
  21110. * Base class for submeshes
  21111. */
  21112. export class BaseSubMesh {
  21113. /** @hidden */
  21114. _materialDefines: Nullable<MaterialDefines>;
  21115. /** @hidden */
  21116. _materialEffect: Nullable<Effect>;
  21117. /**
  21118. * Gets associated effect
  21119. */
  21120. readonly effect: Nullable<Effect>;
  21121. /**
  21122. * Sets associated effect (effect used to render this submesh)
  21123. * @param effect defines the effect to associate with
  21124. * @param defines defines the set of defines used to compile this effect
  21125. */
  21126. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21127. }
  21128. /**
  21129. * Defines a subdivision inside a mesh
  21130. */
  21131. export class SubMesh extends BaseSubMesh implements ICullable {
  21132. /** the material index to use */
  21133. materialIndex: number;
  21134. /** vertex index start */
  21135. verticesStart: number;
  21136. /** vertices count */
  21137. verticesCount: number;
  21138. /** index start */
  21139. indexStart: number;
  21140. /** indices count */
  21141. indexCount: number;
  21142. /** @hidden */
  21143. _linesIndexCount: number;
  21144. private _mesh;
  21145. private _renderingMesh;
  21146. private _boundingInfo;
  21147. private _linesIndexBuffer;
  21148. /** @hidden */
  21149. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21150. /** @hidden */
  21151. _trianglePlanes: Plane[];
  21152. /** @hidden */
  21153. _lastColliderTransformMatrix: Nullable<Matrix>;
  21154. /** @hidden */
  21155. _renderId: number;
  21156. /** @hidden */
  21157. _alphaIndex: number;
  21158. /** @hidden */
  21159. _distanceToCamera: number;
  21160. /** @hidden */
  21161. _id: number;
  21162. private _currentMaterial;
  21163. /**
  21164. * Add a new submesh to a mesh
  21165. * @param materialIndex defines the material index to use
  21166. * @param verticesStart defines vertex index start
  21167. * @param verticesCount defines vertices count
  21168. * @param indexStart defines index start
  21169. * @param indexCount defines indices count
  21170. * @param mesh defines the parent mesh
  21171. * @param renderingMesh defines an optional rendering mesh
  21172. * @param createBoundingBox defines if bounding box should be created for this submesh
  21173. * @returns the new submesh
  21174. */
  21175. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21176. /**
  21177. * Creates a new submesh
  21178. * @param materialIndex defines the material index to use
  21179. * @param verticesStart defines vertex index start
  21180. * @param verticesCount defines vertices count
  21181. * @param indexStart defines index start
  21182. * @param indexCount defines indices count
  21183. * @param mesh defines the parent mesh
  21184. * @param renderingMesh defines an optional rendering mesh
  21185. * @param createBoundingBox defines if bounding box should be created for this submesh
  21186. */
  21187. constructor(
  21188. /** the material index to use */
  21189. materialIndex: number,
  21190. /** vertex index start */
  21191. verticesStart: number,
  21192. /** vertices count */
  21193. verticesCount: number,
  21194. /** index start */
  21195. indexStart: number,
  21196. /** indices count */
  21197. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21198. /**
  21199. * Returns true if this submesh covers the entire parent mesh
  21200. * @ignorenaming
  21201. */
  21202. readonly IsGlobal: boolean;
  21203. /**
  21204. * Returns the submesh BoudingInfo object
  21205. * @returns current bounding info (or mesh's one if the submesh is global)
  21206. */
  21207. getBoundingInfo(): BoundingInfo;
  21208. /**
  21209. * Sets the submesh BoundingInfo
  21210. * @param boundingInfo defines the new bounding info to use
  21211. * @returns the SubMesh
  21212. */
  21213. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21214. /**
  21215. * Returns the mesh of the current submesh
  21216. * @return the parent mesh
  21217. */
  21218. getMesh(): AbstractMesh;
  21219. /**
  21220. * Returns the rendering mesh of the submesh
  21221. * @returns the rendering mesh (could be different from parent mesh)
  21222. */
  21223. getRenderingMesh(): Mesh;
  21224. /**
  21225. * Returns the submesh material
  21226. * @returns null or the current material
  21227. */
  21228. getMaterial(): Nullable<Material>;
  21229. /**
  21230. * Sets a new updated BoundingInfo object to the submesh
  21231. * @param data defines an optional position array to use to determine the bounding info
  21232. * @returns the SubMesh
  21233. */
  21234. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21235. /** @hidden */
  21236. _checkCollision(collider: Collider): boolean;
  21237. /**
  21238. * Updates the submesh BoundingInfo
  21239. * @param world defines the world matrix to use to update the bounding info
  21240. * @returns the submesh
  21241. */
  21242. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21243. /**
  21244. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21245. * @param frustumPlanes defines the frustum planes
  21246. * @returns true if the submesh is intersecting with the frustum
  21247. */
  21248. isInFrustum(frustumPlanes: Plane[]): boolean;
  21249. /**
  21250. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21251. * @param frustumPlanes defines the frustum planes
  21252. * @returns true if the submesh is inside the frustum
  21253. */
  21254. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21255. /**
  21256. * Renders the submesh
  21257. * @param enableAlphaMode defines if alpha needs to be used
  21258. * @returns the submesh
  21259. */
  21260. render(enableAlphaMode: boolean): SubMesh;
  21261. /**
  21262. * @hidden
  21263. */
  21264. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21265. /**
  21266. * Checks if the submesh intersects with a ray
  21267. * @param ray defines the ray to test
  21268. * @returns true is the passed ray intersects the submesh bounding box
  21269. */
  21270. canIntersects(ray: Ray): boolean;
  21271. /**
  21272. * Intersects current submesh with a ray
  21273. * @param ray defines the ray to test
  21274. * @param positions defines mesh's positions array
  21275. * @param indices defines mesh's indices array
  21276. * @param fastCheck defines if only bounding info should be used
  21277. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21278. * @returns intersection info or null if no intersection
  21279. */
  21280. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21281. /** @hidden */
  21282. private _intersectLines;
  21283. /** @hidden */
  21284. private _intersectUnIndexedLines;
  21285. /** @hidden */
  21286. private _intersectTriangles;
  21287. /** @hidden */
  21288. private _intersectUnIndexedTriangles;
  21289. /** @hidden */
  21290. _rebuild(): void;
  21291. /**
  21292. * Creates a new submesh from the passed mesh
  21293. * @param newMesh defines the new hosting mesh
  21294. * @param newRenderingMesh defines an optional rendering mesh
  21295. * @returns the new submesh
  21296. */
  21297. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21298. /**
  21299. * Release associated resources
  21300. */
  21301. dispose(): void;
  21302. /**
  21303. * Gets the class name
  21304. * @returns the string "SubMesh".
  21305. */
  21306. getClassName(): string;
  21307. /**
  21308. * Creates a new submesh from indices data
  21309. * @param materialIndex the index of the main mesh material
  21310. * @param startIndex the index where to start the copy in the mesh indices array
  21311. * @param indexCount the number of indices to copy then from the startIndex
  21312. * @param mesh the main mesh to create the submesh from
  21313. * @param renderingMesh the optional rendering mesh
  21314. * @returns a new submesh
  21315. */
  21316. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21317. }
  21318. }
  21319. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21320. /**
  21321. * Class used to represent data loading progression
  21322. */
  21323. export class SceneLoaderFlags {
  21324. private static _ForceFullSceneLoadingForIncremental;
  21325. private static _ShowLoadingScreen;
  21326. private static _CleanBoneMatrixWeights;
  21327. private static _loggingLevel;
  21328. /**
  21329. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21330. */
  21331. static ForceFullSceneLoadingForIncremental: boolean;
  21332. /**
  21333. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21334. */
  21335. static ShowLoadingScreen: boolean;
  21336. /**
  21337. * Defines the current logging level (while loading the scene)
  21338. * @ignorenaming
  21339. */
  21340. static loggingLevel: number;
  21341. /**
  21342. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21343. */
  21344. static CleanBoneMatrixWeights: boolean;
  21345. }
  21346. }
  21347. declare module "babylonjs/Meshes/geometry" {
  21348. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21349. import { Scene } from "babylonjs/scene";
  21350. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21351. import { Engine } from "babylonjs/Engines/engine";
  21352. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21353. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21354. import { Effect } from "babylonjs/Materials/effect";
  21355. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21356. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21357. import { Mesh } from "babylonjs/Meshes/mesh";
  21358. /**
  21359. * Class used to store geometry data (vertex buffers + index buffer)
  21360. */
  21361. export class Geometry implements IGetSetVerticesData {
  21362. /**
  21363. * Gets or sets the ID of the geometry
  21364. */
  21365. id: string;
  21366. /**
  21367. * Gets or sets the unique ID of the geometry
  21368. */
  21369. uniqueId: number;
  21370. /**
  21371. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21372. */
  21373. delayLoadState: number;
  21374. /**
  21375. * Gets the file containing the data to load when running in delay load state
  21376. */
  21377. delayLoadingFile: Nullable<string>;
  21378. /**
  21379. * Callback called when the geometry is updated
  21380. */
  21381. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21382. private _scene;
  21383. private _engine;
  21384. private _meshes;
  21385. private _totalVertices;
  21386. /** @hidden */
  21387. _indices: IndicesArray;
  21388. /** @hidden */
  21389. _vertexBuffers: {
  21390. [key: string]: VertexBuffer;
  21391. };
  21392. private _isDisposed;
  21393. private _extend;
  21394. private _boundingBias;
  21395. /** @hidden */
  21396. _delayInfo: Array<string>;
  21397. private _indexBuffer;
  21398. private _indexBufferIsUpdatable;
  21399. /** @hidden */
  21400. _boundingInfo: Nullable<BoundingInfo>;
  21401. /** @hidden */
  21402. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21403. /** @hidden */
  21404. _softwareSkinningFrameId: number;
  21405. private _vertexArrayObjects;
  21406. private _updatable;
  21407. /** @hidden */
  21408. _positions: Nullable<Vector3[]>;
  21409. /**
  21410. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21411. */
  21412. /**
  21413. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21414. */
  21415. boundingBias: Vector2;
  21416. /**
  21417. * Static function used to attach a new empty geometry to a mesh
  21418. * @param mesh defines the mesh to attach the geometry to
  21419. * @returns the new Geometry
  21420. */
  21421. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21422. /**
  21423. * Creates a new geometry
  21424. * @param id defines the unique ID
  21425. * @param scene defines the hosting scene
  21426. * @param vertexData defines the VertexData used to get geometry data
  21427. * @param updatable defines if geometry must be updatable (false by default)
  21428. * @param mesh defines the mesh that will be associated with the geometry
  21429. */
  21430. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21431. /**
  21432. * Gets the current extend of the geometry
  21433. */
  21434. readonly extend: {
  21435. minimum: Vector3;
  21436. maximum: Vector3;
  21437. };
  21438. /**
  21439. * Gets the hosting scene
  21440. * @returns the hosting Scene
  21441. */
  21442. getScene(): Scene;
  21443. /**
  21444. * Gets the hosting engine
  21445. * @returns the hosting Engine
  21446. */
  21447. getEngine(): Engine;
  21448. /**
  21449. * Defines if the geometry is ready to use
  21450. * @returns true if the geometry is ready to be used
  21451. */
  21452. isReady(): boolean;
  21453. /**
  21454. * Gets a value indicating that the geometry should not be serialized
  21455. */
  21456. readonly doNotSerialize: boolean;
  21457. /** @hidden */
  21458. _rebuild(): void;
  21459. /**
  21460. * Affects all geometry data in one call
  21461. * @param vertexData defines the geometry data
  21462. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21463. */
  21464. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21465. /**
  21466. * Set specific vertex data
  21467. * @param kind defines the data kind (Position, normal, etc...)
  21468. * @param data defines the vertex data to use
  21469. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21470. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21471. */
  21472. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21473. /**
  21474. * Removes a specific vertex data
  21475. * @param kind defines the data kind (Position, normal, etc...)
  21476. */
  21477. removeVerticesData(kind: string): void;
  21478. /**
  21479. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21480. * @param buffer defines the vertex buffer to use
  21481. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21482. */
  21483. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21484. /**
  21485. * Update a specific vertex buffer
  21486. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21487. * It will do nothing if the buffer is not updatable
  21488. * @param kind defines the data kind (Position, normal, etc...)
  21489. * @param data defines the data to use
  21490. * @param offset defines the offset in the target buffer where to store the data
  21491. * @param useBytes set to true if the offset is in bytes
  21492. */
  21493. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21494. /**
  21495. * Update a specific vertex buffer
  21496. * This function will create a new buffer if the current one is not updatable
  21497. * @param kind defines the data kind (Position, normal, etc...)
  21498. * @param data defines the data to use
  21499. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21500. */
  21501. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21502. private _updateBoundingInfo;
  21503. /** @hidden */
  21504. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21505. /**
  21506. * Gets total number of vertices
  21507. * @returns the total number of vertices
  21508. */
  21509. getTotalVertices(): number;
  21510. /**
  21511. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21512. * @param kind defines the data kind (Position, normal, etc...)
  21513. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21514. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21515. * @returns a float array containing vertex data
  21516. */
  21517. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21518. /**
  21519. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21520. * @param kind defines the data kind (Position, normal, etc...)
  21521. * @returns true if the vertex buffer with the specified kind is updatable
  21522. */
  21523. isVertexBufferUpdatable(kind: string): boolean;
  21524. /**
  21525. * Gets a specific vertex buffer
  21526. * @param kind defines the data kind (Position, normal, etc...)
  21527. * @returns a VertexBuffer
  21528. */
  21529. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21530. /**
  21531. * Returns all vertex buffers
  21532. * @return an object holding all vertex buffers indexed by kind
  21533. */
  21534. getVertexBuffers(): Nullable<{
  21535. [key: string]: VertexBuffer;
  21536. }>;
  21537. /**
  21538. * Gets a boolean indicating if specific vertex buffer is present
  21539. * @param kind defines the data kind (Position, normal, etc...)
  21540. * @returns true if data is present
  21541. */
  21542. isVerticesDataPresent(kind: string): boolean;
  21543. /**
  21544. * Gets a list of all attached data kinds (Position, normal, etc...)
  21545. * @returns a list of string containing all kinds
  21546. */
  21547. getVerticesDataKinds(): string[];
  21548. /**
  21549. * Update index buffer
  21550. * @param indices defines the indices to store in the index buffer
  21551. * @param offset defines the offset in the target buffer where to store the data
  21552. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21553. */
  21554. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21555. /**
  21556. * Creates a new index buffer
  21557. * @param indices defines the indices to store in the index buffer
  21558. * @param totalVertices defines the total number of vertices (could be null)
  21559. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21560. */
  21561. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21562. /**
  21563. * Return the total number of indices
  21564. * @returns the total number of indices
  21565. */
  21566. getTotalIndices(): number;
  21567. /**
  21568. * Gets the index buffer array
  21569. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21570. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21571. * @returns the index buffer array
  21572. */
  21573. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21574. /**
  21575. * Gets the index buffer
  21576. * @return the index buffer
  21577. */
  21578. getIndexBuffer(): Nullable<DataBuffer>;
  21579. /** @hidden */
  21580. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21581. /**
  21582. * Release the associated resources for a specific mesh
  21583. * @param mesh defines the source mesh
  21584. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21585. */
  21586. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21587. /**
  21588. * Apply current geometry to a given mesh
  21589. * @param mesh defines the mesh to apply geometry to
  21590. */
  21591. applyToMesh(mesh: Mesh): void;
  21592. private _updateExtend;
  21593. private _applyToMesh;
  21594. private notifyUpdate;
  21595. /**
  21596. * Load the geometry if it was flagged as delay loaded
  21597. * @param scene defines the hosting scene
  21598. * @param onLoaded defines a callback called when the geometry is loaded
  21599. */
  21600. load(scene: Scene, onLoaded?: () => void): void;
  21601. private _queueLoad;
  21602. /**
  21603. * Invert the geometry to move from a right handed system to a left handed one.
  21604. */
  21605. toLeftHanded(): void;
  21606. /** @hidden */
  21607. _resetPointsArrayCache(): void;
  21608. /** @hidden */
  21609. _generatePointsArray(): boolean;
  21610. /**
  21611. * Gets a value indicating if the geometry is disposed
  21612. * @returns true if the geometry was disposed
  21613. */
  21614. isDisposed(): boolean;
  21615. private _disposeVertexArrayObjects;
  21616. /**
  21617. * Free all associated resources
  21618. */
  21619. dispose(): void;
  21620. /**
  21621. * Clone the current geometry into a new geometry
  21622. * @param id defines the unique ID of the new geometry
  21623. * @returns a new geometry object
  21624. */
  21625. copy(id: string): Geometry;
  21626. /**
  21627. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21628. * @return a JSON representation of the current geometry data (without the vertices data)
  21629. */
  21630. serialize(): any;
  21631. private toNumberArray;
  21632. /**
  21633. * Serialize all vertices data into a JSON oject
  21634. * @returns a JSON representation of the current geometry data
  21635. */
  21636. serializeVerticeData(): any;
  21637. /**
  21638. * Extracts a clone of a mesh geometry
  21639. * @param mesh defines the source mesh
  21640. * @param id defines the unique ID of the new geometry object
  21641. * @returns the new geometry object
  21642. */
  21643. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21644. /**
  21645. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21646. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21647. * Be aware Math.random() could cause collisions, but:
  21648. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21649. * @returns a string containing a new GUID
  21650. */
  21651. static RandomId(): string;
  21652. /** @hidden */
  21653. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21654. private static _CleanMatricesWeights;
  21655. /**
  21656. * Create a new geometry from persisted data (Using .babylon file format)
  21657. * @param parsedVertexData defines the persisted data
  21658. * @param scene defines the hosting scene
  21659. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21660. * @returns the new geometry object
  21661. */
  21662. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21663. }
  21664. }
  21665. declare module "babylonjs/Meshes/mesh.vertexData" {
  21666. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21667. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21668. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21669. import { Geometry } from "babylonjs/Meshes/geometry";
  21670. import { Mesh } from "babylonjs/Meshes/mesh";
  21671. /**
  21672. * Define an interface for all classes that will get and set the data on vertices
  21673. */
  21674. export interface IGetSetVerticesData {
  21675. /**
  21676. * Gets a boolean indicating if specific vertex data is present
  21677. * @param kind defines the vertex data kind to use
  21678. * @returns true is data kind is present
  21679. */
  21680. isVerticesDataPresent(kind: string): boolean;
  21681. /**
  21682. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21683. * @param kind defines the data kind (Position, normal, etc...)
  21684. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21685. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21686. * @returns a float array containing vertex data
  21687. */
  21688. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21689. /**
  21690. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21691. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21692. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21693. * @returns the indices array or an empty array if the mesh has no geometry
  21694. */
  21695. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21696. /**
  21697. * Set specific vertex data
  21698. * @param kind defines the data kind (Position, normal, etc...)
  21699. * @param data defines the vertex data to use
  21700. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21701. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21702. */
  21703. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21704. /**
  21705. * Update a specific associated vertex buffer
  21706. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21707. * - VertexBuffer.PositionKind
  21708. * - VertexBuffer.UVKind
  21709. * - VertexBuffer.UV2Kind
  21710. * - VertexBuffer.UV3Kind
  21711. * - VertexBuffer.UV4Kind
  21712. * - VertexBuffer.UV5Kind
  21713. * - VertexBuffer.UV6Kind
  21714. * - VertexBuffer.ColorKind
  21715. * - VertexBuffer.MatricesIndicesKind
  21716. * - VertexBuffer.MatricesIndicesExtraKind
  21717. * - VertexBuffer.MatricesWeightsKind
  21718. * - VertexBuffer.MatricesWeightsExtraKind
  21719. * @param data defines the data source
  21720. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21721. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21722. */
  21723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21724. /**
  21725. * Creates a new index buffer
  21726. * @param indices defines the indices to store in the index buffer
  21727. * @param totalVertices defines the total number of vertices (could be null)
  21728. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21729. */
  21730. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21731. }
  21732. /**
  21733. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21734. */
  21735. export class VertexData {
  21736. /**
  21737. * Mesh side orientation : usually the external or front surface
  21738. */
  21739. static readonly FRONTSIDE: number;
  21740. /**
  21741. * Mesh side orientation : usually the internal or back surface
  21742. */
  21743. static readonly BACKSIDE: number;
  21744. /**
  21745. * Mesh side orientation : both internal and external or front and back surfaces
  21746. */
  21747. static readonly DOUBLESIDE: number;
  21748. /**
  21749. * Mesh side orientation : by default, `FRONTSIDE`
  21750. */
  21751. static readonly DEFAULTSIDE: number;
  21752. /**
  21753. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21754. */
  21755. positions: Nullable<FloatArray>;
  21756. /**
  21757. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21758. */
  21759. normals: Nullable<FloatArray>;
  21760. /**
  21761. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21762. */
  21763. tangents: Nullable<FloatArray>;
  21764. /**
  21765. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21766. */
  21767. uvs: Nullable<FloatArray>;
  21768. /**
  21769. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21770. */
  21771. uvs2: Nullable<FloatArray>;
  21772. /**
  21773. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs3: Nullable<FloatArray>;
  21776. /**
  21777. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs4: Nullable<FloatArray>;
  21780. /**
  21781. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs5: Nullable<FloatArray>;
  21784. /**
  21785. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs6: Nullable<FloatArray>;
  21788. /**
  21789. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21790. */
  21791. colors: Nullable<FloatArray>;
  21792. /**
  21793. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21794. */
  21795. matricesIndices: Nullable<FloatArray>;
  21796. /**
  21797. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21798. */
  21799. matricesWeights: Nullable<FloatArray>;
  21800. /**
  21801. * An array extending the number of possible indices
  21802. */
  21803. matricesIndicesExtra: Nullable<FloatArray>;
  21804. /**
  21805. * An array extending the number of possible weights when the number of indices is extended
  21806. */
  21807. matricesWeightsExtra: Nullable<FloatArray>;
  21808. /**
  21809. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21810. */
  21811. indices: Nullable<IndicesArray>;
  21812. /**
  21813. * Uses the passed data array to set the set the values for the specified kind of data
  21814. * @param data a linear array of floating numbers
  21815. * @param kind the type of data that is being set, eg positions, colors etc
  21816. */
  21817. set(data: FloatArray, kind: string): void;
  21818. /**
  21819. * Associates the vertexData to the passed Mesh.
  21820. * Sets it as updatable or not (default `false`)
  21821. * @param mesh the mesh the vertexData is applied to
  21822. * @param updatable when used and having the value true allows new data to update the vertexData
  21823. * @returns the VertexData
  21824. */
  21825. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21826. /**
  21827. * Associates the vertexData to the passed Geometry.
  21828. * Sets it as updatable or not (default `false`)
  21829. * @param geometry the geometry the vertexData is applied to
  21830. * @param updatable when used and having the value true allows new data to update the vertexData
  21831. * @returns VertexData
  21832. */
  21833. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21834. /**
  21835. * Updates the associated mesh
  21836. * @param mesh the mesh to be updated
  21837. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21838. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21839. * @returns VertexData
  21840. */
  21841. updateMesh(mesh: Mesh): VertexData;
  21842. /**
  21843. * Updates the associated geometry
  21844. * @param geometry the geometry to be updated
  21845. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21846. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21847. * @returns VertexData.
  21848. */
  21849. updateGeometry(geometry: Geometry): VertexData;
  21850. private _applyTo;
  21851. private _update;
  21852. /**
  21853. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21854. * @param matrix the transforming matrix
  21855. * @returns the VertexData
  21856. */
  21857. transform(matrix: Matrix): VertexData;
  21858. /**
  21859. * Merges the passed VertexData into the current one
  21860. * @param other the VertexData to be merged into the current one
  21861. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21862. * @returns the modified VertexData
  21863. */
  21864. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21865. private _mergeElement;
  21866. private _validate;
  21867. /**
  21868. * Serializes the VertexData
  21869. * @returns a serialized object
  21870. */
  21871. serialize(): any;
  21872. /**
  21873. * Extracts the vertexData from a mesh
  21874. * @param mesh the mesh from which to extract the VertexData
  21875. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21876. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21877. * @returns the object VertexData associated to the passed mesh
  21878. */
  21879. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21880. /**
  21881. * Extracts the vertexData from the geometry
  21882. * @param geometry the geometry from which to extract the VertexData
  21883. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21884. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21885. * @returns the object VertexData associated to the passed mesh
  21886. */
  21887. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21888. private static _ExtractFrom;
  21889. /**
  21890. * Creates the VertexData for a Ribbon
  21891. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21892. * * pathArray array of paths, each of which an array of successive Vector3
  21893. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21894. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21895. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21897. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21898. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21899. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21900. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21901. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21902. * @returns the VertexData of the ribbon
  21903. */
  21904. static CreateRibbon(options: {
  21905. pathArray: Vector3[][];
  21906. closeArray?: boolean;
  21907. closePath?: boolean;
  21908. offset?: number;
  21909. sideOrientation?: number;
  21910. frontUVs?: Vector4;
  21911. backUVs?: Vector4;
  21912. invertUV?: boolean;
  21913. uvs?: Vector2[];
  21914. colors?: Color4[];
  21915. }): VertexData;
  21916. /**
  21917. * Creates the VertexData for a box
  21918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21919. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21920. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21921. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21922. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21923. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21924. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21926. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21927. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21928. * @returns the VertexData of the box
  21929. */
  21930. static CreateBox(options: {
  21931. size?: number;
  21932. width?: number;
  21933. height?: number;
  21934. depth?: number;
  21935. faceUV?: Vector4[];
  21936. faceColors?: Color4[];
  21937. sideOrientation?: number;
  21938. frontUVs?: Vector4;
  21939. backUVs?: Vector4;
  21940. }): VertexData;
  21941. /**
  21942. * Creates the VertexData for a tiled box
  21943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21944. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21945. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21946. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21948. * @returns the VertexData of the box
  21949. */
  21950. static CreateTiledBox(options: {
  21951. pattern?: number;
  21952. width?: number;
  21953. height?: number;
  21954. depth?: number;
  21955. tileSize?: number;
  21956. tileWidth?: number;
  21957. tileHeight?: number;
  21958. alignHorizontal?: number;
  21959. alignVertical?: number;
  21960. faceUV?: Vector4[];
  21961. faceColors?: Color4[];
  21962. sideOrientation?: number;
  21963. }): VertexData;
  21964. /**
  21965. * Creates the VertexData for a tiled plane
  21966. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21967. * * pattern a limited pattern arrangement depending on the number
  21968. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21969. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21970. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21972. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21973. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21974. * @returns the VertexData of the tiled plane
  21975. */
  21976. static CreateTiledPlane(options: {
  21977. pattern?: number;
  21978. tileSize?: number;
  21979. tileWidth?: number;
  21980. tileHeight?: number;
  21981. size?: number;
  21982. width?: number;
  21983. height?: number;
  21984. alignHorizontal?: number;
  21985. alignVertical?: number;
  21986. sideOrientation?: number;
  21987. frontUVs?: Vector4;
  21988. backUVs?: Vector4;
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21993. * * segments sets the number of horizontal strips optional, default 32
  21994. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21995. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21996. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21997. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21998. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  21999. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22001. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22002. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22003. * @returns the VertexData of the ellipsoid
  22004. */
  22005. static CreateSphere(options: {
  22006. segments?: number;
  22007. diameter?: number;
  22008. diameterX?: number;
  22009. diameterY?: number;
  22010. diameterZ?: number;
  22011. arc?: number;
  22012. slice?: number;
  22013. sideOrientation?: number;
  22014. frontUVs?: Vector4;
  22015. backUVs?: Vector4;
  22016. }): VertexData;
  22017. /**
  22018. * Creates the VertexData for a cylinder, cone or prism
  22019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22020. * * height sets the height (y direction) of the cylinder, optional, default 2
  22021. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22022. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22023. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22024. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22025. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22026. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22027. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22028. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22029. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22030. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22032. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22033. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22034. * @returns the VertexData of the cylinder, cone or prism
  22035. */
  22036. static CreateCylinder(options: {
  22037. height?: number;
  22038. diameterTop?: number;
  22039. diameterBottom?: number;
  22040. diameter?: number;
  22041. tessellation?: number;
  22042. subdivisions?: number;
  22043. arc?: number;
  22044. faceColors?: Color4[];
  22045. faceUV?: Vector4[];
  22046. hasRings?: boolean;
  22047. enclose?: boolean;
  22048. sideOrientation?: number;
  22049. frontUVs?: Vector4;
  22050. backUVs?: Vector4;
  22051. }): VertexData;
  22052. /**
  22053. * Creates the VertexData for a torus
  22054. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22055. * * diameter the diameter of the torus, optional default 1
  22056. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22057. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22059. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22060. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22061. * @returns the VertexData of the torus
  22062. */
  22063. static CreateTorus(options: {
  22064. diameter?: number;
  22065. thickness?: number;
  22066. tessellation?: number;
  22067. sideOrientation?: number;
  22068. frontUVs?: Vector4;
  22069. backUVs?: Vector4;
  22070. }): VertexData;
  22071. /**
  22072. * Creates the VertexData of the LineSystem
  22073. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22074. * - lines an array of lines, each line being an array of successive Vector3
  22075. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22076. * @returns the VertexData of the LineSystem
  22077. */
  22078. static CreateLineSystem(options: {
  22079. lines: Vector3[][];
  22080. colors?: Nullable<Color4[][]>;
  22081. }): VertexData;
  22082. /**
  22083. * Create the VertexData for a DashedLines
  22084. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22085. * - points an array successive Vector3
  22086. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22087. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22088. * - dashNb the intended total number of dashes, optional, default 200
  22089. * @returns the VertexData for the DashedLines
  22090. */
  22091. static CreateDashedLines(options: {
  22092. points: Vector3[];
  22093. dashSize?: number;
  22094. gapSize?: number;
  22095. dashNb?: number;
  22096. }): VertexData;
  22097. /**
  22098. * Creates the VertexData for a Ground
  22099. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22100. * - width the width (x direction) of the ground, optional, default 1
  22101. * - height the height (z direction) of the ground, optional, default 1
  22102. * - subdivisions the number of subdivisions per side, optional, default 1
  22103. * @returns the VertexData of the Ground
  22104. */
  22105. static CreateGround(options: {
  22106. width?: number;
  22107. height?: number;
  22108. subdivisions?: number;
  22109. subdivisionsX?: number;
  22110. subdivisionsY?: number;
  22111. }): VertexData;
  22112. /**
  22113. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22114. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22115. * * xmin the ground minimum X coordinate, optional, default -1
  22116. * * zmin the ground minimum Z coordinate, optional, default -1
  22117. * * xmax the ground maximum X coordinate, optional, default 1
  22118. * * zmax the ground maximum Z coordinate, optional, default 1
  22119. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22120. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22121. * @returns the VertexData of the TiledGround
  22122. */
  22123. static CreateTiledGround(options: {
  22124. xmin: number;
  22125. zmin: number;
  22126. xmax: number;
  22127. zmax: number;
  22128. subdivisions?: {
  22129. w: number;
  22130. h: number;
  22131. };
  22132. precision?: {
  22133. w: number;
  22134. h: number;
  22135. };
  22136. }): VertexData;
  22137. /**
  22138. * Creates the VertexData of the Ground designed from a heightmap
  22139. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22140. * * width the width (x direction) of the ground
  22141. * * height the height (z direction) of the ground
  22142. * * subdivisions the number of subdivisions per side
  22143. * * minHeight the minimum altitude on the ground, optional, default 0
  22144. * * maxHeight the maximum altitude on the ground, optional default 1
  22145. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22146. * * buffer the array holding the image color data
  22147. * * bufferWidth the width of image
  22148. * * bufferHeight the height of image
  22149. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22150. * @returns the VertexData of the Ground designed from a heightmap
  22151. */
  22152. static CreateGroundFromHeightMap(options: {
  22153. width: number;
  22154. height: number;
  22155. subdivisions: number;
  22156. minHeight: number;
  22157. maxHeight: number;
  22158. colorFilter: Color3;
  22159. buffer: Uint8Array;
  22160. bufferWidth: number;
  22161. bufferHeight: number;
  22162. alphaFilter: number;
  22163. }): VertexData;
  22164. /**
  22165. * Creates the VertexData for a Plane
  22166. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22167. * * size sets the width and height of the plane to the value of size, optional default 1
  22168. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22169. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22171. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22172. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22173. * @returns the VertexData of the box
  22174. */
  22175. static CreatePlane(options: {
  22176. size?: number;
  22177. width?: number;
  22178. height?: number;
  22179. sideOrientation?: number;
  22180. frontUVs?: Vector4;
  22181. backUVs?: Vector4;
  22182. }): VertexData;
  22183. /**
  22184. * Creates the VertexData of the Disc or regular Polygon
  22185. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22186. * * radius the radius of the disc, optional default 0.5
  22187. * * tessellation the number of polygon sides, optional, default 64
  22188. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22190. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22191. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22192. * @returns the VertexData of the box
  22193. */
  22194. static CreateDisc(options: {
  22195. radius?: number;
  22196. tessellation?: number;
  22197. arc?: number;
  22198. sideOrientation?: number;
  22199. frontUVs?: Vector4;
  22200. backUVs?: Vector4;
  22201. }): VertexData;
  22202. /**
  22203. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22204. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22205. * @param polygon a mesh built from polygonTriangulation.build()
  22206. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22208. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22209. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22210. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22211. * @returns the VertexData of the Polygon
  22212. */
  22213. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22214. /**
  22215. * Creates the VertexData of the IcoSphere
  22216. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22217. * * radius the radius of the IcoSphere, optional default 1
  22218. * * radiusX allows stretching in the x direction, optional, default radius
  22219. * * radiusY allows stretching in the y direction, optional, default radius
  22220. * * radiusZ allows stretching in the z direction, optional, default radius
  22221. * * flat when true creates a flat shaded mesh, optional, default true
  22222. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22224. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22225. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22226. * @returns the VertexData of the IcoSphere
  22227. */
  22228. static CreateIcoSphere(options: {
  22229. radius?: number;
  22230. radiusX?: number;
  22231. radiusY?: number;
  22232. radiusZ?: number;
  22233. flat?: boolean;
  22234. subdivisions?: number;
  22235. sideOrientation?: number;
  22236. frontUVs?: Vector4;
  22237. backUVs?: Vector4;
  22238. }): VertexData;
  22239. /**
  22240. * Creates the VertexData for a Polyhedron
  22241. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22242. * * type provided types are:
  22243. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22244. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22245. * * size the size of the IcoSphere, optional default 1
  22246. * * sizeX allows stretching in the x direction, optional, default size
  22247. * * sizeY allows stretching in the y direction, optional, default size
  22248. * * sizeZ allows stretching in the z direction, optional, default size
  22249. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22250. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22251. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22252. * * flat when true creates a flat shaded mesh, optional, default true
  22253. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22255. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22256. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22257. * @returns the VertexData of the Polyhedron
  22258. */
  22259. static CreatePolyhedron(options: {
  22260. type?: number;
  22261. size?: number;
  22262. sizeX?: number;
  22263. sizeY?: number;
  22264. sizeZ?: number;
  22265. custom?: any;
  22266. faceUV?: Vector4[];
  22267. faceColors?: Color4[];
  22268. flat?: boolean;
  22269. sideOrientation?: number;
  22270. frontUVs?: Vector4;
  22271. backUVs?: Vector4;
  22272. }): VertexData;
  22273. /**
  22274. * Creates the VertexData for a TorusKnot
  22275. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22276. * * radius the radius of the torus knot, optional, default 2
  22277. * * tube the thickness of the tube, optional, default 0.5
  22278. * * radialSegments the number of sides on each tube segments, optional, default 32
  22279. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22280. * * p the number of windings around the z axis, optional, default 2
  22281. * * q the number of windings around the x axis, optional, default 3
  22282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22283. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22284. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22285. * @returns the VertexData of the Torus Knot
  22286. */
  22287. static CreateTorusKnot(options: {
  22288. radius?: number;
  22289. tube?: number;
  22290. radialSegments?: number;
  22291. tubularSegments?: number;
  22292. p?: number;
  22293. q?: number;
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Compute normals for given positions and indices
  22300. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22301. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22302. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22303. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22304. * * facetNormals : optional array of facet normals (vector3)
  22305. * * facetPositions : optional array of facet positions (vector3)
  22306. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22307. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22308. * * bInfo : optional bounding info, required for facetPartitioning computation
  22309. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22310. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22311. * * useRightHandedSystem: optional boolean to for right handed system computation
  22312. * * depthSort : optional boolean to enable the facet depth sort computation
  22313. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22314. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22315. */
  22316. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22317. facetNormals?: any;
  22318. facetPositions?: any;
  22319. facetPartitioning?: any;
  22320. ratio?: number;
  22321. bInfo?: any;
  22322. bbSize?: Vector3;
  22323. subDiv?: any;
  22324. useRightHandedSystem?: boolean;
  22325. depthSort?: boolean;
  22326. distanceTo?: Vector3;
  22327. depthSortedFacets?: any;
  22328. }): void;
  22329. /** @hidden */
  22330. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22331. /**
  22332. * Applies VertexData created from the imported parameters to the geometry
  22333. * @param parsedVertexData the parsed data from an imported file
  22334. * @param geometry the geometry to apply the VertexData to
  22335. */
  22336. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22337. }
  22338. }
  22339. declare module "babylonjs/Morph/morphTarget" {
  22340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22341. import { Observable } from "babylonjs/Misc/observable";
  22342. import { Nullable, FloatArray } from "babylonjs/types";
  22343. import { Scene } from "babylonjs/scene";
  22344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22345. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22346. /**
  22347. * Defines a target to use with MorphTargetManager
  22348. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22349. */
  22350. export class MorphTarget implements IAnimatable {
  22351. /** defines the name of the target */
  22352. name: string;
  22353. /**
  22354. * Gets or sets the list of animations
  22355. */
  22356. animations: import("babylonjs/Animations/animation").Animation[];
  22357. private _scene;
  22358. private _positions;
  22359. private _normals;
  22360. private _tangents;
  22361. private _uvs;
  22362. private _influence;
  22363. /**
  22364. * Observable raised when the influence changes
  22365. */
  22366. onInfluenceChanged: Observable<boolean>;
  22367. /** @hidden */
  22368. _onDataLayoutChanged: Observable<void>;
  22369. /**
  22370. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22371. */
  22372. influence: number;
  22373. /**
  22374. * Gets or sets the id of the morph Target
  22375. */
  22376. id: string;
  22377. private _animationPropertiesOverride;
  22378. /**
  22379. * Gets or sets the animation properties override
  22380. */
  22381. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22382. /**
  22383. * Creates a new MorphTarget
  22384. * @param name defines the name of the target
  22385. * @param influence defines the influence to use
  22386. * @param scene defines the scene the morphtarget belongs to
  22387. */
  22388. constructor(
  22389. /** defines the name of the target */
  22390. name: string, influence?: number, scene?: Nullable<Scene>);
  22391. /**
  22392. * Gets a boolean defining if the target contains position data
  22393. */
  22394. readonly hasPositions: boolean;
  22395. /**
  22396. * Gets a boolean defining if the target contains normal data
  22397. */
  22398. readonly hasNormals: boolean;
  22399. /**
  22400. * Gets a boolean defining if the target contains tangent data
  22401. */
  22402. readonly hasTangents: boolean;
  22403. /**
  22404. * Gets a boolean defining if the target contains texture coordinates data
  22405. */
  22406. readonly hasUVs: boolean;
  22407. /**
  22408. * Affects position data to this target
  22409. * @param data defines the position data to use
  22410. */
  22411. setPositions(data: Nullable<FloatArray>): void;
  22412. /**
  22413. * Gets the position data stored in this target
  22414. * @returns a FloatArray containing the position data (or null if not present)
  22415. */
  22416. getPositions(): Nullable<FloatArray>;
  22417. /**
  22418. * Affects normal data to this target
  22419. * @param data defines the normal data to use
  22420. */
  22421. setNormals(data: Nullable<FloatArray>): void;
  22422. /**
  22423. * Gets the normal data stored in this target
  22424. * @returns a FloatArray containing the normal data (or null if not present)
  22425. */
  22426. getNormals(): Nullable<FloatArray>;
  22427. /**
  22428. * Affects tangent data to this target
  22429. * @param data defines the tangent data to use
  22430. */
  22431. setTangents(data: Nullable<FloatArray>): void;
  22432. /**
  22433. * Gets the tangent data stored in this target
  22434. * @returns a FloatArray containing the tangent data (or null if not present)
  22435. */
  22436. getTangents(): Nullable<FloatArray>;
  22437. /**
  22438. * Affects texture coordinates data to this target
  22439. * @param data defines the texture coordinates data to use
  22440. */
  22441. setUVs(data: Nullable<FloatArray>): void;
  22442. /**
  22443. * Gets the texture coordinates data stored in this target
  22444. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22445. */
  22446. getUVs(): Nullable<FloatArray>;
  22447. /**
  22448. * Serializes the current target into a Serialization object
  22449. * @returns the serialized object
  22450. */
  22451. serialize(): any;
  22452. /**
  22453. * Returns the string "MorphTarget"
  22454. * @returns "MorphTarget"
  22455. */
  22456. getClassName(): string;
  22457. /**
  22458. * Creates a new target from serialized data
  22459. * @param serializationObject defines the serialized data to use
  22460. * @returns a new MorphTarget
  22461. */
  22462. static Parse(serializationObject: any): MorphTarget;
  22463. /**
  22464. * Creates a MorphTarget from mesh data
  22465. * @param mesh defines the source mesh
  22466. * @param name defines the name to use for the new target
  22467. * @param influence defines the influence to attach to the target
  22468. * @returns a new MorphTarget
  22469. */
  22470. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22471. }
  22472. }
  22473. declare module "babylonjs/Morph/morphTargetManager" {
  22474. import { Nullable } from "babylonjs/types";
  22475. import { Scene } from "babylonjs/scene";
  22476. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22477. /**
  22478. * This class is used to deform meshes using morphing between different targets
  22479. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22480. */
  22481. export class MorphTargetManager {
  22482. private _targets;
  22483. private _targetInfluenceChangedObservers;
  22484. private _targetDataLayoutChangedObservers;
  22485. private _activeTargets;
  22486. private _scene;
  22487. private _influences;
  22488. private _supportsNormals;
  22489. private _supportsTangents;
  22490. private _supportsUVs;
  22491. private _vertexCount;
  22492. private _uniqueId;
  22493. private _tempInfluences;
  22494. /**
  22495. * Gets or sets a boolean indicating if normals must be morphed
  22496. */
  22497. enableNormalMorphing: boolean;
  22498. /**
  22499. * Gets or sets a boolean indicating if tangents must be morphed
  22500. */
  22501. enableTangentMorphing: boolean;
  22502. /**
  22503. * Gets or sets a boolean indicating if UV must be morphed
  22504. */
  22505. enableUVMorphing: boolean;
  22506. /**
  22507. * Creates a new MorphTargetManager
  22508. * @param scene defines the current scene
  22509. */
  22510. constructor(scene?: Nullable<Scene>);
  22511. /**
  22512. * Gets the unique ID of this manager
  22513. */
  22514. readonly uniqueId: number;
  22515. /**
  22516. * Gets the number of vertices handled by this manager
  22517. */
  22518. readonly vertexCount: number;
  22519. /**
  22520. * Gets a boolean indicating if this manager supports morphing of normals
  22521. */
  22522. readonly supportsNormals: boolean;
  22523. /**
  22524. * Gets a boolean indicating if this manager supports morphing of tangents
  22525. */
  22526. readonly supportsTangents: boolean;
  22527. /**
  22528. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22529. */
  22530. readonly supportsUVs: boolean;
  22531. /**
  22532. * Gets the number of targets stored in this manager
  22533. */
  22534. readonly numTargets: number;
  22535. /**
  22536. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22537. */
  22538. readonly numInfluencers: number;
  22539. /**
  22540. * Gets the list of influences (one per target)
  22541. */
  22542. readonly influences: Float32Array;
  22543. /**
  22544. * Gets the active target at specified index. An active target is a target with an influence > 0
  22545. * @param index defines the index to check
  22546. * @returns the requested target
  22547. */
  22548. getActiveTarget(index: number): MorphTarget;
  22549. /**
  22550. * Gets the target at specified index
  22551. * @param index defines the index to check
  22552. * @returns the requested target
  22553. */
  22554. getTarget(index: number): MorphTarget;
  22555. /**
  22556. * Add a new target to this manager
  22557. * @param target defines the target to add
  22558. */
  22559. addTarget(target: MorphTarget): void;
  22560. /**
  22561. * Removes a target from the manager
  22562. * @param target defines the target to remove
  22563. */
  22564. removeTarget(target: MorphTarget): void;
  22565. /**
  22566. * Serializes the current manager into a Serialization object
  22567. * @returns the serialized object
  22568. */
  22569. serialize(): any;
  22570. private _syncActiveTargets;
  22571. /**
  22572. * Syncrhonize the targets with all the meshes using this morph target manager
  22573. */
  22574. synchronize(): void;
  22575. /**
  22576. * Creates a new MorphTargetManager from serialized data
  22577. * @param serializationObject defines the serialized data
  22578. * @param scene defines the hosting scene
  22579. * @returns the new MorphTargetManager
  22580. */
  22581. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22582. }
  22583. }
  22584. declare module "babylonjs/Meshes/meshLODLevel" {
  22585. import { Mesh } from "babylonjs/Meshes/mesh";
  22586. import { Nullable } from "babylonjs/types";
  22587. /**
  22588. * Class used to represent a specific level of detail of a mesh
  22589. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22590. */
  22591. export class MeshLODLevel {
  22592. /** Defines the distance where this level should star being displayed */
  22593. distance: number;
  22594. /** Defines the mesh to use to render this level */
  22595. mesh: Nullable<Mesh>;
  22596. /**
  22597. * Creates a new LOD level
  22598. * @param distance defines the distance where this level should star being displayed
  22599. * @param mesh defines the mesh to use to render this level
  22600. */
  22601. constructor(
  22602. /** Defines the distance where this level should star being displayed */
  22603. distance: number,
  22604. /** Defines the mesh to use to render this level */
  22605. mesh: Nullable<Mesh>);
  22606. }
  22607. }
  22608. declare module "babylonjs/Meshes/groundMesh" {
  22609. import { Scene } from "babylonjs/scene";
  22610. import { Vector3 } from "babylonjs/Maths/math.vector";
  22611. import { Mesh } from "babylonjs/Meshes/mesh";
  22612. /**
  22613. * Mesh representing the gorund
  22614. */
  22615. export class GroundMesh extends Mesh {
  22616. /** If octree should be generated */
  22617. generateOctree: boolean;
  22618. private _heightQuads;
  22619. /** @hidden */
  22620. _subdivisionsX: number;
  22621. /** @hidden */
  22622. _subdivisionsY: number;
  22623. /** @hidden */
  22624. _width: number;
  22625. /** @hidden */
  22626. _height: number;
  22627. /** @hidden */
  22628. _minX: number;
  22629. /** @hidden */
  22630. _maxX: number;
  22631. /** @hidden */
  22632. _minZ: number;
  22633. /** @hidden */
  22634. _maxZ: number;
  22635. constructor(name: string, scene: Scene);
  22636. /**
  22637. * "GroundMesh"
  22638. * @returns "GroundMesh"
  22639. */
  22640. getClassName(): string;
  22641. /**
  22642. * The minimum of x and y subdivisions
  22643. */
  22644. readonly subdivisions: number;
  22645. /**
  22646. * X subdivisions
  22647. */
  22648. readonly subdivisionsX: number;
  22649. /**
  22650. * Y subdivisions
  22651. */
  22652. readonly subdivisionsY: number;
  22653. /**
  22654. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22655. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22656. * @param chunksCount the number of subdivisions for x and y
  22657. * @param octreeBlocksSize (Default: 32)
  22658. */
  22659. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22660. /**
  22661. * Returns a height (y) value in the Worl system :
  22662. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22663. * @param x x coordinate
  22664. * @param z z coordinate
  22665. * @returns the ground y position if (x, z) are outside the ground surface.
  22666. */
  22667. getHeightAtCoordinates(x: number, z: number): number;
  22668. /**
  22669. * Returns a normalized vector (Vector3) orthogonal to the ground
  22670. * at the ground coordinates (x, z) expressed in the World system.
  22671. * @param x x coordinate
  22672. * @param z z coordinate
  22673. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22674. */
  22675. getNormalAtCoordinates(x: number, z: number): Vector3;
  22676. /**
  22677. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22678. * at the ground coordinates (x, z) expressed in the World system.
  22679. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22680. * @param x x coordinate
  22681. * @param z z coordinate
  22682. * @param ref vector to store the result
  22683. * @returns the GroundMesh.
  22684. */
  22685. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22686. /**
  22687. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22688. * if the ground has been updated.
  22689. * This can be used in the render loop.
  22690. * @returns the GroundMesh.
  22691. */
  22692. updateCoordinateHeights(): GroundMesh;
  22693. private _getFacetAt;
  22694. private _initHeightQuads;
  22695. private _computeHeightQuads;
  22696. /**
  22697. * Serializes this ground mesh
  22698. * @param serializationObject object to write serialization to
  22699. */
  22700. serialize(serializationObject: any): void;
  22701. /**
  22702. * Parses a serialized ground mesh
  22703. * @param parsedMesh the serialized mesh
  22704. * @param scene the scene to create the ground mesh in
  22705. * @returns the created ground mesh
  22706. */
  22707. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22708. }
  22709. }
  22710. declare module "babylonjs/Physics/physicsJoint" {
  22711. import { Vector3 } from "babylonjs/Maths/math.vector";
  22712. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22713. /**
  22714. * Interface for Physics-Joint data
  22715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22716. */
  22717. export interface PhysicsJointData {
  22718. /**
  22719. * The main pivot of the joint
  22720. */
  22721. mainPivot?: Vector3;
  22722. /**
  22723. * The connected pivot of the joint
  22724. */
  22725. connectedPivot?: Vector3;
  22726. /**
  22727. * The main axis of the joint
  22728. */
  22729. mainAxis?: Vector3;
  22730. /**
  22731. * The connected axis of the joint
  22732. */
  22733. connectedAxis?: Vector3;
  22734. /**
  22735. * The collision of the joint
  22736. */
  22737. collision?: boolean;
  22738. /**
  22739. * Native Oimo/Cannon/Energy data
  22740. */
  22741. nativeParams?: any;
  22742. }
  22743. /**
  22744. * This is a holder class for the physics joint created by the physics plugin
  22745. * It holds a set of functions to control the underlying joint
  22746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22747. */
  22748. export class PhysicsJoint {
  22749. /**
  22750. * The type of the physics joint
  22751. */
  22752. type: number;
  22753. /**
  22754. * The data for the physics joint
  22755. */
  22756. jointData: PhysicsJointData;
  22757. private _physicsJoint;
  22758. protected _physicsPlugin: IPhysicsEnginePlugin;
  22759. /**
  22760. * Initializes the physics joint
  22761. * @param type The type of the physics joint
  22762. * @param jointData The data for the physics joint
  22763. */
  22764. constructor(
  22765. /**
  22766. * The type of the physics joint
  22767. */
  22768. type: number,
  22769. /**
  22770. * The data for the physics joint
  22771. */
  22772. jointData: PhysicsJointData);
  22773. /**
  22774. * Gets the physics joint
  22775. */
  22776. /**
  22777. * Sets the physics joint
  22778. */
  22779. physicsJoint: any;
  22780. /**
  22781. * Sets the physics plugin
  22782. */
  22783. physicsPlugin: IPhysicsEnginePlugin;
  22784. /**
  22785. * Execute a function that is physics-plugin specific.
  22786. * @param {Function} func the function that will be executed.
  22787. * It accepts two parameters: the physics world and the physics joint
  22788. */
  22789. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22790. /**
  22791. * Distance-Joint type
  22792. */
  22793. static DistanceJoint: number;
  22794. /**
  22795. * Hinge-Joint type
  22796. */
  22797. static HingeJoint: number;
  22798. /**
  22799. * Ball-and-Socket joint type
  22800. */
  22801. static BallAndSocketJoint: number;
  22802. /**
  22803. * Wheel-Joint type
  22804. */
  22805. static WheelJoint: number;
  22806. /**
  22807. * Slider-Joint type
  22808. */
  22809. static SliderJoint: number;
  22810. /**
  22811. * Prismatic-Joint type
  22812. */
  22813. static PrismaticJoint: number;
  22814. /**
  22815. * Universal-Joint type
  22816. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22817. */
  22818. static UniversalJoint: number;
  22819. /**
  22820. * Hinge-Joint 2 type
  22821. */
  22822. static Hinge2Joint: number;
  22823. /**
  22824. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22825. */
  22826. static PointToPointJoint: number;
  22827. /**
  22828. * Spring-Joint type
  22829. */
  22830. static SpringJoint: number;
  22831. /**
  22832. * Lock-Joint type
  22833. */
  22834. static LockJoint: number;
  22835. }
  22836. /**
  22837. * A class representing a physics distance joint
  22838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22839. */
  22840. export class DistanceJoint extends PhysicsJoint {
  22841. /**
  22842. *
  22843. * @param jointData The data for the Distance-Joint
  22844. */
  22845. constructor(jointData: DistanceJointData);
  22846. /**
  22847. * Update the predefined distance.
  22848. * @param maxDistance The maximum preferred distance
  22849. * @param minDistance The minimum preferred distance
  22850. */
  22851. updateDistance(maxDistance: number, minDistance?: number): void;
  22852. }
  22853. /**
  22854. * Represents a Motor-Enabled Joint
  22855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22856. */
  22857. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22858. /**
  22859. * Initializes the Motor-Enabled Joint
  22860. * @param type The type of the joint
  22861. * @param jointData The physica joint data for the joint
  22862. */
  22863. constructor(type: number, jointData: PhysicsJointData);
  22864. /**
  22865. * Set the motor values.
  22866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22867. * @param force the force to apply
  22868. * @param maxForce max force for this motor.
  22869. */
  22870. setMotor(force?: number, maxForce?: number): void;
  22871. /**
  22872. * Set the motor's limits.
  22873. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22874. * @param upperLimit The upper limit of the motor
  22875. * @param lowerLimit The lower limit of the motor
  22876. */
  22877. setLimit(upperLimit: number, lowerLimit?: number): void;
  22878. }
  22879. /**
  22880. * This class represents a single physics Hinge-Joint
  22881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22882. */
  22883. export class HingeJoint extends MotorEnabledJoint {
  22884. /**
  22885. * Initializes the Hinge-Joint
  22886. * @param jointData The joint data for the Hinge-Joint
  22887. */
  22888. constructor(jointData: PhysicsJointData);
  22889. /**
  22890. * Set the motor values.
  22891. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22892. * @param {number} force the force to apply
  22893. * @param {number} maxForce max force for this motor.
  22894. */
  22895. setMotor(force?: number, maxForce?: number): void;
  22896. /**
  22897. * Set the motor's limits.
  22898. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22899. * @param upperLimit The upper limit of the motor
  22900. * @param lowerLimit The lower limit of the motor
  22901. */
  22902. setLimit(upperLimit: number, lowerLimit?: number): void;
  22903. }
  22904. /**
  22905. * This class represents a dual hinge physics joint (same as wheel joint)
  22906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22907. */
  22908. export class Hinge2Joint extends MotorEnabledJoint {
  22909. /**
  22910. * Initializes the Hinge2-Joint
  22911. * @param jointData The joint data for the Hinge2-Joint
  22912. */
  22913. constructor(jointData: PhysicsJointData);
  22914. /**
  22915. * Set the motor values.
  22916. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22917. * @param {number} targetSpeed the speed the motor is to reach
  22918. * @param {number} maxForce max force for this motor.
  22919. * @param {motorIndex} the motor's index, 0 or 1.
  22920. */
  22921. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22922. /**
  22923. * Set the motor limits.
  22924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22925. * @param {number} upperLimit the upper limit
  22926. * @param {number} lowerLimit lower limit
  22927. * @param {motorIndex} the motor's index, 0 or 1.
  22928. */
  22929. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22930. }
  22931. /**
  22932. * Interface for a motor enabled joint
  22933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22934. */
  22935. export interface IMotorEnabledJoint {
  22936. /**
  22937. * Physics joint
  22938. */
  22939. physicsJoint: any;
  22940. /**
  22941. * Sets the motor of the motor-enabled joint
  22942. * @param force The force of the motor
  22943. * @param maxForce The maximum force of the motor
  22944. * @param motorIndex The index of the motor
  22945. */
  22946. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22947. /**
  22948. * Sets the limit of the motor
  22949. * @param upperLimit The upper limit of the motor
  22950. * @param lowerLimit The lower limit of the motor
  22951. * @param motorIndex The index of the motor
  22952. */
  22953. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22954. }
  22955. /**
  22956. * Joint data for a Distance-Joint
  22957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22958. */
  22959. export interface DistanceJointData extends PhysicsJointData {
  22960. /**
  22961. * Max distance the 2 joint objects can be apart
  22962. */
  22963. maxDistance: number;
  22964. }
  22965. /**
  22966. * Joint data from a spring joint
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export interface SpringJointData extends PhysicsJointData {
  22970. /**
  22971. * Length of the spring
  22972. */
  22973. length: number;
  22974. /**
  22975. * Stiffness of the spring
  22976. */
  22977. stiffness: number;
  22978. /**
  22979. * Damping of the spring
  22980. */
  22981. damping: number;
  22982. /** this callback will be called when applying the force to the impostors. */
  22983. forceApplicationCallback: () => void;
  22984. }
  22985. }
  22986. declare module "babylonjs/Physics/physicsRaycastResult" {
  22987. import { Vector3 } from "babylonjs/Maths/math.vector";
  22988. /**
  22989. * Holds the data for the raycast result
  22990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22991. */
  22992. export class PhysicsRaycastResult {
  22993. private _hasHit;
  22994. private _hitDistance;
  22995. private _hitNormalWorld;
  22996. private _hitPointWorld;
  22997. private _rayFromWorld;
  22998. private _rayToWorld;
  22999. /**
  23000. * Gets if there was a hit
  23001. */
  23002. readonly hasHit: boolean;
  23003. /**
  23004. * Gets the distance from the hit
  23005. */
  23006. readonly hitDistance: number;
  23007. /**
  23008. * Gets the hit normal/direction in the world
  23009. */
  23010. readonly hitNormalWorld: Vector3;
  23011. /**
  23012. * Gets the hit point in the world
  23013. */
  23014. readonly hitPointWorld: Vector3;
  23015. /**
  23016. * Gets the ray "start point" of the ray in the world
  23017. */
  23018. readonly rayFromWorld: Vector3;
  23019. /**
  23020. * Gets the ray "end point" of the ray in the world
  23021. */
  23022. readonly rayToWorld: Vector3;
  23023. /**
  23024. * Sets the hit data (normal & point in world space)
  23025. * @param hitNormalWorld defines the normal in world space
  23026. * @param hitPointWorld defines the point in world space
  23027. */
  23028. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23029. /**
  23030. * Sets the distance from the start point to the hit point
  23031. * @param distance
  23032. */
  23033. setHitDistance(distance: number): void;
  23034. /**
  23035. * Calculates the distance manually
  23036. */
  23037. calculateHitDistance(): void;
  23038. /**
  23039. * Resets all the values to default
  23040. * @param from The from point on world space
  23041. * @param to The to point on world space
  23042. */
  23043. reset(from?: Vector3, to?: Vector3): void;
  23044. }
  23045. /**
  23046. * Interface for the size containing width and height
  23047. */
  23048. interface IXYZ {
  23049. /**
  23050. * X
  23051. */
  23052. x: number;
  23053. /**
  23054. * Y
  23055. */
  23056. y: number;
  23057. /**
  23058. * Z
  23059. */
  23060. z: number;
  23061. }
  23062. }
  23063. declare module "babylonjs/Physics/IPhysicsEngine" {
  23064. import { Nullable } from "babylonjs/types";
  23065. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23067. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23068. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23069. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23070. /**
  23071. * Interface used to describe a physics joint
  23072. */
  23073. export interface PhysicsImpostorJoint {
  23074. /** Defines the main impostor to which the joint is linked */
  23075. mainImpostor: PhysicsImpostor;
  23076. /** Defines the impostor that is connected to the main impostor using this joint */
  23077. connectedImpostor: PhysicsImpostor;
  23078. /** Defines the joint itself */
  23079. joint: PhysicsJoint;
  23080. }
  23081. /** @hidden */
  23082. export interface IPhysicsEnginePlugin {
  23083. world: any;
  23084. name: string;
  23085. setGravity(gravity: Vector3): void;
  23086. setTimeStep(timeStep: number): void;
  23087. getTimeStep(): number;
  23088. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23089. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23090. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23091. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23092. removePhysicsBody(impostor: PhysicsImpostor): void;
  23093. generateJoint(joint: PhysicsImpostorJoint): void;
  23094. removeJoint(joint: PhysicsImpostorJoint): void;
  23095. isSupported(): boolean;
  23096. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23097. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23098. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23099. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23100. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23101. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23102. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23103. getBodyMass(impostor: PhysicsImpostor): number;
  23104. getBodyFriction(impostor: PhysicsImpostor): number;
  23105. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23106. getBodyRestitution(impostor: PhysicsImpostor): number;
  23107. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23108. getBodyPressure?(impostor: PhysicsImpostor): number;
  23109. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23110. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23111. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23112. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23113. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23114. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23115. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23116. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23117. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23118. sleepBody(impostor: PhysicsImpostor): void;
  23119. wakeUpBody(impostor: PhysicsImpostor): void;
  23120. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23121. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23122. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23123. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23124. getRadius(impostor: PhysicsImpostor): number;
  23125. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23126. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23127. dispose(): void;
  23128. }
  23129. /**
  23130. * Interface used to define a physics engine
  23131. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23132. */
  23133. export interface IPhysicsEngine {
  23134. /**
  23135. * Gets the gravity vector used by the simulation
  23136. */
  23137. gravity: Vector3;
  23138. /**
  23139. * Sets the gravity vector used by the simulation
  23140. * @param gravity defines the gravity vector to use
  23141. */
  23142. setGravity(gravity: Vector3): void;
  23143. /**
  23144. * Set the time step of the physics engine.
  23145. * Default is 1/60.
  23146. * To slow it down, enter 1/600 for example.
  23147. * To speed it up, 1/30
  23148. * @param newTimeStep the new timestep to apply to this world.
  23149. */
  23150. setTimeStep(newTimeStep: number): void;
  23151. /**
  23152. * Get the time step of the physics engine.
  23153. * @returns the current time step
  23154. */
  23155. getTimeStep(): number;
  23156. /**
  23157. * Release all resources
  23158. */
  23159. dispose(): void;
  23160. /**
  23161. * Gets the name of the current physics plugin
  23162. * @returns the name of the plugin
  23163. */
  23164. getPhysicsPluginName(): string;
  23165. /**
  23166. * Adding a new impostor for the impostor tracking.
  23167. * This will be done by the impostor itself.
  23168. * @param impostor the impostor to add
  23169. */
  23170. addImpostor(impostor: PhysicsImpostor): void;
  23171. /**
  23172. * Remove an impostor from the engine.
  23173. * This impostor and its mesh will not longer be updated by the physics engine.
  23174. * @param impostor the impostor to remove
  23175. */
  23176. removeImpostor(impostor: PhysicsImpostor): void;
  23177. /**
  23178. * Add a joint to the physics engine
  23179. * @param mainImpostor defines the main impostor to which the joint is added.
  23180. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23181. * @param joint defines the joint that will connect both impostors.
  23182. */
  23183. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23184. /**
  23185. * Removes a joint from the simulation
  23186. * @param mainImpostor defines the impostor used with the joint
  23187. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23188. * @param joint defines the joint to remove
  23189. */
  23190. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23191. /**
  23192. * Gets the current plugin used to run the simulation
  23193. * @returns current plugin
  23194. */
  23195. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23196. /**
  23197. * Gets the list of physic impostors
  23198. * @returns an array of PhysicsImpostor
  23199. */
  23200. getImpostors(): Array<PhysicsImpostor>;
  23201. /**
  23202. * Gets the impostor for a physics enabled object
  23203. * @param object defines the object impersonated by the impostor
  23204. * @returns the PhysicsImpostor or null if not found
  23205. */
  23206. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23207. /**
  23208. * Gets the impostor for a physics body object
  23209. * @param body defines physics body used by the impostor
  23210. * @returns the PhysicsImpostor or null if not found
  23211. */
  23212. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23213. /**
  23214. * Does a raycast in the physics world
  23215. * @param from when should the ray start?
  23216. * @param to when should the ray end?
  23217. * @returns PhysicsRaycastResult
  23218. */
  23219. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23220. /**
  23221. * Called by the scene. No need to call it.
  23222. * @param delta defines the timespam between frames
  23223. */
  23224. _step(delta: number): void;
  23225. }
  23226. }
  23227. declare module "babylonjs/Physics/physicsImpostor" {
  23228. import { Nullable, IndicesArray } from "babylonjs/types";
  23229. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23230. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23232. import { Scene } from "babylonjs/scene";
  23233. import { Bone } from "babylonjs/Bones/bone";
  23234. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23235. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23236. import { Space } from "babylonjs/Maths/math.axis";
  23237. /**
  23238. * The interface for the physics imposter parameters
  23239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23240. */
  23241. export interface PhysicsImpostorParameters {
  23242. /**
  23243. * The mass of the physics imposter
  23244. */
  23245. mass: number;
  23246. /**
  23247. * The friction of the physics imposter
  23248. */
  23249. friction?: number;
  23250. /**
  23251. * The coefficient of restitution of the physics imposter
  23252. */
  23253. restitution?: number;
  23254. /**
  23255. * The native options of the physics imposter
  23256. */
  23257. nativeOptions?: any;
  23258. /**
  23259. * Specifies if the parent should be ignored
  23260. */
  23261. ignoreParent?: boolean;
  23262. /**
  23263. * Specifies if bi-directional transformations should be disabled
  23264. */
  23265. disableBidirectionalTransformation?: boolean;
  23266. /**
  23267. * The pressure inside the physics imposter, soft object only
  23268. */
  23269. pressure?: number;
  23270. /**
  23271. * The stiffness the physics imposter, soft object only
  23272. */
  23273. stiffness?: number;
  23274. /**
  23275. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23276. */
  23277. velocityIterations?: number;
  23278. /**
  23279. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23280. */
  23281. positionIterations?: number;
  23282. /**
  23283. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23284. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23285. * Add to fix multiple points
  23286. */
  23287. fixedPoints?: number;
  23288. /**
  23289. * The collision margin around a soft object
  23290. */
  23291. margin?: number;
  23292. /**
  23293. * The collision margin around a soft object
  23294. */
  23295. damping?: number;
  23296. /**
  23297. * The path for a rope based on an extrusion
  23298. */
  23299. path?: any;
  23300. /**
  23301. * The shape of an extrusion used for a rope based on an extrusion
  23302. */
  23303. shape?: any;
  23304. }
  23305. /**
  23306. * Interface for a physics-enabled object
  23307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23308. */
  23309. export interface IPhysicsEnabledObject {
  23310. /**
  23311. * The position of the physics-enabled object
  23312. */
  23313. position: Vector3;
  23314. /**
  23315. * The rotation of the physics-enabled object
  23316. */
  23317. rotationQuaternion: Nullable<Quaternion>;
  23318. /**
  23319. * The scale of the physics-enabled object
  23320. */
  23321. scaling: Vector3;
  23322. /**
  23323. * The rotation of the physics-enabled object
  23324. */
  23325. rotation?: Vector3;
  23326. /**
  23327. * The parent of the physics-enabled object
  23328. */
  23329. parent?: any;
  23330. /**
  23331. * The bounding info of the physics-enabled object
  23332. * @returns The bounding info of the physics-enabled object
  23333. */
  23334. getBoundingInfo(): BoundingInfo;
  23335. /**
  23336. * Computes the world matrix
  23337. * @param force Specifies if the world matrix should be computed by force
  23338. * @returns A world matrix
  23339. */
  23340. computeWorldMatrix(force: boolean): Matrix;
  23341. /**
  23342. * Gets the world matrix
  23343. * @returns A world matrix
  23344. */
  23345. getWorldMatrix?(): Matrix;
  23346. /**
  23347. * Gets the child meshes
  23348. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23349. * @returns An array of abstract meshes
  23350. */
  23351. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23352. /**
  23353. * Gets the vertex data
  23354. * @param kind The type of vertex data
  23355. * @returns A nullable array of numbers, or a float32 array
  23356. */
  23357. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23358. /**
  23359. * Gets the indices from the mesh
  23360. * @returns A nullable array of index arrays
  23361. */
  23362. getIndices?(): Nullable<IndicesArray>;
  23363. /**
  23364. * Gets the scene from the mesh
  23365. * @returns the indices array or null
  23366. */
  23367. getScene?(): Scene;
  23368. /**
  23369. * Gets the absolute position from the mesh
  23370. * @returns the absolute position
  23371. */
  23372. getAbsolutePosition(): Vector3;
  23373. /**
  23374. * Gets the absolute pivot point from the mesh
  23375. * @returns the absolute pivot point
  23376. */
  23377. getAbsolutePivotPoint(): Vector3;
  23378. /**
  23379. * Rotates the mesh
  23380. * @param axis The axis of rotation
  23381. * @param amount The amount of rotation
  23382. * @param space The space of the rotation
  23383. * @returns The rotation transform node
  23384. */
  23385. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23386. /**
  23387. * Translates the mesh
  23388. * @param axis The axis of translation
  23389. * @param distance The distance of translation
  23390. * @param space The space of the translation
  23391. * @returns The transform node
  23392. */
  23393. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23394. /**
  23395. * Sets the absolute position of the mesh
  23396. * @param absolutePosition The absolute position of the mesh
  23397. * @returns The transform node
  23398. */
  23399. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23400. /**
  23401. * Gets the class name of the mesh
  23402. * @returns The class name
  23403. */
  23404. getClassName(): string;
  23405. }
  23406. /**
  23407. * Represents a physics imposter
  23408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23409. */
  23410. export class PhysicsImpostor {
  23411. /**
  23412. * The physics-enabled object used as the physics imposter
  23413. */
  23414. object: IPhysicsEnabledObject;
  23415. /**
  23416. * The type of the physics imposter
  23417. */
  23418. type: number;
  23419. private _options;
  23420. private _scene?;
  23421. /**
  23422. * The default object size of the imposter
  23423. */
  23424. static DEFAULT_OBJECT_SIZE: Vector3;
  23425. /**
  23426. * The identity quaternion of the imposter
  23427. */
  23428. static IDENTITY_QUATERNION: Quaternion;
  23429. /** @hidden */
  23430. _pluginData: any;
  23431. private _physicsEngine;
  23432. private _physicsBody;
  23433. private _bodyUpdateRequired;
  23434. private _onBeforePhysicsStepCallbacks;
  23435. private _onAfterPhysicsStepCallbacks;
  23436. /** @hidden */
  23437. _onPhysicsCollideCallbacks: Array<{
  23438. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23439. otherImpostors: Array<PhysicsImpostor>;
  23440. }>;
  23441. private _deltaPosition;
  23442. private _deltaRotation;
  23443. private _deltaRotationConjugated;
  23444. /** @hidden */
  23445. _isFromLine: boolean;
  23446. private _parent;
  23447. private _isDisposed;
  23448. private static _tmpVecs;
  23449. private static _tmpQuat;
  23450. /**
  23451. * Specifies if the physics imposter is disposed
  23452. */
  23453. readonly isDisposed: boolean;
  23454. /**
  23455. * Gets the mass of the physics imposter
  23456. */
  23457. mass: number;
  23458. /**
  23459. * Gets the coefficient of friction
  23460. */
  23461. /**
  23462. * Sets the coefficient of friction
  23463. */
  23464. friction: number;
  23465. /**
  23466. * Gets the coefficient of restitution
  23467. */
  23468. /**
  23469. * Sets the coefficient of restitution
  23470. */
  23471. restitution: number;
  23472. /**
  23473. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23474. */
  23475. /**
  23476. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23477. */
  23478. pressure: number;
  23479. /**
  23480. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23481. */
  23482. /**
  23483. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23484. */
  23485. stiffness: number;
  23486. /**
  23487. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23488. */
  23489. /**
  23490. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23491. */
  23492. velocityIterations: number;
  23493. /**
  23494. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23495. */
  23496. /**
  23497. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23498. */
  23499. positionIterations: number;
  23500. /**
  23501. * The unique id of the physics imposter
  23502. * set by the physics engine when adding this impostor to the array
  23503. */
  23504. uniqueId: number;
  23505. /**
  23506. * @hidden
  23507. */
  23508. soft: boolean;
  23509. /**
  23510. * @hidden
  23511. */
  23512. segments: number;
  23513. private _joints;
  23514. /**
  23515. * Initializes the physics imposter
  23516. * @param object The physics-enabled object used as the physics imposter
  23517. * @param type The type of the physics imposter
  23518. * @param _options The options for the physics imposter
  23519. * @param _scene The Babylon scene
  23520. */
  23521. constructor(
  23522. /**
  23523. * The physics-enabled object used as the physics imposter
  23524. */
  23525. object: IPhysicsEnabledObject,
  23526. /**
  23527. * The type of the physics imposter
  23528. */
  23529. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23530. /**
  23531. * This function will completly initialize this impostor.
  23532. * It will create a new body - but only if this mesh has no parent.
  23533. * If it has, this impostor will not be used other than to define the impostor
  23534. * of the child mesh.
  23535. * @hidden
  23536. */
  23537. _init(): void;
  23538. private _getPhysicsParent;
  23539. /**
  23540. * Should a new body be generated.
  23541. * @returns boolean specifying if body initialization is required
  23542. */
  23543. isBodyInitRequired(): boolean;
  23544. /**
  23545. * Sets the updated scaling
  23546. * @param updated Specifies if the scaling is updated
  23547. */
  23548. setScalingUpdated(): void;
  23549. /**
  23550. * Force a regeneration of this or the parent's impostor's body.
  23551. * Use under cautious - This will remove all joints already implemented.
  23552. */
  23553. forceUpdate(): void;
  23554. /**
  23555. * Gets the body that holds this impostor. Either its own, or its parent.
  23556. */
  23557. /**
  23558. * Set the physics body. Used mainly by the physics engine/plugin
  23559. */
  23560. physicsBody: any;
  23561. /**
  23562. * Get the parent of the physics imposter
  23563. * @returns Physics imposter or null
  23564. */
  23565. /**
  23566. * Sets the parent of the physics imposter
  23567. */
  23568. parent: Nullable<PhysicsImpostor>;
  23569. /**
  23570. * Resets the update flags
  23571. */
  23572. resetUpdateFlags(): void;
  23573. /**
  23574. * Gets the object extend size
  23575. * @returns the object extend size
  23576. */
  23577. getObjectExtendSize(): Vector3;
  23578. /**
  23579. * Gets the object center
  23580. * @returns The object center
  23581. */
  23582. getObjectCenter(): Vector3;
  23583. /**
  23584. * Get a specific parametes from the options parameter
  23585. * @param paramName The object parameter name
  23586. * @returns The object parameter
  23587. */
  23588. getParam(paramName: string): any;
  23589. /**
  23590. * Sets a specific parameter in the options given to the physics plugin
  23591. * @param paramName The parameter name
  23592. * @param value The value of the parameter
  23593. */
  23594. setParam(paramName: string, value: number): void;
  23595. /**
  23596. * Specifically change the body's mass option. Won't recreate the physics body object
  23597. * @param mass The mass of the physics imposter
  23598. */
  23599. setMass(mass: number): void;
  23600. /**
  23601. * Gets the linear velocity
  23602. * @returns linear velocity or null
  23603. */
  23604. getLinearVelocity(): Nullable<Vector3>;
  23605. /**
  23606. * Sets the linear velocity
  23607. * @param velocity linear velocity or null
  23608. */
  23609. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23610. /**
  23611. * Gets the angular velocity
  23612. * @returns angular velocity or null
  23613. */
  23614. getAngularVelocity(): Nullable<Vector3>;
  23615. /**
  23616. * Sets the angular velocity
  23617. * @param velocity The velocity or null
  23618. */
  23619. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23620. /**
  23621. * Execute a function with the physics plugin native code
  23622. * Provide a function the will have two variables - the world object and the physics body object
  23623. * @param func The function to execute with the physics plugin native code
  23624. */
  23625. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23626. /**
  23627. * Register a function that will be executed before the physics world is stepping forward
  23628. * @param func The function to execute before the physics world is stepped forward
  23629. */
  23630. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23631. /**
  23632. * Unregister a function that will be executed before the physics world is stepping forward
  23633. * @param func The function to execute before the physics world is stepped forward
  23634. */
  23635. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23636. /**
  23637. * Register a function that will be executed after the physics step
  23638. * @param func The function to execute after physics step
  23639. */
  23640. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23641. /**
  23642. * Unregisters a function that will be executed after the physics step
  23643. * @param func The function to execute after physics step
  23644. */
  23645. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23646. /**
  23647. * register a function that will be executed when this impostor collides against a different body
  23648. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23649. * @param func Callback that is executed on collision
  23650. */
  23651. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23652. /**
  23653. * Unregisters the physics imposter on contact
  23654. * @param collideAgainst The physics object to collide against
  23655. * @param func Callback to execute on collision
  23656. */
  23657. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23658. private _tmpQuat;
  23659. private _tmpQuat2;
  23660. /**
  23661. * Get the parent rotation
  23662. * @returns The parent rotation
  23663. */
  23664. getParentsRotation(): Quaternion;
  23665. /**
  23666. * this function is executed by the physics engine.
  23667. */
  23668. beforeStep: () => void;
  23669. /**
  23670. * this function is executed by the physics engine
  23671. */
  23672. afterStep: () => void;
  23673. /**
  23674. * Legacy collision detection event support
  23675. */
  23676. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23677. /**
  23678. * event and body object due to cannon's event-based architecture.
  23679. */
  23680. onCollide: (e: {
  23681. body: any;
  23682. }) => void;
  23683. /**
  23684. * Apply a force
  23685. * @param force The force to apply
  23686. * @param contactPoint The contact point for the force
  23687. * @returns The physics imposter
  23688. */
  23689. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23690. /**
  23691. * Apply an impulse
  23692. * @param force The impulse force
  23693. * @param contactPoint The contact point for the impulse force
  23694. * @returns The physics imposter
  23695. */
  23696. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23697. /**
  23698. * A help function to create a joint
  23699. * @param otherImpostor A physics imposter used to create a joint
  23700. * @param jointType The type of joint
  23701. * @param jointData The data for the joint
  23702. * @returns The physics imposter
  23703. */
  23704. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23705. /**
  23706. * Add a joint to this impostor with a different impostor
  23707. * @param otherImpostor A physics imposter used to add a joint
  23708. * @param joint The joint to add
  23709. * @returns The physics imposter
  23710. */
  23711. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23712. /**
  23713. * Add an anchor to a cloth impostor
  23714. * @param otherImpostor rigid impostor to anchor to
  23715. * @param width ratio across width from 0 to 1
  23716. * @param height ratio up height from 0 to 1
  23717. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23718. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23719. * @returns impostor the soft imposter
  23720. */
  23721. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23722. /**
  23723. * Add a hook to a rope impostor
  23724. * @param otherImpostor rigid impostor to anchor to
  23725. * @param length ratio across rope from 0 to 1
  23726. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23727. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23728. * @returns impostor the rope imposter
  23729. */
  23730. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23731. /**
  23732. * Will keep this body still, in a sleep mode.
  23733. * @returns the physics imposter
  23734. */
  23735. sleep(): PhysicsImpostor;
  23736. /**
  23737. * Wake the body up.
  23738. * @returns The physics imposter
  23739. */
  23740. wakeUp(): PhysicsImpostor;
  23741. /**
  23742. * Clones the physics imposter
  23743. * @param newObject The physics imposter clones to this physics-enabled object
  23744. * @returns A nullable physics imposter
  23745. */
  23746. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23747. /**
  23748. * Disposes the physics imposter
  23749. */
  23750. dispose(): void;
  23751. /**
  23752. * Sets the delta position
  23753. * @param position The delta position amount
  23754. */
  23755. setDeltaPosition(position: Vector3): void;
  23756. /**
  23757. * Sets the delta rotation
  23758. * @param rotation The delta rotation amount
  23759. */
  23760. setDeltaRotation(rotation: Quaternion): void;
  23761. /**
  23762. * Gets the box size of the physics imposter and stores the result in the input parameter
  23763. * @param result Stores the box size
  23764. * @returns The physics imposter
  23765. */
  23766. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23767. /**
  23768. * Gets the radius of the physics imposter
  23769. * @returns Radius of the physics imposter
  23770. */
  23771. getRadius(): number;
  23772. /**
  23773. * Sync a bone with this impostor
  23774. * @param bone The bone to sync to the impostor.
  23775. * @param boneMesh The mesh that the bone is influencing.
  23776. * @param jointPivot The pivot of the joint / bone in local space.
  23777. * @param distToJoint Optional distance from the impostor to the joint.
  23778. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23779. */
  23780. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23781. /**
  23782. * Sync impostor to a bone
  23783. * @param bone The bone that the impostor will be synced to.
  23784. * @param boneMesh The mesh that the bone is influencing.
  23785. * @param jointPivot The pivot of the joint / bone in local space.
  23786. * @param distToJoint Optional distance from the impostor to the joint.
  23787. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23788. * @param boneAxis Optional vector3 axis the bone is aligned with
  23789. */
  23790. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23791. /**
  23792. * No-Imposter type
  23793. */
  23794. static NoImpostor: number;
  23795. /**
  23796. * Sphere-Imposter type
  23797. */
  23798. static SphereImpostor: number;
  23799. /**
  23800. * Box-Imposter type
  23801. */
  23802. static BoxImpostor: number;
  23803. /**
  23804. * Plane-Imposter type
  23805. */
  23806. static PlaneImpostor: number;
  23807. /**
  23808. * Mesh-imposter type
  23809. */
  23810. static MeshImpostor: number;
  23811. /**
  23812. * Capsule-Impostor type (Ammo.js plugin only)
  23813. */
  23814. static CapsuleImpostor: number;
  23815. /**
  23816. * Cylinder-Imposter type
  23817. */
  23818. static CylinderImpostor: number;
  23819. /**
  23820. * Particle-Imposter type
  23821. */
  23822. static ParticleImpostor: number;
  23823. /**
  23824. * Heightmap-Imposter type
  23825. */
  23826. static HeightmapImpostor: number;
  23827. /**
  23828. * ConvexHull-Impostor type (Ammo.js plugin only)
  23829. */
  23830. static ConvexHullImpostor: number;
  23831. /**
  23832. * Rope-Imposter type
  23833. */
  23834. static RopeImpostor: number;
  23835. /**
  23836. * Cloth-Imposter type
  23837. */
  23838. static ClothImpostor: number;
  23839. /**
  23840. * Softbody-Imposter type
  23841. */
  23842. static SoftbodyImpostor: number;
  23843. }
  23844. }
  23845. declare module "babylonjs/Meshes/mesh" {
  23846. import { Observable } from "babylonjs/Misc/observable";
  23847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23848. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23849. import { Camera } from "babylonjs/Cameras/camera";
  23850. import { Scene } from "babylonjs/scene";
  23851. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23852. import { Color4 } from "babylonjs/Maths/math.color";
  23853. import { Engine } from "babylonjs/Engines/engine";
  23854. import { Node } from "babylonjs/node";
  23855. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23856. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23857. import { Buffer } from "babylonjs/Meshes/buffer";
  23858. import { Geometry } from "babylonjs/Meshes/geometry";
  23859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23861. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23862. import { Effect } from "babylonjs/Materials/effect";
  23863. import { Material } from "babylonjs/Materials/material";
  23864. import { Skeleton } from "babylonjs/Bones/skeleton";
  23865. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23866. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23867. import { Path3D } from "babylonjs/Maths/math.path";
  23868. import { Plane } from "babylonjs/Maths/math.plane";
  23869. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23870. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23871. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23872. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23873. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23874. /**
  23875. * @hidden
  23876. **/
  23877. export class _CreationDataStorage {
  23878. closePath?: boolean;
  23879. closeArray?: boolean;
  23880. idx: number[];
  23881. dashSize: number;
  23882. gapSize: number;
  23883. path3D: Path3D;
  23884. pathArray: Vector3[][];
  23885. arc: number;
  23886. radius: number;
  23887. cap: number;
  23888. tessellation: number;
  23889. }
  23890. /**
  23891. * @hidden
  23892. **/
  23893. class _InstanceDataStorage {
  23894. visibleInstances: any;
  23895. batchCache: _InstancesBatch;
  23896. instancesBufferSize: number;
  23897. instancesBuffer: Nullable<Buffer>;
  23898. instancesData: Float32Array;
  23899. overridenInstanceCount: number;
  23900. isFrozen: boolean;
  23901. previousBatch: Nullable<_InstancesBatch>;
  23902. hardwareInstancedRendering: boolean;
  23903. sideOrientation: number;
  23904. }
  23905. /**
  23906. * @hidden
  23907. **/
  23908. export class _InstancesBatch {
  23909. mustReturn: boolean;
  23910. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23911. renderSelf: boolean[];
  23912. hardwareInstancedRendering: boolean[];
  23913. }
  23914. /**
  23915. * Class used to represent renderable models
  23916. */
  23917. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23918. /**
  23919. * Mesh side orientation : usually the external or front surface
  23920. */
  23921. static readonly FRONTSIDE: number;
  23922. /**
  23923. * Mesh side orientation : usually the internal or back surface
  23924. */
  23925. static readonly BACKSIDE: number;
  23926. /**
  23927. * Mesh side orientation : both internal and external or front and back surfaces
  23928. */
  23929. static readonly DOUBLESIDE: number;
  23930. /**
  23931. * Mesh side orientation : by default, `FRONTSIDE`
  23932. */
  23933. static readonly DEFAULTSIDE: number;
  23934. /**
  23935. * Mesh cap setting : no cap
  23936. */
  23937. static readonly NO_CAP: number;
  23938. /**
  23939. * Mesh cap setting : one cap at the beginning of the mesh
  23940. */
  23941. static readonly CAP_START: number;
  23942. /**
  23943. * Mesh cap setting : one cap at the end of the mesh
  23944. */
  23945. static readonly CAP_END: number;
  23946. /**
  23947. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23948. */
  23949. static readonly CAP_ALL: number;
  23950. /**
  23951. * Mesh pattern setting : no flip or rotate
  23952. */
  23953. static readonly NO_FLIP: number;
  23954. /**
  23955. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23956. */
  23957. static readonly FLIP_TILE: number;
  23958. /**
  23959. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23960. */
  23961. static readonly ROTATE_TILE: number;
  23962. /**
  23963. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23964. */
  23965. static readonly FLIP_ROW: number;
  23966. /**
  23967. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23968. */
  23969. static readonly ROTATE_ROW: number;
  23970. /**
  23971. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23972. */
  23973. static readonly FLIP_N_ROTATE_TILE: number;
  23974. /**
  23975. * Mesh pattern setting : rotate pattern and rotate
  23976. */
  23977. static readonly FLIP_N_ROTATE_ROW: number;
  23978. /**
  23979. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23980. */
  23981. static readonly CENTER: number;
  23982. /**
  23983. * Mesh tile positioning : part tiles on left
  23984. */
  23985. static readonly LEFT: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles on right
  23988. */
  23989. static readonly RIGHT: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on top
  23992. */
  23993. static readonly TOP: number;
  23994. /**
  23995. * Mesh tile positioning : part tiles on bottom
  23996. */
  23997. static readonly BOTTOM: number;
  23998. /**
  23999. * Gets the default side orientation.
  24000. * @param orientation the orientation to value to attempt to get
  24001. * @returns the default orientation
  24002. * @hidden
  24003. */
  24004. static _GetDefaultSideOrientation(orientation?: number): number;
  24005. private _internalMeshDataInfo;
  24006. /**
  24007. * An event triggered before rendering the mesh
  24008. */
  24009. readonly onBeforeRenderObservable: Observable<Mesh>;
  24010. /**
  24011. * An event triggered before binding the mesh
  24012. */
  24013. readonly onBeforeBindObservable: Observable<Mesh>;
  24014. /**
  24015. * An event triggered after rendering the mesh
  24016. */
  24017. readonly onAfterRenderObservable: Observable<Mesh>;
  24018. /**
  24019. * An event triggered before drawing the mesh
  24020. */
  24021. readonly onBeforeDrawObservable: Observable<Mesh>;
  24022. private _onBeforeDrawObserver;
  24023. /**
  24024. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24025. */
  24026. onBeforeDraw: () => void;
  24027. /**
  24028. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24029. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24030. */
  24031. delayLoadState: number;
  24032. /**
  24033. * Gets the list of instances created from this mesh
  24034. * it is not supposed to be modified manually.
  24035. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24036. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24037. */
  24038. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24039. /**
  24040. * Gets the file containing delay loading data for this mesh
  24041. */
  24042. delayLoadingFile: string;
  24043. /** @hidden */
  24044. _binaryInfo: any;
  24045. /**
  24046. * User defined function used to change how LOD level selection is done
  24047. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24048. */
  24049. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24050. /**
  24051. * Gets or sets the morph target manager
  24052. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24053. */
  24054. morphTargetManager: Nullable<MorphTargetManager>;
  24055. /** @hidden */
  24056. _creationDataStorage: Nullable<_CreationDataStorage>;
  24057. /** @hidden */
  24058. _geometry: Nullable<Geometry>;
  24059. /** @hidden */
  24060. _delayInfo: Array<string>;
  24061. /** @hidden */
  24062. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24063. /** @hidden */
  24064. _instanceDataStorage: _InstanceDataStorage;
  24065. private _effectiveMaterial;
  24066. /** @hidden */
  24067. _shouldGenerateFlatShading: boolean;
  24068. /** @hidden */
  24069. _originalBuilderSideOrientation: number;
  24070. /**
  24071. * Use this property to change the original side orientation defined at construction time
  24072. */
  24073. overrideMaterialSideOrientation: Nullable<number>;
  24074. /**
  24075. * Gets the source mesh (the one used to clone this one from)
  24076. */
  24077. readonly source: Nullable<Mesh>;
  24078. /**
  24079. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24080. */
  24081. isUnIndexed: boolean;
  24082. /**
  24083. * @constructor
  24084. * @param name The value used by scene.getMeshByName() to do a lookup.
  24085. * @param scene The scene to add this mesh to.
  24086. * @param parent The parent of this mesh, if it has one
  24087. * @param source An optional Mesh from which geometry is shared, cloned.
  24088. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24089. * When false, achieved by calling a clone(), also passing False.
  24090. * This will make creation of children, recursive.
  24091. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24092. */
  24093. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24094. /**
  24095. * Gets the class name
  24096. * @returns the string "Mesh".
  24097. */
  24098. getClassName(): string;
  24099. /** @hidden */
  24100. readonly _isMesh: boolean;
  24101. /**
  24102. * Returns a description of this mesh
  24103. * @param fullDetails define if full details about this mesh must be used
  24104. * @returns a descriptive string representing this mesh
  24105. */
  24106. toString(fullDetails?: boolean): string;
  24107. /** @hidden */
  24108. _unBindEffect(): void;
  24109. /**
  24110. * Gets a boolean indicating if this mesh has LOD
  24111. */
  24112. readonly hasLODLevels: boolean;
  24113. /**
  24114. * Gets the list of MeshLODLevel associated with the current mesh
  24115. * @returns an array of MeshLODLevel
  24116. */
  24117. getLODLevels(): MeshLODLevel[];
  24118. private _sortLODLevels;
  24119. /**
  24120. * Add a mesh as LOD level triggered at the given distance.
  24121. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24122. * @param distance The distance from the center of the object to show this level
  24123. * @param mesh The mesh to be added as LOD level (can be null)
  24124. * @return This mesh (for chaining)
  24125. */
  24126. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24127. /**
  24128. * Returns the LOD level mesh at the passed distance or null if not found.
  24129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24130. * @param distance The distance from the center of the object to show this level
  24131. * @returns a Mesh or `null`
  24132. */
  24133. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24134. /**
  24135. * Remove a mesh from the LOD array
  24136. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24137. * @param mesh defines the mesh to be removed
  24138. * @return This mesh (for chaining)
  24139. */
  24140. removeLODLevel(mesh: Mesh): Mesh;
  24141. /**
  24142. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24144. * @param camera defines the camera to use to compute distance
  24145. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24146. * @return This mesh (for chaining)
  24147. */
  24148. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24149. /**
  24150. * Gets the mesh internal Geometry object
  24151. */
  24152. readonly geometry: Nullable<Geometry>;
  24153. /**
  24154. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24155. * @returns the total number of vertices
  24156. */
  24157. getTotalVertices(): number;
  24158. /**
  24159. * Returns the content of an associated vertex buffer
  24160. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24161. * - VertexBuffer.PositionKind
  24162. * - VertexBuffer.UVKind
  24163. * - VertexBuffer.UV2Kind
  24164. * - VertexBuffer.UV3Kind
  24165. * - VertexBuffer.UV4Kind
  24166. * - VertexBuffer.UV5Kind
  24167. * - VertexBuffer.UV6Kind
  24168. * - VertexBuffer.ColorKind
  24169. * - VertexBuffer.MatricesIndicesKind
  24170. * - VertexBuffer.MatricesIndicesExtraKind
  24171. * - VertexBuffer.MatricesWeightsKind
  24172. * - VertexBuffer.MatricesWeightsExtraKind
  24173. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24174. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24175. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24176. */
  24177. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24178. /**
  24179. * Returns the mesh VertexBuffer object from the requested `kind`
  24180. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24181. * - VertexBuffer.PositionKind
  24182. * - VertexBuffer.NormalKind
  24183. * - VertexBuffer.UVKind
  24184. * - VertexBuffer.UV2Kind
  24185. * - VertexBuffer.UV3Kind
  24186. * - VertexBuffer.UV4Kind
  24187. * - VertexBuffer.UV5Kind
  24188. * - VertexBuffer.UV6Kind
  24189. * - VertexBuffer.ColorKind
  24190. * - VertexBuffer.MatricesIndicesKind
  24191. * - VertexBuffer.MatricesIndicesExtraKind
  24192. * - VertexBuffer.MatricesWeightsKind
  24193. * - VertexBuffer.MatricesWeightsExtraKind
  24194. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24195. */
  24196. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24197. /**
  24198. * Tests if a specific vertex buffer is associated with this mesh
  24199. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24200. * - VertexBuffer.PositionKind
  24201. * - VertexBuffer.NormalKind
  24202. * - VertexBuffer.UVKind
  24203. * - VertexBuffer.UV2Kind
  24204. * - VertexBuffer.UV3Kind
  24205. * - VertexBuffer.UV4Kind
  24206. * - VertexBuffer.UV5Kind
  24207. * - VertexBuffer.UV6Kind
  24208. * - VertexBuffer.ColorKind
  24209. * - VertexBuffer.MatricesIndicesKind
  24210. * - VertexBuffer.MatricesIndicesExtraKind
  24211. * - VertexBuffer.MatricesWeightsKind
  24212. * - VertexBuffer.MatricesWeightsExtraKind
  24213. * @returns a boolean
  24214. */
  24215. isVerticesDataPresent(kind: string): boolean;
  24216. /**
  24217. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24218. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24219. * - VertexBuffer.PositionKind
  24220. * - VertexBuffer.UVKind
  24221. * - VertexBuffer.UV2Kind
  24222. * - VertexBuffer.UV3Kind
  24223. * - VertexBuffer.UV4Kind
  24224. * - VertexBuffer.UV5Kind
  24225. * - VertexBuffer.UV6Kind
  24226. * - VertexBuffer.ColorKind
  24227. * - VertexBuffer.MatricesIndicesKind
  24228. * - VertexBuffer.MatricesIndicesExtraKind
  24229. * - VertexBuffer.MatricesWeightsKind
  24230. * - VertexBuffer.MatricesWeightsExtraKind
  24231. * @returns a boolean
  24232. */
  24233. isVertexBufferUpdatable(kind: string): boolean;
  24234. /**
  24235. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24236. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24237. * - VertexBuffer.PositionKind
  24238. * - VertexBuffer.NormalKind
  24239. * - VertexBuffer.UVKind
  24240. * - VertexBuffer.UV2Kind
  24241. * - VertexBuffer.UV3Kind
  24242. * - VertexBuffer.UV4Kind
  24243. * - VertexBuffer.UV5Kind
  24244. * - VertexBuffer.UV6Kind
  24245. * - VertexBuffer.ColorKind
  24246. * - VertexBuffer.MatricesIndicesKind
  24247. * - VertexBuffer.MatricesIndicesExtraKind
  24248. * - VertexBuffer.MatricesWeightsKind
  24249. * - VertexBuffer.MatricesWeightsExtraKind
  24250. * @returns an array of strings
  24251. */
  24252. getVerticesDataKinds(): string[];
  24253. /**
  24254. * Returns a positive integer : the total number of indices in this mesh geometry.
  24255. * @returns the numner of indices or zero if the mesh has no geometry.
  24256. */
  24257. getTotalIndices(): number;
  24258. /**
  24259. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24260. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24262. * @returns the indices array or an empty array if the mesh has no geometry
  24263. */
  24264. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24265. readonly isBlocked: boolean;
  24266. /**
  24267. * Determine if the current mesh is ready to be rendered
  24268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24269. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24270. * @returns true if all associated assets are ready (material, textures, shaders)
  24271. */
  24272. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24273. /**
  24274. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24275. */
  24276. readonly areNormalsFrozen: boolean;
  24277. /**
  24278. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24279. * @returns the current mesh
  24280. */
  24281. freezeNormals(): Mesh;
  24282. /**
  24283. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24284. * @returns the current mesh
  24285. */
  24286. unfreezeNormals(): Mesh;
  24287. /**
  24288. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24289. */
  24290. overridenInstanceCount: number;
  24291. /** @hidden */
  24292. _preActivate(): Mesh;
  24293. /** @hidden */
  24294. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24295. /** @hidden */
  24296. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24297. /**
  24298. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24299. * This means the mesh underlying bounding box and sphere are recomputed.
  24300. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24301. * @returns the current mesh
  24302. */
  24303. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24304. /** @hidden */
  24305. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24306. /**
  24307. * This function will subdivide the mesh into multiple submeshes
  24308. * @param count defines the expected number of submeshes
  24309. */
  24310. subdivide(count: number): void;
  24311. /**
  24312. * Copy a FloatArray into a specific associated vertex buffer
  24313. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24314. * - VertexBuffer.PositionKind
  24315. * - VertexBuffer.UVKind
  24316. * - VertexBuffer.UV2Kind
  24317. * - VertexBuffer.UV3Kind
  24318. * - VertexBuffer.UV4Kind
  24319. * - VertexBuffer.UV5Kind
  24320. * - VertexBuffer.UV6Kind
  24321. * - VertexBuffer.ColorKind
  24322. * - VertexBuffer.MatricesIndicesKind
  24323. * - VertexBuffer.MatricesIndicesExtraKind
  24324. * - VertexBuffer.MatricesWeightsKind
  24325. * - VertexBuffer.MatricesWeightsExtraKind
  24326. * @param data defines the data source
  24327. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24328. * @param stride defines the data stride size (can be null)
  24329. * @returns the current mesh
  24330. */
  24331. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24332. /**
  24333. * Flags an associated vertex buffer as updatable
  24334. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24335. * - VertexBuffer.PositionKind
  24336. * - VertexBuffer.UVKind
  24337. * - VertexBuffer.UV2Kind
  24338. * - VertexBuffer.UV3Kind
  24339. * - VertexBuffer.UV4Kind
  24340. * - VertexBuffer.UV5Kind
  24341. * - VertexBuffer.UV6Kind
  24342. * - VertexBuffer.ColorKind
  24343. * - VertexBuffer.MatricesIndicesKind
  24344. * - VertexBuffer.MatricesIndicesExtraKind
  24345. * - VertexBuffer.MatricesWeightsKind
  24346. * - VertexBuffer.MatricesWeightsExtraKind
  24347. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24348. */
  24349. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24350. /**
  24351. * Sets the mesh global Vertex Buffer
  24352. * @param buffer defines the buffer to use
  24353. * @returns the current mesh
  24354. */
  24355. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24356. /**
  24357. * Update a specific associated vertex buffer
  24358. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.UVKind
  24361. * - VertexBuffer.UV2Kind
  24362. * - VertexBuffer.UV3Kind
  24363. * - VertexBuffer.UV4Kind
  24364. * - VertexBuffer.UV5Kind
  24365. * - VertexBuffer.UV6Kind
  24366. * - VertexBuffer.ColorKind
  24367. * - VertexBuffer.MatricesIndicesKind
  24368. * - VertexBuffer.MatricesIndicesExtraKind
  24369. * - VertexBuffer.MatricesWeightsKind
  24370. * - VertexBuffer.MatricesWeightsExtraKind
  24371. * @param data defines the data source
  24372. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24373. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24374. * @returns the current mesh
  24375. */
  24376. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24377. /**
  24378. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24379. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24380. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24381. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24382. * @returns the current mesh
  24383. */
  24384. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24385. /**
  24386. * Creates a un-shared specific occurence of the geometry for the mesh.
  24387. * @returns the current mesh
  24388. */
  24389. makeGeometryUnique(): Mesh;
  24390. /**
  24391. * Set the index buffer of this mesh
  24392. * @param indices defines the source data
  24393. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24394. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24395. * @returns the current mesh
  24396. */
  24397. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24398. /**
  24399. * Update the current index buffer
  24400. * @param indices defines the source data
  24401. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24402. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24403. * @returns the current mesh
  24404. */
  24405. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24406. /**
  24407. * Invert the geometry to move from a right handed system to a left handed one.
  24408. * @returns the current mesh
  24409. */
  24410. toLeftHanded(): Mesh;
  24411. /** @hidden */
  24412. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24413. /** @hidden */
  24414. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24415. /**
  24416. * Registers for this mesh a javascript function called just before the rendering process
  24417. * @param func defines the function to call before rendering this mesh
  24418. * @returns the current mesh
  24419. */
  24420. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24421. /**
  24422. * Disposes a previously registered javascript function called before the rendering
  24423. * @param func defines the function to remove
  24424. * @returns the current mesh
  24425. */
  24426. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24427. /**
  24428. * Registers for this mesh a javascript function called just after the rendering is complete
  24429. * @param func defines the function to call after rendering this mesh
  24430. * @returns the current mesh
  24431. */
  24432. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24433. /**
  24434. * Disposes a previously registered javascript function called after the rendering.
  24435. * @param func defines the function to remove
  24436. * @returns the current mesh
  24437. */
  24438. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24439. /** @hidden */
  24440. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24441. /** @hidden */
  24442. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24443. /** @hidden */
  24444. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24445. /** @hidden */
  24446. _rebuild(): void;
  24447. /** @hidden */
  24448. _freeze(): void;
  24449. /** @hidden */
  24450. _unFreeze(): void;
  24451. /**
  24452. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24453. * @param subMesh defines the subMesh to render
  24454. * @param enableAlphaMode defines if alpha mode can be changed
  24455. * @returns the current mesh
  24456. */
  24457. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24458. private _onBeforeDraw;
  24459. /**
  24460. * Renormalize the mesh and patch it up if there are no weights
  24461. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24462. * However in the case of zero weights then we set just a single influence to 1.
  24463. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24464. */
  24465. cleanMatrixWeights(): void;
  24466. private normalizeSkinFourWeights;
  24467. private normalizeSkinWeightsAndExtra;
  24468. /**
  24469. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24470. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24471. * the user know there was an issue with importing the mesh
  24472. * @returns a validation object with skinned, valid and report string
  24473. */
  24474. validateSkinning(): {
  24475. skinned: boolean;
  24476. valid: boolean;
  24477. report: string;
  24478. };
  24479. /** @hidden */
  24480. _checkDelayState(): Mesh;
  24481. private _queueLoad;
  24482. /**
  24483. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24484. * A mesh is in the frustum if its bounding box intersects the frustum
  24485. * @param frustumPlanes defines the frustum to test
  24486. * @returns true if the mesh is in the frustum planes
  24487. */
  24488. isInFrustum(frustumPlanes: Plane[]): boolean;
  24489. /**
  24490. * Sets the mesh material by the material or multiMaterial `id` property
  24491. * @param id is a string identifying the material or the multiMaterial
  24492. * @returns the current mesh
  24493. */
  24494. setMaterialByID(id: string): Mesh;
  24495. /**
  24496. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24497. * @returns an array of IAnimatable
  24498. */
  24499. getAnimatables(): IAnimatable[];
  24500. /**
  24501. * Modifies the mesh geometry according to the passed transformation matrix.
  24502. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24503. * The mesh normals are modified using the same transformation.
  24504. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24505. * @param transform defines the transform matrix to use
  24506. * @see http://doc.babylonjs.com/resources/baking_transformations
  24507. * @returns the current mesh
  24508. */
  24509. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24510. /**
  24511. * Modifies the mesh geometry according to its own current World Matrix.
  24512. * The mesh World Matrix is then reset.
  24513. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24514. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24515. * @see http://doc.babylonjs.com/resources/baking_transformations
  24516. * @returns the current mesh
  24517. */
  24518. bakeCurrentTransformIntoVertices(): Mesh;
  24519. /** @hidden */
  24520. readonly _positions: Nullable<Vector3[]>;
  24521. /** @hidden */
  24522. _resetPointsArrayCache(): Mesh;
  24523. /** @hidden */
  24524. _generatePointsArray(): boolean;
  24525. /**
  24526. * Returns a new Mesh object generated from the current mesh properties.
  24527. * This method must not get confused with createInstance()
  24528. * @param name is a string, the name given to the new mesh
  24529. * @param newParent can be any Node object (default `null`)
  24530. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24531. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24532. * @returns a new mesh
  24533. */
  24534. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24535. /**
  24536. * Releases resources associated with this mesh.
  24537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24539. */
  24540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24541. /**
  24542. * Modifies the mesh geometry according to a displacement map.
  24543. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24544. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24545. * @param url is a string, the URL from the image file is to be downloaded.
  24546. * @param minHeight is the lower limit of the displacement.
  24547. * @param maxHeight is the upper limit of the displacement.
  24548. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24549. * @param uvOffset is an optional vector2 used to offset UV.
  24550. * @param uvScale is an optional vector2 used to scale UV.
  24551. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24552. * @returns the Mesh.
  24553. */
  24554. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24555. /**
  24556. * Modifies the mesh geometry according to a displacementMap buffer.
  24557. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24558. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24559. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24560. * @param heightMapWidth is the width of the buffer image.
  24561. * @param heightMapHeight is the height of the buffer image.
  24562. * @param minHeight is the lower limit of the displacement.
  24563. * @param maxHeight is the upper limit of the displacement.
  24564. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24565. * @param uvOffset is an optional vector2 used to offset UV.
  24566. * @param uvScale is an optional vector2 used to scale UV.
  24567. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24568. * @returns the Mesh.
  24569. */
  24570. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24571. /**
  24572. * Modify the mesh to get a flat shading rendering.
  24573. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24574. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24575. * @returns current mesh
  24576. */
  24577. convertToFlatShadedMesh(): Mesh;
  24578. /**
  24579. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24580. * In other words, more vertices, no more indices and a single bigger VBO.
  24581. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24582. * @returns current mesh
  24583. */
  24584. convertToUnIndexedMesh(): Mesh;
  24585. /**
  24586. * Inverses facet orientations.
  24587. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24588. * @param flipNormals will also inverts the normals
  24589. * @returns current mesh
  24590. */
  24591. flipFaces(flipNormals?: boolean): Mesh;
  24592. /**
  24593. * Increase the number of facets and hence vertices in a mesh
  24594. * Vertex normals are interpolated from existing vertex normals
  24595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24596. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24597. */
  24598. increaseVertices(numberPerEdge: number): void;
  24599. /**
  24600. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24601. * This will undo any application of covertToFlatShadedMesh
  24602. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24603. */
  24604. forceSharedVertices(): void;
  24605. /** @hidden */
  24606. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24607. /** @hidden */
  24608. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24609. /**
  24610. * Creates a new InstancedMesh object from the mesh model.
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24612. * @param name defines the name of the new instance
  24613. * @returns a new InstancedMesh
  24614. */
  24615. createInstance(name: string): InstancedMesh;
  24616. /**
  24617. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24618. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24619. * @returns the current mesh
  24620. */
  24621. synchronizeInstances(): Mesh;
  24622. /**
  24623. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24624. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24625. * This should be used together with the simplification to avoid disappearing triangles.
  24626. * @param successCallback an optional success callback to be called after the optimization finished.
  24627. * @returns the current mesh
  24628. */
  24629. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24630. /**
  24631. * Serialize current mesh
  24632. * @param serializationObject defines the object which will receive the serialization data
  24633. */
  24634. serialize(serializationObject: any): void;
  24635. /** @hidden */
  24636. _syncGeometryWithMorphTargetManager(): void;
  24637. /** @hidden */
  24638. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24639. /**
  24640. * Returns a new Mesh object parsed from the source provided.
  24641. * @param parsedMesh is the source
  24642. * @param scene defines the hosting scene
  24643. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24644. * @returns a new Mesh
  24645. */
  24646. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24647. /**
  24648. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24650. * @param name defines the name of the mesh to create
  24651. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24652. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24653. * @param closePath creates a seam between the first and the last points of each path of the path array
  24654. * @param offset is taken in account only if the `pathArray` is containing a single path
  24655. * @param scene defines the hosting scene
  24656. * @param updatable defines if the mesh must be flagged as updatable
  24657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24658. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24659. * @returns a new Mesh
  24660. */
  24661. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24662. /**
  24663. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24664. * @param name defines the name of the mesh to create
  24665. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24666. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24667. * @param scene defines the hosting scene
  24668. * @param updatable defines if the mesh must be flagged as updatable
  24669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24670. * @returns a new Mesh
  24671. */
  24672. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24673. /**
  24674. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24675. * @param name defines the name of the mesh to create
  24676. * @param size sets the size (float) of each box side (default 1)
  24677. * @param scene defines the hosting scene
  24678. * @param updatable defines if the mesh must be flagged as updatable
  24679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24680. * @returns a new Mesh
  24681. */
  24682. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24683. /**
  24684. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24685. * @param name defines the name of the mesh to create
  24686. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24687. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24694. /**
  24695. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24698. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24699. * @param scene defines the hosting scene
  24700. * @returns a new Mesh
  24701. */
  24702. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24703. /**
  24704. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24705. * @param name defines the name of the mesh to create
  24706. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24707. * @param diameterTop set the top cap diameter (floats, default 1)
  24708. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24709. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24710. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24711. * @param scene defines the hosting scene
  24712. * @param updatable defines if the mesh must be flagged as updatable
  24713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24714. * @returns a new Mesh
  24715. */
  24716. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24717. /**
  24718. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24719. * @param name defines the name of the mesh to create
  24720. * @param diameter sets the diameter size (float) of the torus (default 1)
  24721. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24722. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24723. * @param scene defines the hosting scene
  24724. * @param updatable defines if the mesh must be flagged as updatable
  24725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24726. * @returns a new Mesh
  24727. */
  24728. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24729. /**
  24730. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24731. * @param name defines the name of the mesh to create
  24732. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24733. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24734. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24735. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24736. * @param p the number of windings on X axis (positive integers, default 2)
  24737. * @param q the number of windings on Y axis (positive integers, default 3)
  24738. * @param scene defines the hosting scene
  24739. * @param updatable defines if the mesh must be flagged as updatable
  24740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24741. * @returns a new Mesh
  24742. */
  24743. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24744. /**
  24745. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24746. * @param name defines the name of the mesh to create
  24747. * @param points is an array successive Vector3
  24748. * @param scene defines the hosting scene
  24749. * @param updatable defines if the mesh must be flagged as updatable
  24750. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24751. * @returns a new Mesh
  24752. */
  24753. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24754. /**
  24755. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24756. * @param name defines the name of the mesh to create
  24757. * @param points is an array successive Vector3
  24758. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24759. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24760. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24761. * @param scene defines the hosting scene
  24762. * @param updatable defines if the mesh must be flagged as updatable
  24763. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24764. * @returns a new Mesh
  24765. */
  24766. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24767. /**
  24768. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24769. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24770. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  24771. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24772. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24773. * Remember you can only change the shape positions, not their number when updating a polygon.
  24774. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24775. * @param name defines the name of the mesh to create
  24776. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24777. * @param scene defines the hosting scene
  24778. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24779. * @param updatable defines if the mesh must be flagged as updatable
  24780. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24781. * @param earcutInjection can be used to inject your own earcut reference
  24782. * @returns a new Mesh
  24783. */
  24784. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24785. /**
  24786. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24787. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24788. * @param name defines the name of the mesh to create
  24789. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24790. * @param depth defines the height of extrusion
  24791. * @param scene defines the hosting scene
  24792. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24795. * @param earcutInjection can be used to inject your own earcut reference
  24796. * @returns a new Mesh
  24797. */
  24798. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24799. /**
  24800. * Creates an extruded shape mesh.
  24801. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24802. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24803. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24804. * @param name defines the name of the mesh to create
  24805. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24806. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24807. * @param scale is the value to scale the shape
  24808. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  24809. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24810. * @param scene defines the hosting scene
  24811. * @param updatable defines if the mesh must be flagged as updatable
  24812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24813. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24814. * @returns a new Mesh
  24815. */
  24816. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24817. /**
  24818. * Creates an custom extruded shape mesh.
  24819. * The custom extrusion is a parametric shape.
  24820. * It has no predefined shape. Its final shape will depend on the input parameters.
  24821. * Please consider using the same method from the MeshBuilder class instead
  24822. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24823. * @param name defines the name of the mesh to create
  24824. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24825. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24826. * @param scaleFunction is a custom Javascript function called on each path point
  24827. * @param rotationFunction is a custom Javascript function called on each path point
  24828. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24829. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24830. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24831. * @param scene defines the hosting scene
  24832. * @param updatable defines if the mesh must be flagged as updatable
  24833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24834. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  24835. * @returns a new Mesh
  24836. */
  24837. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24838. /**
  24839. * Creates lathe mesh.
  24840. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24841. * Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  24844. * @param radius is the radius value of the lathe
  24845. * @param tessellation is the side number of the lathe.
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24849. * @returns a new Mesh
  24850. */
  24851. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24852. /**
  24853. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24854. * @param name defines the name of the mesh to create
  24855. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24856. * @param scene defines the hosting scene
  24857. * @param updatable defines if the mesh must be flagged as updatable
  24858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24859. * @returns a new Mesh
  24860. */
  24861. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24862. /**
  24863. * Creates a ground mesh.
  24864. * Please consider using the same method from the MeshBuilder class instead
  24865. * @param name defines the name of the mesh to create
  24866. * @param width set the width of the ground
  24867. * @param height set the height of the ground
  24868. * @param subdivisions sets the number of subdivisions per side
  24869. * @param scene defines the hosting scene
  24870. * @param updatable defines if the mesh must be flagged as updatable
  24871. * @returns a new Mesh
  24872. */
  24873. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24874. /**
  24875. * Creates a tiled ground mesh.
  24876. * Please consider using the same method from the MeshBuilder class instead
  24877. * @param name defines the name of the mesh to create
  24878. * @param xmin set the ground minimum X coordinate
  24879. * @param zmin set the ground minimum Y coordinate
  24880. * @param xmax set the ground maximum X coordinate
  24881. * @param zmax set the ground maximum Z coordinate
  24882. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  24883. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  24884. * @param scene defines the hosting scene
  24885. * @param updatable defines if the mesh must be flagged as updatable
  24886. * @returns a new Mesh
  24887. */
  24888. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24889. w: number;
  24890. h: number;
  24891. }, precision: {
  24892. w: number;
  24893. h: number;
  24894. }, scene: Scene, updatable?: boolean): Mesh;
  24895. /**
  24896. * Creates a ground mesh from a height map.
  24897. * Please consider using the same method from the MeshBuilder class instead
  24898. * @see http://doc.babylonjs.com/babylon101/height_map
  24899. * @param name defines the name of the mesh to create
  24900. * @param url sets the URL of the height map image resource
  24901. * @param width set the ground width size
  24902. * @param height set the ground height size
  24903. * @param subdivisions sets the number of subdivision per side
  24904. * @param minHeight is the minimum altitude on the ground
  24905. * @param maxHeight is the maximum altitude on the ground
  24906. * @param scene defines the hosting scene
  24907. * @param updatable defines if the mesh must be flagged as updatable
  24908. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24909. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24910. * @returns a new Mesh
  24911. */
  24912. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  24913. /**
  24914. * Creates a tube mesh.
  24915. * The tube is a parametric shape.
  24916. * It has no predefined shape. Its final shape will depend on the input parameters.
  24917. * Please consider using the same method from the MeshBuilder class instead
  24918. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24919. * @param name defines the name of the mesh to create
  24920. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24921. * @param radius sets the tube radius size
  24922. * @param tessellation is the number of sides on the tubular surface
  24923. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  24924. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24925. * @param scene defines the hosting scene
  24926. * @param updatable defines if the mesh must be flagged as updatable
  24927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24928. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24932. (i: number, distance: number): number;
  24933. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24934. /**
  24935. * Creates a polyhedron mesh.
  24936. * Please consider using the same method from the MeshBuilder class instead.
  24937. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  24938. * * The parameter `size` (positive float, default 1) sets the polygon size
  24939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24940. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  24941. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  24942. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  24943. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24944. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  24945. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24948. * @param name defines the name of the mesh to create
  24949. * @param options defines the options used to create the mesh
  24950. * @param scene defines the hosting scene
  24951. * @returns a new Mesh
  24952. */
  24953. static CreatePolyhedron(name: string, options: {
  24954. type?: number;
  24955. size?: number;
  24956. sizeX?: number;
  24957. sizeY?: number;
  24958. sizeZ?: number;
  24959. custom?: any;
  24960. faceUV?: Vector4[];
  24961. faceColors?: Color4[];
  24962. updatable?: boolean;
  24963. sideOrientation?: number;
  24964. }, scene: Scene): Mesh;
  24965. /**
  24966. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24967. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24968. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  24969. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24970. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  24971. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24974. * @param name defines the name of the mesh
  24975. * @param options defines the options used to create the mesh
  24976. * @param scene defines the hosting scene
  24977. * @returns a new Mesh
  24978. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24979. */
  24980. static CreateIcoSphere(name: string, options: {
  24981. radius?: number;
  24982. flat?: boolean;
  24983. subdivisions?: number;
  24984. sideOrientation?: number;
  24985. updatable?: boolean;
  24986. }, scene: Scene): Mesh;
  24987. /**
  24988. * Creates a decal mesh.
  24989. * Please consider using the same method from the MeshBuilder class instead.
  24990. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24991. * @param name defines the name of the mesh
  24992. * @param sourceMesh defines the mesh receiving the decal
  24993. * @param position sets the position of the decal in world coordinates
  24994. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24995. * @param size sets the decal scaling
  24996. * @param angle sets the angle to rotate the decal
  24997. * @returns a new Mesh
  24998. */
  24999. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25000. /**
  25001. * Prepare internal position array for software CPU skinning
  25002. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25003. */
  25004. setPositionsForCPUSkinning(): Float32Array;
  25005. /**
  25006. * Prepare internal normal array for software CPU skinning
  25007. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25008. */
  25009. setNormalsForCPUSkinning(): Float32Array;
  25010. /**
  25011. * Updates the vertex buffer by applying transformation from the bones
  25012. * @param skeleton defines the skeleton to apply to current mesh
  25013. * @returns the current mesh
  25014. */
  25015. applySkeleton(skeleton: Skeleton): Mesh;
  25016. /**
  25017. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25018. * @param meshes defines the list of meshes to scan
  25019. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25020. */
  25021. static MinMax(meshes: AbstractMesh[]): {
  25022. min: Vector3;
  25023. max: Vector3;
  25024. };
  25025. /**
  25026. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25027. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25028. * @returns a vector3
  25029. */
  25030. static Center(meshesOrMinMaxVector: {
  25031. min: Vector3;
  25032. max: Vector3;
  25033. } | AbstractMesh[]): Vector3;
  25034. /**
  25035. * Merge the array of meshes into a single mesh for performance reasons.
  25036. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25037. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25038. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25039. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25040. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25041. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25042. * @returns a new mesh
  25043. */
  25044. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25045. /** @hidden */
  25046. addInstance(instance: InstancedMesh): void;
  25047. /** @hidden */
  25048. removeInstance(instance: InstancedMesh): void;
  25049. }
  25050. }
  25051. declare module "babylonjs/Cameras/camera" {
  25052. import { SmartArray } from "babylonjs/Misc/smartArray";
  25053. import { Observable } from "babylonjs/Misc/observable";
  25054. import { Nullable } from "babylonjs/types";
  25055. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25056. import { Scene } from "babylonjs/scene";
  25057. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25058. import { Node } from "babylonjs/node";
  25059. import { Mesh } from "babylonjs/Meshes/mesh";
  25060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25061. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25062. import { Viewport } from "babylonjs/Maths/math.viewport";
  25063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25064. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25065. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25066. import { Ray } from "babylonjs/Culling/ray";
  25067. /**
  25068. * This is the base class of all the camera used in the application.
  25069. * @see http://doc.babylonjs.com/features/cameras
  25070. */
  25071. export class Camera extends Node {
  25072. /** @hidden */
  25073. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25074. /**
  25075. * This is the default projection mode used by the cameras.
  25076. * It helps recreating a feeling of perspective and better appreciate depth.
  25077. * This is the best way to simulate real life cameras.
  25078. */
  25079. static readonly PERSPECTIVE_CAMERA: number;
  25080. /**
  25081. * This helps creating camera with an orthographic mode.
  25082. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25083. */
  25084. static readonly ORTHOGRAPHIC_CAMERA: number;
  25085. /**
  25086. * This is the default FOV mode for perspective cameras.
  25087. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25088. */
  25089. static readonly FOVMODE_VERTICAL_FIXED: number;
  25090. /**
  25091. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25092. */
  25093. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25094. /**
  25095. * This specifies ther is no need for a camera rig.
  25096. * Basically only one eye is rendered corresponding to the camera.
  25097. */
  25098. static readonly RIG_MODE_NONE: number;
  25099. /**
  25100. * Simulates a camera Rig with one blue eye and one red eye.
  25101. * This can be use with 3d blue and red glasses.
  25102. */
  25103. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25104. /**
  25105. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25106. */
  25107. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25108. /**
  25109. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25112. /**
  25113. * Defines that both eyes of the camera will be rendered over under each other.
  25114. */
  25115. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25116. /**
  25117. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25118. */
  25119. static readonly RIG_MODE_VR: number;
  25120. /**
  25121. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25122. */
  25123. static readonly RIG_MODE_WEBVR: number;
  25124. /**
  25125. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25126. */
  25127. static readonly RIG_MODE_CUSTOM: number;
  25128. /**
  25129. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25130. */
  25131. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25132. /**
  25133. * Define the input manager associated with the camera.
  25134. */
  25135. inputs: CameraInputsManager<Camera>;
  25136. /** @hidden */
  25137. _position: Vector3;
  25138. /**
  25139. * Define the current local position of the camera in the scene
  25140. */
  25141. position: Vector3;
  25142. /**
  25143. * The vector the camera should consider as up.
  25144. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25145. */
  25146. upVector: Vector3;
  25147. /**
  25148. * Define the current limit on the left side for an orthographic camera
  25149. * In scene unit
  25150. */
  25151. orthoLeft: Nullable<number>;
  25152. /**
  25153. * Define the current limit on the right side for an orthographic camera
  25154. * In scene unit
  25155. */
  25156. orthoRight: Nullable<number>;
  25157. /**
  25158. * Define the current limit on the bottom side for an orthographic camera
  25159. * In scene unit
  25160. */
  25161. orthoBottom: Nullable<number>;
  25162. /**
  25163. * Define the current limit on the top side for an orthographic camera
  25164. * In scene unit
  25165. */
  25166. orthoTop: Nullable<number>;
  25167. /**
  25168. * Field Of View is set in Radians. (default is 0.8)
  25169. */
  25170. fov: number;
  25171. /**
  25172. * Define the minimum distance the camera can see from.
  25173. * This is important to note that the depth buffer are not infinite and the closer it starts
  25174. * the more your scene might encounter depth fighting issue.
  25175. */
  25176. minZ: number;
  25177. /**
  25178. * Define the maximum distance the camera can see to.
  25179. * This is important to note that the depth buffer are not infinite and the further it end
  25180. * the more your scene might encounter depth fighting issue.
  25181. */
  25182. maxZ: number;
  25183. /**
  25184. * Define the default inertia of the camera.
  25185. * This helps giving a smooth feeling to the camera movement.
  25186. */
  25187. inertia: number;
  25188. /**
  25189. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25190. */
  25191. mode: number;
  25192. /**
  25193. * Define wether the camera is intermediate.
  25194. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25195. */
  25196. isIntermediate: boolean;
  25197. /**
  25198. * Define the viewport of the camera.
  25199. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25200. */
  25201. viewport: Viewport;
  25202. /**
  25203. * Restricts the camera to viewing objects with the same layerMask.
  25204. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25205. */
  25206. layerMask: number;
  25207. /**
  25208. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25209. */
  25210. fovMode: number;
  25211. /**
  25212. * Rig mode of the camera.
  25213. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25214. * This is normally controlled byt the camera themselves as internal use.
  25215. */
  25216. cameraRigMode: number;
  25217. /**
  25218. * Defines the distance between both "eyes" in case of a RIG
  25219. */
  25220. interaxialDistance: number;
  25221. /**
  25222. * Defines if stereoscopic rendering is done side by side or over under.
  25223. */
  25224. isStereoscopicSideBySide: boolean;
  25225. /**
  25226. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25227. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25228. * else in the scene. (Eg. security camera)
  25229. *
  25230. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25231. */
  25232. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25233. /**
  25234. * When set, the camera will render to this render target instead of the default canvas
  25235. *
  25236. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25237. */
  25238. outputRenderTarget: Nullable<RenderTargetTexture>;
  25239. /**
  25240. * Observable triggered when the camera view matrix has changed.
  25241. */
  25242. onViewMatrixChangedObservable: Observable<Camera>;
  25243. /**
  25244. * Observable triggered when the camera Projection matrix has changed.
  25245. */
  25246. onProjectionMatrixChangedObservable: Observable<Camera>;
  25247. /**
  25248. * Observable triggered when the inputs have been processed.
  25249. */
  25250. onAfterCheckInputsObservable: Observable<Camera>;
  25251. /**
  25252. * Observable triggered when reset has been called and applied to the camera.
  25253. */
  25254. onRestoreStateObservable: Observable<Camera>;
  25255. /** @hidden */
  25256. _cameraRigParams: any;
  25257. /** @hidden */
  25258. _rigCameras: Camera[];
  25259. /** @hidden */
  25260. _rigPostProcess: Nullable<PostProcess>;
  25261. protected _webvrViewMatrix: Matrix;
  25262. /** @hidden */
  25263. _skipRendering: boolean;
  25264. /** @hidden */
  25265. _projectionMatrix: Matrix;
  25266. /** @hidden */
  25267. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25268. /** @hidden */
  25269. _activeMeshes: SmartArray<AbstractMesh>;
  25270. protected _globalPosition: Vector3;
  25271. /** @hidden */
  25272. _computedViewMatrix: Matrix;
  25273. private _doNotComputeProjectionMatrix;
  25274. private _transformMatrix;
  25275. private _frustumPlanes;
  25276. private _refreshFrustumPlanes;
  25277. private _storedFov;
  25278. private _stateStored;
  25279. /**
  25280. * Instantiates a new camera object.
  25281. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25282. * @see http://doc.babylonjs.com/features/cameras
  25283. * @param name Defines the name of the camera in the scene
  25284. * @param position Defines the position of the camera
  25285. * @param scene Defines the scene the camera belongs too
  25286. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25287. */
  25288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25289. /**
  25290. * Store current camera state (fov, position, etc..)
  25291. * @returns the camera
  25292. */
  25293. storeState(): Camera;
  25294. /**
  25295. * Restores the camera state values if it has been stored. You must call storeState() first
  25296. */
  25297. protected _restoreStateValues(): boolean;
  25298. /**
  25299. * Restored camera state. You must call storeState() first.
  25300. * @returns true if restored and false otherwise
  25301. */
  25302. restoreState(): boolean;
  25303. /**
  25304. * Gets the class name of the camera.
  25305. * @returns the class name
  25306. */
  25307. getClassName(): string;
  25308. /** @hidden */
  25309. readonly _isCamera: boolean;
  25310. /**
  25311. * Gets a string representation of the camera useful for debug purpose.
  25312. * @param fullDetails Defines that a more verboe level of logging is required
  25313. * @returns the string representation
  25314. */
  25315. toString(fullDetails?: boolean): string;
  25316. /**
  25317. * Gets the current world space position of the camera.
  25318. */
  25319. readonly globalPosition: Vector3;
  25320. /**
  25321. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25322. * @returns the active meshe list
  25323. */
  25324. getActiveMeshes(): SmartArray<AbstractMesh>;
  25325. /**
  25326. * Check wether a mesh is part of the current active mesh list of the camera
  25327. * @param mesh Defines the mesh to check
  25328. * @returns true if active, false otherwise
  25329. */
  25330. isActiveMesh(mesh: Mesh): boolean;
  25331. /**
  25332. * Is this camera ready to be used/rendered
  25333. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25334. * @return true if the camera is ready
  25335. */
  25336. isReady(completeCheck?: boolean): boolean;
  25337. /** @hidden */
  25338. _initCache(): void;
  25339. /** @hidden */
  25340. _updateCache(ignoreParentClass?: boolean): void;
  25341. /** @hidden */
  25342. _isSynchronized(): boolean;
  25343. /** @hidden */
  25344. _isSynchronizedViewMatrix(): boolean;
  25345. /** @hidden */
  25346. _isSynchronizedProjectionMatrix(): boolean;
  25347. /**
  25348. * Attach the input controls to a specific dom element to get the input from.
  25349. * @param element Defines the element the controls should be listened from
  25350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25351. */
  25352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25353. /**
  25354. * Detach the current controls from the specified dom element.
  25355. * @param element Defines the element to stop listening the inputs from
  25356. */
  25357. detachControl(element: HTMLElement): void;
  25358. /**
  25359. * Update the camera state according to the different inputs gathered during the frame.
  25360. */
  25361. update(): void;
  25362. /** @hidden */
  25363. _checkInputs(): void;
  25364. /** @hidden */
  25365. readonly rigCameras: Camera[];
  25366. /**
  25367. * Gets the post process used by the rig cameras
  25368. */
  25369. readonly rigPostProcess: Nullable<PostProcess>;
  25370. /**
  25371. * Internal, gets the first post proces.
  25372. * @returns the first post process to be run on this camera.
  25373. */
  25374. _getFirstPostProcess(): Nullable<PostProcess>;
  25375. private _cascadePostProcessesToRigCams;
  25376. /**
  25377. * Attach a post process to the camera.
  25378. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25379. * @param postProcess The post process to attach to the camera
  25380. * @param insertAt The position of the post process in case several of them are in use in the scene
  25381. * @returns the position the post process has been inserted at
  25382. */
  25383. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25384. /**
  25385. * Detach a post process to the camera.
  25386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25387. * @param postProcess The post process to detach from the camera
  25388. */
  25389. detachPostProcess(postProcess: PostProcess): void;
  25390. /**
  25391. * Gets the current world matrix of the camera
  25392. */
  25393. getWorldMatrix(): Matrix;
  25394. /** @hidden */
  25395. _getViewMatrix(): Matrix;
  25396. /**
  25397. * Gets the current view matrix of the camera.
  25398. * @param force forces the camera to recompute the matrix without looking at the cached state
  25399. * @returns the view matrix
  25400. */
  25401. getViewMatrix(force?: boolean): Matrix;
  25402. /**
  25403. * Freeze the projection matrix.
  25404. * It will prevent the cache check of the camera projection compute and can speed up perf
  25405. * if no parameter of the camera are meant to change
  25406. * @param projection Defines manually a projection if necessary
  25407. */
  25408. freezeProjectionMatrix(projection?: Matrix): void;
  25409. /**
  25410. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25411. */
  25412. unfreezeProjectionMatrix(): void;
  25413. /**
  25414. * Gets the current projection matrix of the camera.
  25415. * @param force forces the camera to recompute the matrix without looking at the cached state
  25416. * @returns the projection matrix
  25417. */
  25418. getProjectionMatrix(force?: boolean): Matrix;
  25419. /**
  25420. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25421. * @returns a Matrix
  25422. */
  25423. getTransformationMatrix(): Matrix;
  25424. private _updateFrustumPlanes;
  25425. /**
  25426. * Checks if a cullable object (mesh...) is in the camera frustum
  25427. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25428. * @param target The object to check
  25429. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25430. * @returns true if the object is in frustum otherwise false
  25431. */
  25432. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25433. /**
  25434. * Checks if a cullable object (mesh...) is in the camera frustum
  25435. * Unlike isInFrustum this cheks the full bounding box
  25436. * @param target The object to check
  25437. * @returns true if the object is in frustum otherwise false
  25438. */
  25439. isCompletelyInFrustum(target: ICullable): boolean;
  25440. /**
  25441. * Gets a ray in the forward direction from the camera.
  25442. * @param length Defines the length of the ray to create
  25443. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25444. * @param origin Defines the start point of the ray which defaults to the camera position
  25445. * @returns the forward ray
  25446. */
  25447. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25448. /**
  25449. * Releases resources associated with this node.
  25450. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25451. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25452. */
  25453. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25454. /** @hidden */
  25455. _isLeftCamera: boolean;
  25456. /**
  25457. * Gets the left camera of a rig setup in case of Rigged Camera
  25458. */
  25459. readonly isLeftCamera: boolean;
  25460. /** @hidden */
  25461. _isRightCamera: boolean;
  25462. /**
  25463. * Gets the right camera of a rig setup in case of Rigged Camera
  25464. */
  25465. readonly isRightCamera: boolean;
  25466. /**
  25467. * Gets the left camera of a rig setup in case of Rigged Camera
  25468. */
  25469. readonly leftCamera: Nullable<FreeCamera>;
  25470. /**
  25471. * Gets the right camera of a rig setup in case of Rigged Camera
  25472. */
  25473. readonly rightCamera: Nullable<FreeCamera>;
  25474. /**
  25475. * Gets the left camera target of a rig setup in case of Rigged Camera
  25476. * @returns the target position
  25477. */
  25478. getLeftTarget(): Nullable<Vector3>;
  25479. /**
  25480. * Gets the right camera target of a rig setup in case of Rigged Camera
  25481. * @returns the target position
  25482. */
  25483. getRightTarget(): Nullable<Vector3>;
  25484. /**
  25485. * @hidden
  25486. */
  25487. setCameraRigMode(mode: number, rigParams: any): void;
  25488. /** @hidden */
  25489. static _setStereoscopicRigMode(camera: Camera): void;
  25490. /** @hidden */
  25491. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25492. /** @hidden */
  25493. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25494. /** @hidden */
  25495. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25496. /** @hidden */
  25497. _getVRProjectionMatrix(): Matrix;
  25498. protected _updateCameraRotationMatrix(): void;
  25499. protected _updateWebVRCameraRotationMatrix(): void;
  25500. /**
  25501. * This function MUST be overwritten by the different WebVR cameras available.
  25502. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25503. * @hidden
  25504. */
  25505. _getWebVRProjectionMatrix(): Matrix;
  25506. /**
  25507. * This function MUST be overwritten by the different WebVR cameras available.
  25508. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25509. * @hidden
  25510. */
  25511. _getWebVRViewMatrix(): Matrix;
  25512. /** @hidden */
  25513. setCameraRigParameter(name: string, value: any): void;
  25514. /**
  25515. * needs to be overridden by children so sub has required properties to be copied
  25516. * @hidden
  25517. */
  25518. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25519. /**
  25520. * May need to be overridden by children
  25521. * @hidden
  25522. */
  25523. _updateRigCameras(): void;
  25524. /** @hidden */
  25525. _setupInputs(): void;
  25526. /**
  25527. * Serialiaze the camera setup to a json represention
  25528. * @returns the JSON representation
  25529. */
  25530. serialize(): any;
  25531. /**
  25532. * Clones the current camera.
  25533. * @param name The cloned camera name
  25534. * @returns the cloned camera
  25535. */
  25536. clone(name: string): Camera;
  25537. /**
  25538. * Gets the direction of the camera relative to a given local axis.
  25539. * @param localAxis Defines the reference axis to provide a relative direction.
  25540. * @return the direction
  25541. */
  25542. getDirection(localAxis: Vector3): Vector3;
  25543. /**
  25544. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25545. * @param localAxis Defines the reference axis to provide a relative direction.
  25546. * @param result Defines the vector to store the result in
  25547. */
  25548. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25549. /**
  25550. * Gets a camera constructor for a given camera type
  25551. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25552. * @param name The name of the camera the result will be able to instantiate
  25553. * @param scene The scene the result will construct the camera in
  25554. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25555. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25556. * @returns a factory method to construc the camera
  25557. */
  25558. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25559. /**
  25560. * Compute the world matrix of the camera.
  25561. * @returns the camera workd matrix
  25562. */
  25563. computeWorldMatrix(): Matrix;
  25564. /**
  25565. * Parse a JSON and creates the camera from the parsed information
  25566. * @param parsedCamera The JSON to parse
  25567. * @param scene The scene to instantiate the camera in
  25568. * @returns the newly constructed camera
  25569. */
  25570. static Parse(parsedCamera: any, scene: Scene): Camera;
  25571. }
  25572. }
  25573. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25574. import { Nullable } from "babylonjs/types";
  25575. import { Scene } from "babylonjs/scene";
  25576. import { Vector4 } from "babylonjs/Maths/math.vector";
  25577. import { Mesh } from "babylonjs/Meshes/mesh";
  25578. /**
  25579. * Class containing static functions to help procedurally build meshes
  25580. */
  25581. export class DiscBuilder {
  25582. /**
  25583. * Creates a plane polygonal mesh. By default, this is a disc
  25584. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25585. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25586. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25590. * @param name defines the name of the mesh
  25591. * @param options defines the options used to create the mesh
  25592. * @param scene defines the hosting scene
  25593. * @returns the plane polygonal mesh
  25594. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25595. */
  25596. static CreateDisc(name: string, options: {
  25597. radius?: number;
  25598. tessellation?: number;
  25599. arc?: number;
  25600. updatable?: boolean;
  25601. sideOrientation?: number;
  25602. frontUVs?: Vector4;
  25603. backUVs?: Vector4;
  25604. }, scene?: Nullable<Scene>): Mesh;
  25605. }
  25606. }
  25607. declare module "babylonjs/Particles/solidParticleSystem" {
  25608. import { Vector3 } from "babylonjs/Maths/math.vector";
  25609. import { Mesh } from "babylonjs/Meshes/mesh";
  25610. import { Scene, IDisposable } from "babylonjs/scene";
  25611. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25612. /**
  25613. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25614. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  25615. * The SPS is also a particle system. It provides some methods to manage the particles.
  25616. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25617. *
  25618. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25619. */
  25620. export class SolidParticleSystem implements IDisposable {
  25621. /**
  25622. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25623. * Example : var p = SPS.particles[i];
  25624. */
  25625. particles: SolidParticle[];
  25626. /**
  25627. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25628. */
  25629. nbParticles: number;
  25630. /**
  25631. * If the particles must ever face the camera (default false). Useful for planar particles.
  25632. */
  25633. billboard: boolean;
  25634. /**
  25635. * Recompute normals when adding a shape
  25636. */
  25637. recomputeNormals: boolean;
  25638. /**
  25639. * This a counter ofr your own usage. It's not set by any SPS functions.
  25640. */
  25641. counter: number;
  25642. /**
  25643. * The SPS name. This name is also given to the underlying mesh.
  25644. */
  25645. name: string;
  25646. /**
  25647. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25648. */
  25649. mesh: Mesh;
  25650. /**
  25651. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25652. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25653. */
  25654. vars: any;
  25655. /**
  25656. * This array is populated when the SPS is set as 'pickable'.
  25657. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25658. * Each element of this array is an object `{idx: int, faceId: int}`.
  25659. * `idx` is the picked particle index in the `SPS.particles` array
  25660. * `faceId` is the picked face index counted within this particle.
  25661. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25662. */
  25663. pickedParticles: {
  25664. idx: number;
  25665. faceId: number;
  25666. }[];
  25667. /**
  25668. * This array is populated when `enableDepthSort` is set to true.
  25669. * Each element of this array is an instance of the class DepthSortedParticle.
  25670. */
  25671. depthSortedParticles: DepthSortedParticle[];
  25672. /**
  25673. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25674. * @hidden
  25675. */
  25676. _bSphereOnly: boolean;
  25677. /**
  25678. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25679. * @hidden
  25680. */
  25681. _bSphereRadiusFactor: number;
  25682. private _scene;
  25683. private _positions;
  25684. private _indices;
  25685. private _normals;
  25686. private _colors;
  25687. private _uvs;
  25688. private _indices32;
  25689. private _positions32;
  25690. private _normals32;
  25691. private _fixedNormal32;
  25692. private _colors32;
  25693. private _uvs32;
  25694. private _index;
  25695. private _updatable;
  25696. private _pickable;
  25697. private _isVisibilityBoxLocked;
  25698. private _alwaysVisible;
  25699. private _depthSort;
  25700. private _shapeCounter;
  25701. private _copy;
  25702. private _color;
  25703. private _computeParticleColor;
  25704. private _computeParticleTexture;
  25705. private _computeParticleRotation;
  25706. private _computeParticleVertex;
  25707. private _computeBoundingBox;
  25708. private _depthSortParticles;
  25709. private _camera;
  25710. private _mustUnrotateFixedNormals;
  25711. private _particlesIntersect;
  25712. private _needs32Bits;
  25713. /**
  25714. * Creates a SPS (Solid Particle System) object.
  25715. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25716. * @param scene (Scene) is the scene in which the SPS is added.
  25717. * @param options defines the options of the sps e.g.
  25718. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25719. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25720. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25721. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25722. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25723. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25724. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25725. */
  25726. constructor(name: string, scene: Scene, options?: {
  25727. updatable?: boolean;
  25728. isPickable?: boolean;
  25729. enableDepthSort?: boolean;
  25730. particleIntersection?: boolean;
  25731. boundingSphereOnly?: boolean;
  25732. bSphereRadiusFactor?: number;
  25733. });
  25734. /**
  25735. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25736. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25737. * @returns the created mesh
  25738. */
  25739. buildMesh(): Mesh;
  25740. /**
  25741. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25742. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25743. * Thus the particles generated from `digest()` have their property `position` set yet.
  25744. * @param mesh ( Mesh ) is the mesh to be digested
  25745. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  25746. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25747. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25748. * @returns the current SPS
  25749. */
  25750. digest(mesh: Mesh, options?: {
  25751. facetNb?: number;
  25752. number?: number;
  25753. delta?: number;
  25754. }): SolidParticleSystem;
  25755. private _unrotateFixedNormals;
  25756. private _resetCopy;
  25757. private _meshBuilder;
  25758. private _posToShape;
  25759. private _uvsToShapeUV;
  25760. private _addParticle;
  25761. /**
  25762. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25763. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25764. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25765. * @param nb (positive integer) the number of particles to be created from this model
  25766. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25767. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25768. * @returns the number of shapes in the system
  25769. */
  25770. addShape(mesh: Mesh, nb: number, options?: {
  25771. positionFunction?: any;
  25772. vertexFunction?: any;
  25773. }): number;
  25774. private _rebuildParticle;
  25775. /**
  25776. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25777. * @returns the SPS.
  25778. */
  25779. rebuildMesh(): SolidParticleSystem;
  25780. /**
  25781. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25782. * This method calls `updateParticle()` for each particle of the SPS.
  25783. * For an animated SPS, it is usually called within the render loop.
  25784. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25785. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25786. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25787. * @returns the SPS.
  25788. */
  25789. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25790. /**
  25791. * Disposes the SPS.
  25792. */
  25793. dispose(): void;
  25794. /**
  25795. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25796. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25797. * @returns the SPS.
  25798. */
  25799. refreshVisibleSize(): SolidParticleSystem;
  25800. /**
  25801. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25802. * @param size the size (float) of the visibility box
  25803. * note : this doesn't lock the SPS mesh bounding box.
  25804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25805. */
  25806. setVisibilityBox(size: number): void;
  25807. /**
  25808. * Gets whether the SPS as always visible or not
  25809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25810. */
  25811. /**
  25812. * Sets the SPS as always visible or not
  25813. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25814. */
  25815. isAlwaysVisible: boolean;
  25816. /**
  25817. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25818. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25819. */
  25820. /**
  25821. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25823. */
  25824. isVisibilityBoxLocked: boolean;
  25825. /**
  25826. * Tells to `setParticles()` to compute the particle rotations or not.
  25827. * Default value : true. The SPS is faster when it's set to false.
  25828. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25829. */
  25830. /**
  25831. * Gets if `setParticles()` computes the particle rotations or not.
  25832. * Default value : true. The SPS is faster when it's set to false.
  25833. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25834. */
  25835. computeParticleRotation: boolean;
  25836. /**
  25837. * Tells to `setParticles()` to compute the particle colors or not.
  25838. * Default value : true. The SPS is faster when it's set to false.
  25839. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25840. */
  25841. /**
  25842. * Gets if `setParticles()` computes the particle colors or not.
  25843. * Default value : true. The SPS is faster when it's set to false.
  25844. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25845. */
  25846. computeParticleColor: boolean;
  25847. /**
  25848. * Gets if `setParticles()` computes the particle textures or not.
  25849. * Default value : true. The SPS is faster when it's set to false.
  25850. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25851. */
  25852. computeParticleTexture: boolean;
  25853. /**
  25854. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25855. * Default value : false. The SPS is faster when it's set to false.
  25856. * Note : the particle custom vertex positions aren't stored values.
  25857. */
  25858. /**
  25859. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25860. * Default value : false. The SPS is faster when it's set to false.
  25861. * Note : the particle custom vertex positions aren't stored values.
  25862. */
  25863. computeParticleVertex: boolean;
  25864. /**
  25865. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25866. */
  25867. /**
  25868. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25869. */
  25870. computeBoundingBox: boolean;
  25871. /**
  25872. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25873. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25874. * Default : `true`
  25875. */
  25876. /**
  25877. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25878. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25879. * Default : `true`
  25880. */
  25881. depthSortParticles: boolean;
  25882. /**
  25883. * This function does nothing. It may be overwritten to set all the particle first values.
  25884. * The SPS doesn't call this function, you may have to call it by your own.
  25885. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25886. */
  25887. initParticles(): void;
  25888. /**
  25889. * This function does nothing. It may be overwritten to recycle a particle.
  25890. * The SPS doesn't call this function, you may have to call it by your own.
  25891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25892. * @param particle The particle to recycle
  25893. * @returns the recycled particle
  25894. */
  25895. recycleParticle(particle: SolidParticle): SolidParticle;
  25896. /**
  25897. * Updates a particle : this function should be overwritten by the user.
  25898. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25899. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25900. * @example : just set a particle position or velocity and recycle conditions
  25901. * @param particle The particle to update
  25902. * @returns the updated particle
  25903. */
  25904. updateParticle(particle: SolidParticle): SolidParticle;
  25905. /**
  25906. * Updates a vertex of a particle : it can be overwritten by the user.
  25907. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25908. * @param particle the current particle
  25909. * @param vertex the current index of the current particle
  25910. * @param pt the index of the current vertex in the particle shape
  25911. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25912. * @example : just set a vertex particle position
  25913. * @returns the updated vertex
  25914. */
  25915. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25916. /**
  25917. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25918. * This does nothing and may be overwritten by the user.
  25919. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25920. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25921. * @param update the boolean update value actually passed to setParticles()
  25922. */
  25923. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25924. /**
  25925. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25926. * This will be passed three parameters.
  25927. * This does nothing and may be overwritten by the user.
  25928. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25929. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25930. * @param update the boolean update value actually passed to setParticles()
  25931. */
  25932. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25933. }
  25934. }
  25935. declare module "babylonjs/Particles/solidParticle" {
  25936. import { Nullable } from "babylonjs/types";
  25937. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25938. import { Color4 } from "babylonjs/Maths/math.color";
  25939. import { Mesh } from "babylonjs/Meshes/mesh";
  25940. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25941. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25942. import { Plane } from "babylonjs/Maths/math.plane";
  25943. /**
  25944. * Represents one particle of a solid particle system.
  25945. */
  25946. export class SolidParticle {
  25947. /**
  25948. * particle global index
  25949. */
  25950. idx: number;
  25951. /**
  25952. * The color of the particle
  25953. */
  25954. color: Nullable<Color4>;
  25955. /**
  25956. * The world space position of the particle.
  25957. */
  25958. position: Vector3;
  25959. /**
  25960. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25961. */
  25962. rotation: Vector3;
  25963. /**
  25964. * The world space rotation quaternion of the particle.
  25965. */
  25966. rotationQuaternion: Nullable<Quaternion>;
  25967. /**
  25968. * The scaling of the particle.
  25969. */
  25970. scaling: Vector3;
  25971. /**
  25972. * The uvs of the particle.
  25973. */
  25974. uvs: Vector4;
  25975. /**
  25976. * The current speed of the particle.
  25977. */
  25978. velocity: Vector3;
  25979. /**
  25980. * The pivot point in the particle local space.
  25981. */
  25982. pivot: Vector3;
  25983. /**
  25984. * Must the particle be translated from its pivot point in its local space ?
  25985. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25986. * Default : false
  25987. */
  25988. translateFromPivot: boolean;
  25989. /**
  25990. * Is the particle active or not ?
  25991. */
  25992. alive: boolean;
  25993. /**
  25994. * Is the particle visible or not ?
  25995. */
  25996. isVisible: boolean;
  25997. /**
  25998. * Index of this particle in the global "positions" array (Internal use)
  25999. * @hidden
  26000. */
  26001. _pos: number;
  26002. /**
  26003. * @hidden Index of this particle in the global "indices" array (Internal use)
  26004. */
  26005. _ind: number;
  26006. /**
  26007. * @hidden ModelShape of this particle (Internal use)
  26008. */
  26009. _model: ModelShape;
  26010. /**
  26011. * ModelShape id of this particle
  26012. */
  26013. shapeId: number;
  26014. /**
  26015. * Index of the particle in its shape id (Internal use)
  26016. */
  26017. idxInShape: number;
  26018. /**
  26019. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26020. */
  26021. _modelBoundingInfo: BoundingInfo;
  26022. /**
  26023. * @hidden Particle BoundingInfo object (Internal use)
  26024. */
  26025. _boundingInfo: BoundingInfo;
  26026. /**
  26027. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26028. */
  26029. _sps: SolidParticleSystem;
  26030. /**
  26031. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26032. */
  26033. _stillInvisible: boolean;
  26034. /**
  26035. * @hidden Last computed particle rotation matrix
  26036. */
  26037. _rotationMatrix: number[];
  26038. /**
  26039. * Parent particle Id, if any.
  26040. * Default null.
  26041. */
  26042. parentId: Nullable<number>;
  26043. /**
  26044. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26045. * The possible values are :
  26046. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26047. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26048. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26049. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26050. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26051. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26052. * */
  26053. cullingStrategy: number;
  26054. /**
  26055. * @hidden Internal global position in the SPS.
  26056. */
  26057. _globalPosition: Vector3;
  26058. /**
  26059. * Creates a Solid Particle object.
  26060. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26061. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26062. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26063. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26064. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26065. * @param shapeId (integer) is the model shape identifier in the SPS.
  26066. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26067. * @param sps defines the sps it is associated to
  26068. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26069. */
  26070. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26071. /**
  26072. * Legacy support, changed scale to scaling
  26073. */
  26074. /**
  26075. * Legacy support, changed scale to scaling
  26076. */
  26077. scale: Vector3;
  26078. /**
  26079. * Legacy support, changed quaternion to rotationQuaternion
  26080. */
  26081. /**
  26082. * Legacy support, changed quaternion to rotationQuaternion
  26083. */
  26084. quaternion: Nullable<Quaternion>;
  26085. /**
  26086. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26087. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26088. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26089. * @returns true if it intersects
  26090. */
  26091. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26092. /**
  26093. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26094. * A particle is in the frustum if its bounding box intersects the frustum
  26095. * @param frustumPlanes defines the frustum to test
  26096. * @returns true if the particle is in the frustum planes
  26097. */
  26098. isInFrustum(frustumPlanes: Plane[]): boolean;
  26099. /**
  26100. * get the rotation matrix of the particle
  26101. * @hidden
  26102. */
  26103. getRotationMatrix(m: Matrix): void;
  26104. }
  26105. /**
  26106. * Represents the shape of the model used by one particle of a solid particle system.
  26107. * SPS internal tool, don't use it manually.
  26108. */
  26109. export class ModelShape {
  26110. /**
  26111. * The shape id
  26112. * @hidden
  26113. */
  26114. shapeID: number;
  26115. /**
  26116. * flat array of model positions (internal use)
  26117. * @hidden
  26118. */
  26119. _shape: Vector3[];
  26120. /**
  26121. * flat array of model UVs (internal use)
  26122. * @hidden
  26123. */
  26124. _shapeUV: number[];
  26125. /**
  26126. * length of the shape in the model indices array (internal use)
  26127. * @hidden
  26128. */
  26129. _indicesLength: number;
  26130. /**
  26131. * Custom position function (internal use)
  26132. * @hidden
  26133. */
  26134. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26135. /**
  26136. * Custom vertex function (internal use)
  26137. * @hidden
  26138. */
  26139. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26140. /**
  26141. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  26142. * SPS internal tool, don't use it manually.
  26143. * @hidden
  26144. */
  26145. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26146. }
  26147. /**
  26148. * Represents a Depth Sorted Particle in the solid particle system.
  26149. */
  26150. export class DepthSortedParticle {
  26151. /**
  26152. * Index of the particle in the "indices" array
  26153. */
  26154. ind: number;
  26155. /**
  26156. * Length of the particle shape in the "indices" array
  26157. */
  26158. indicesLength: number;
  26159. /**
  26160. * Squared distance from the particle to the camera
  26161. */
  26162. sqDistance: number;
  26163. }
  26164. }
  26165. declare module "babylonjs/Collisions/meshCollisionData" {
  26166. import { Collider } from "babylonjs/Collisions/collider";
  26167. import { Vector3 } from "babylonjs/Maths/math.vector";
  26168. import { Nullable } from "babylonjs/types";
  26169. import { Observer } from "babylonjs/Misc/observable";
  26170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26171. /**
  26172. * @hidden
  26173. */
  26174. export class _MeshCollisionData {
  26175. _checkCollisions: boolean;
  26176. _collisionMask: number;
  26177. _collisionGroup: number;
  26178. _collider: Nullable<Collider>;
  26179. _oldPositionForCollisions: Vector3;
  26180. _diffPositionForCollisions: Vector3;
  26181. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26182. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26183. }
  26184. }
  26185. declare module "babylonjs/Meshes/abstractMesh" {
  26186. import { Observable } from "babylonjs/Misc/observable";
  26187. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26188. import { Camera } from "babylonjs/Cameras/camera";
  26189. import { Scene, IDisposable } from "babylonjs/scene";
  26190. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26191. import { Node } from "babylonjs/node";
  26192. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26195. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26196. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26197. import { Material } from "babylonjs/Materials/material";
  26198. import { Light } from "babylonjs/Lights/light";
  26199. import { Skeleton } from "babylonjs/Bones/skeleton";
  26200. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26201. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26202. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26203. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26204. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26205. import { Plane } from "babylonjs/Maths/math.plane";
  26206. import { Ray } from "babylonjs/Culling/ray";
  26207. import { Collider } from "babylonjs/Collisions/collider";
  26208. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26209. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26210. /** @hidden */
  26211. class _FacetDataStorage {
  26212. facetPositions: Vector3[];
  26213. facetNormals: Vector3[];
  26214. facetPartitioning: number[][];
  26215. facetNb: number;
  26216. partitioningSubdivisions: number;
  26217. partitioningBBoxRatio: number;
  26218. facetDataEnabled: boolean;
  26219. facetParameters: any;
  26220. bbSize: Vector3;
  26221. subDiv: {
  26222. max: number;
  26223. X: number;
  26224. Y: number;
  26225. Z: number;
  26226. };
  26227. facetDepthSort: boolean;
  26228. facetDepthSortEnabled: boolean;
  26229. depthSortedIndices: IndicesArray;
  26230. depthSortedFacets: {
  26231. ind: number;
  26232. sqDistance: number;
  26233. }[];
  26234. facetDepthSortFunction: (f1: {
  26235. ind: number;
  26236. sqDistance: number;
  26237. }, f2: {
  26238. ind: number;
  26239. sqDistance: number;
  26240. }) => number;
  26241. facetDepthSortFrom: Vector3;
  26242. facetDepthSortOrigin: Vector3;
  26243. invertedMatrix: Matrix;
  26244. }
  26245. /**
  26246. * @hidden
  26247. **/
  26248. class _InternalAbstractMeshDataInfo {
  26249. _hasVertexAlpha: boolean;
  26250. _useVertexColors: boolean;
  26251. _numBoneInfluencers: number;
  26252. _applyFog: boolean;
  26253. _receiveShadows: boolean;
  26254. _facetData: _FacetDataStorage;
  26255. _visibility: number;
  26256. _skeleton: Nullable<Skeleton>;
  26257. _layerMask: number;
  26258. _computeBonesUsingShaders: boolean;
  26259. _isActive: boolean;
  26260. _onlyForInstances: boolean;
  26261. _isActiveIntermediate: boolean;
  26262. _onlyForInstancesIntermediate: boolean;
  26263. }
  26264. /**
  26265. * Class used to store all common mesh properties
  26266. */
  26267. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26268. /** No occlusion */
  26269. static OCCLUSION_TYPE_NONE: number;
  26270. /** Occlusion set to optimisitic */
  26271. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26272. /** Occlusion set to strict */
  26273. static OCCLUSION_TYPE_STRICT: number;
  26274. /** Use an accurante occlusion algorithm */
  26275. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26276. /** Use a conservative occlusion algorithm */
  26277. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26278. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26279. * Test order :
  26280. * Is the bounding sphere outside the frustum ?
  26281. * If not, are the bounding box vertices outside the frustum ?
  26282. * It not, then the cullable object is in the frustum.
  26283. */
  26284. static readonly CULLINGSTRATEGY_STANDARD: number;
  26285. /** Culling strategy : Bounding Sphere Only.
  26286. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26287. * It's also less accurate than the standard because some not visible objects can still be selected.
  26288. * Test : is the bounding sphere outside the frustum ?
  26289. * If not, then the cullable object is in the frustum.
  26290. */
  26291. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26292. /** Culling strategy : Optimistic Inclusion.
  26293. * This in an inclusion test first, then the standard exclusion test.
  26294. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26295. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  26296. * Anyway, it's as accurate as the standard strategy.
  26297. * Test :
  26298. * Is the cullable object bounding sphere center in the frustum ?
  26299. * If not, apply the default culling strategy.
  26300. */
  26301. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26302. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26303. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26304. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26305. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  26306. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26307. * Test :
  26308. * Is the cullable object bounding sphere center in the frustum ?
  26309. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26310. */
  26311. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26312. /**
  26313. * No billboard
  26314. */
  26315. static readonly BILLBOARDMODE_NONE: number;
  26316. /** Billboard on X axis */
  26317. static readonly BILLBOARDMODE_X: number;
  26318. /** Billboard on Y axis */
  26319. static readonly BILLBOARDMODE_Y: number;
  26320. /** Billboard on Z axis */
  26321. static readonly BILLBOARDMODE_Z: number;
  26322. /** Billboard on all axes */
  26323. static readonly BILLBOARDMODE_ALL: number;
  26324. /** @hidden */
  26325. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26326. /**
  26327. * The culling strategy to use to check whether the mesh must be rendered or not.
  26328. * This value can be changed at any time and will be used on the next render mesh selection.
  26329. * The possible values are :
  26330. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26331. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26332. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26333. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26334. * Please read each static variable documentation to get details about the culling process.
  26335. * */
  26336. cullingStrategy: number;
  26337. /**
  26338. * Gets the number of facets in the mesh
  26339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26340. */
  26341. readonly facetNb: number;
  26342. /**
  26343. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26345. */
  26346. partitioningSubdivisions: number;
  26347. /**
  26348. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26349. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26351. */
  26352. partitioningBBoxRatio: number;
  26353. /**
  26354. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26355. * Works only for updatable meshes.
  26356. * Doesn't work with multi-materials
  26357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26358. */
  26359. mustDepthSortFacets: boolean;
  26360. /**
  26361. * The location (Vector3) where the facet depth sort must be computed from.
  26362. * By default, the active camera position.
  26363. * Used only when facet depth sort is enabled
  26364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26365. */
  26366. facetDepthSortFrom: Vector3;
  26367. /**
  26368. * gets a boolean indicating if facetData is enabled
  26369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26370. */
  26371. readonly isFacetDataEnabled: boolean;
  26372. /** @hidden */
  26373. _updateNonUniformScalingState(value: boolean): boolean;
  26374. /**
  26375. * An event triggered when this mesh collides with another one
  26376. */
  26377. onCollideObservable: Observable<AbstractMesh>;
  26378. /** Set a function to call when this mesh collides with another one */
  26379. onCollide: () => void;
  26380. /**
  26381. * An event triggered when the collision's position changes
  26382. */
  26383. onCollisionPositionChangeObservable: Observable<Vector3>;
  26384. /** Set a function to call when the collision's position changes */
  26385. onCollisionPositionChange: () => void;
  26386. /**
  26387. * An event triggered when material is changed
  26388. */
  26389. onMaterialChangedObservable: Observable<AbstractMesh>;
  26390. /**
  26391. * Gets or sets the orientation for POV movement & rotation
  26392. */
  26393. definedFacingForward: boolean;
  26394. /** @hidden */
  26395. _occlusionQuery: Nullable<WebGLQuery>;
  26396. /** @hidden */
  26397. _renderingGroup: Nullable<RenderingGroup>;
  26398. /**
  26399. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26400. */
  26401. /**
  26402. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26403. */
  26404. visibility: number;
  26405. /** Gets or sets the alpha index used to sort transparent meshes
  26406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26407. */
  26408. alphaIndex: number;
  26409. /**
  26410. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26411. */
  26412. isVisible: boolean;
  26413. /**
  26414. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26415. */
  26416. isPickable: boolean;
  26417. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26418. showSubMeshesBoundingBox: boolean;
  26419. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26421. */
  26422. isBlocker: boolean;
  26423. /**
  26424. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26425. */
  26426. enablePointerMoveEvents: boolean;
  26427. /**
  26428. * Specifies the rendering group id for this mesh (0 by default)
  26429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26430. */
  26431. renderingGroupId: number;
  26432. private _material;
  26433. /** Gets or sets current material */
  26434. material: Nullable<Material>;
  26435. /**
  26436. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26437. * @see http://doc.babylonjs.com/babylon101/shadows
  26438. */
  26439. receiveShadows: boolean;
  26440. /** Defines color to use when rendering outline */
  26441. outlineColor: Color3;
  26442. /** Define width to use when rendering outline */
  26443. outlineWidth: number;
  26444. /** Defines color to use when rendering overlay */
  26445. overlayColor: Color3;
  26446. /** Defines alpha to use when rendering overlay */
  26447. overlayAlpha: number;
  26448. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26449. hasVertexAlpha: boolean;
  26450. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  26451. useVertexColors: boolean;
  26452. /**
  26453. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26454. */
  26455. computeBonesUsingShaders: boolean;
  26456. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26457. numBoneInfluencers: number;
  26458. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26459. applyFog: boolean;
  26460. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26461. useOctreeForRenderingSelection: boolean;
  26462. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26463. useOctreeForPicking: boolean;
  26464. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26465. useOctreeForCollisions: boolean;
  26466. /**
  26467. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26468. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26469. */
  26470. layerMask: number;
  26471. /**
  26472. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26473. */
  26474. alwaysSelectAsActiveMesh: boolean;
  26475. /**
  26476. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26477. */
  26478. doNotSyncBoundingInfo: boolean;
  26479. /**
  26480. * Gets or sets the current action manager
  26481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26482. */
  26483. actionManager: Nullable<AbstractActionManager>;
  26484. private _meshCollisionData;
  26485. /**
  26486. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26487. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26488. */
  26489. ellipsoid: Vector3;
  26490. /**
  26491. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26493. */
  26494. ellipsoidOffset: Vector3;
  26495. /**
  26496. * Gets or sets a collision mask used to mask collisions (default is -1).
  26497. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26498. */
  26499. collisionMask: number;
  26500. /**
  26501. * Gets or sets the current collision group mask (-1 by default).
  26502. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26503. */
  26504. collisionGroup: number;
  26505. /**
  26506. * Defines edge width used when edgesRenderer is enabled
  26507. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26508. */
  26509. edgesWidth: number;
  26510. /**
  26511. * Defines edge color used when edgesRenderer is enabled
  26512. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26513. */
  26514. edgesColor: Color4;
  26515. /** @hidden */
  26516. _edgesRenderer: Nullable<IEdgesRenderer>;
  26517. /** @hidden */
  26518. _masterMesh: Nullable<AbstractMesh>;
  26519. /** @hidden */
  26520. _boundingInfo: Nullable<BoundingInfo>;
  26521. /** @hidden */
  26522. _renderId: number;
  26523. /**
  26524. * Gets or sets the list of subMeshes
  26525. * @see http://doc.babylonjs.com/how_to/multi_materials
  26526. */
  26527. subMeshes: SubMesh[];
  26528. /** @hidden */
  26529. _intersectionsInProgress: AbstractMesh[];
  26530. /** @hidden */
  26531. _unIndexed: boolean;
  26532. /** @hidden */
  26533. _lightSources: Light[];
  26534. /** Gets the list of lights affecting that mesh */
  26535. readonly lightSources: Light[];
  26536. /** @hidden */
  26537. readonly _positions: Nullable<Vector3[]>;
  26538. /** @hidden */
  26539. _waitingData: {
  26540. lods: Nullable<any>;
  26541. actions: Nullable<any>;
  26542. freezeWorldMatrix: Nullable<boolean>;
  26543. };
  26544. /** @hidden */
  26545. _bonesTransformMatrices: Nullable<Float32Array>;
  26546. /** @hidden */
  26547. _transformMatrixTexture: Nullable<RawTexture>;
  26548. /**
  26549. * Gets or sets a skeleton to apply skining transformations
  26550. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26551. */
  26552. skeleton: Nullable<Skeleton>;
  26553. /**
  26554. * An event triggered when the mesh is rebuilt.
  26555. */
  26556. onRebuildObservable: Observable<AbstractMesh>;
  26557. /**
  26558. * Creates a new AbstractMesh
  26559. * @param name defines the name of the mesh
  26560. * @param scene defines the hosting scene
  26561. */
  26562. constructor(name: string, scene?: Nullable<Scene>);
  26563. /**
  26564. * Returns the string "AbstractMesh"
  26565. * @returns "AbstractMesh"
  26566. */
  26567. getClassName(): string;
  26568. /**
  26569. * Gets a string representation of the current mesh
  26570. * @param fullDetails defines a boolean indicating if full details must be included
  26571. * @returns a string representation of the current mesh
  26572. */
  26573. toString(fullDetails?: boolean): string;
  26574. /**
  26575. * @hidden
  26576. */
  26577. protected _getEffectiveParent(): Nullable<Node>;
  26578. /** @hidden */
  26579. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26580. /** @hidden */
  26581. _rebuild(): void;
  26582. /** @hidden */
  26583. _resyncLightSources(): void;
  26584. /** @hidden */
  26585. _resyncLighSource(light: Light): void;
  26586. /** @hidden */
  26587. _unBindEffect(): void;
  26588. /** @hidden */
  26589. _removeLightSource(light: Light): void;
  26590. private _markSubMeshesAsDirty;
  26591. /** @hidden */
  26592. _markSubMeshesAsLightDirty(): void;
  26593. /** @hidden */
  26594. _markSubMeshesAsAttributesDirty(): void;
  26595. /** @hidden */
  26596. _markSubMeshesAsMiscDirty(): void;
  26597. /**
  26598. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26599. */
  26600. scaling: Vector3;
  26601. /**
  26602. * Returns true if the mesh is blocked. Implemented by child classes
  26603. */
  26604. readonly isBlocked: boolean;
  26605. /**
  26606. * Returns the mesh itself by default. Implemented by child classes
  26607. * @param camera defines the camera to use to pick the right LOD level
  26608. * @returns the currentAbstractMesh
  26609. */
  26610. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26611. /**
  26612. * Returns 0 by default. Implemented by child classes
  26613. * @returns an integer
  26614. */
  26615. getTotalVertices(): number;
  26616. /**
  26617. * Returns a positive integer : the total number of indices in this mesh geometry.
  26618. * @returns the numner of indices or zero if the mesh has no geometry.
  26619. */
  26620. getTotalIndices(): number;
  26621. /**
  26622. * Returns null by default. Implemented by child classes
  26623. * @returns null
  26624. */
  26625. getIndices(): Nullable<IndicesArray>;
  26626. /**
  26627. * Returns the array of the requested vertex data kind. Implemented by child classes
  26628. * @param kind defines the vertex data kind to use
  26629. * @returns null
  26630. */
  26631. getVerticesData(kind: string): Nullable<FloatArray>;
  26632. /**
  26633. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26634. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26635. * Note that a new underlying VertexBuffer object is created each call.
  26636. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26637. * @param kind defines vertex data kind:
  26638. * * VertexBuffer.PositionKind
  26639. * * VertexBuffer.UVKind
  26640. * * VertexBuffer.UV2Kind
  26641. * * VertexBuffer.UV3Kind
  26642. * * VertexBuffer.UV4Kind
  26643. * * VertexBuffer.UV5Kind
  26644. * * VertexBuffer.UV6Kind
  26645. * * VertexBuffer.ColorKind
  26646. * * VertexBuffer.MatricesIndicesKind
  26647. * * VertexBuffer.MatricesIndicesExtraKind
  26648. * * VertexBuffer.MatricesWeightsKind
  26649. * * VertexBuffer.MatricesWeightsExtraKind
  26650. * @param data defines the data source
  26651. * @param updatable defines if the data must be flagged as updatable (or static)
  26652. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  26653. * @returns the current mesh
  26654. */
  26655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26656. /**
  26657. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26658. * If the mesh has no geometry, it is simply returned as it is.
  26659. * @param kind defines vertex data kind:
  26660. * * VertexBuffer.PositionKind
  26661. * * VertexBuffer.UVKind
  26662. * * VertexBuffer.UV2Kind
  26663. * * VertexBuffer.UV3Kind
  26664. * * VertexBuffer.UV4Kind
  26665. * * VertexBuffer.UV5Kind
  26666. * * VertexBuffer.UV6Kind
  26667. * * VertexBuffer.ColorKind
  26668. * * VertexBuffer.MatricesIndicesKind
  26669. * * VertexBuffer.MatricesIndicesExtraKind
  26670. * * VertexBuffer.MatricesWeightsKind
  26671. * * VertexBuffer.MatricesWeightsExtraKind
  26672. * @param data defines the data source
  26673. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  26674. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26675. * @returns the current mesh
  26676. */
  26677. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26678. /**
  26679. * Sets the mesh indices,
  26680. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26681. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26682. * @param totalVertices Defines the total number of vertices
  26683. * @returns the current mesh
  26684. */
  26685. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26686. /**
  26687. * Gets a boolean indicating if specific vertex data is present
  26688. * @param kind defines the vertex data kind to use
  26689. * @returns true is data kind is present
  26690. */
  26691. isVerticesDataPresent(kind: string): boolean;
  26692. /**
  26693. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26694. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26695. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26696. * @returns a BoundingInfo
  26697. */
  26698. getBoundingInfo(): BoundingInfo;
  26699. /**
  26700. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26701. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26702. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26703. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26704. * @returns the current mesh
  26705. */
  26706. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26707. /**
  26708. * Overwrite the current bounding info
  26709. * @param boundingInfo defines the new bounding info
  26710. * @returns the current mesh
  26711. */
  26712. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26713. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26714. readonly useBones: boolean;
  26715. /** @hidden */
  26716. _preActivate(): void;
  26717. /** @hidden */
  26718. _preActivateForIntermediateRendering(renderId: number): void;
  26719. /** @hidden */
  26720. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26721. /** @hidden */
  26722. _postActivate(): void;
  26723. /** @hidden */
  26724. _freeze(): void;
  26725. /** @hidden */
  26726. _unFreeze(): void;
  26727. /**
  26728. * Gets the current world matrix
  26729. * @returns a Matrix
  26730. */
  26731. getWorldMatrix(): Matrix;
  26732. /** @hidden */
  26733. _getWorldMatrixDeterminant(): number;
  26734. /**
  26735. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26736. */
  26737. readonly isAnInstance: boolean;
  26738. /**
  26739. * Perform relative position change from the point of view of behind the front of the mesh.
  26740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26741. * Supports definition of mesh facing forward or backward
  26742. * @param amountRight defines the distance on the right axis
  26743. * @param amountUp defines the distance on the up axis
  26744. * @param amountForward defines the distance on the forward axis
  26745. * @returns the current mesh
  26746. */
  26747. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26748. /**
  26749. * Calculate relative position change from the point of view of behind the front of the mesh.
  26750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26751. * Supports definition of mesh facing forward or backward
  26752. * @param amountRight defines the distance on the right axis
  26753. * @param amountUp defines the distance on the up axis
  26754. * @param amountForward defines the distance on the forward axis
  26755. * @returns the new displacement vector
  26756. */
  26757. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26758. /**
  26759. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26760. * Supports definition of mesh facing forward or backward
  26761. * @param flipBack defines the flip
  26762. * @param twirlClockwise defines the twirl
  26763. * @param tiltRight defines the tilt
  26764. * @returns the current mesh
  26765. */
  26766. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26767. /**
  26768. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26769. * Supports definition of mesh facing forward or backward.
  26770. * @param flipBack defines the flip
  26771. * @param twirlClockwise defines the twirl
  26772. * @param tiltRight defines the tilt
  26773. * @returns the new rotation vector
  26774. */
  26775. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26776. /**
  26777. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26778. * This means the mesh underlying bounding box and sphere are recomputed.
  26779. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26780. * @returns the current mesh
  26781. */
  26782. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26783. /** @hidden */
  26784. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26785. /** @hidden */
  26786. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26787. /** @hidden */
  26788. _updateBoundingInfo(): AbstractMesh;
  26789. /** @hidden */
  26790. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26791. /** @hidden */
  26792. protected _afterComputeWorldMatrix(): void;
  26793. /** @hidden */
  26794. readonly _effectiveMesh: AbstractMesh;
  26795. /**
  26796. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26797. * A mesh is in the frustum if its bounding box intersects the frustum
  26798. * @param frustumPlanes defines the frustum to test
  26799. * @returns true if the mesh is in the frustum planes
  26800. */
  26801. isInFrustum(frustumPlanes: Plane[]): boolean;
  26802. /**
  26803. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26804. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26805. * @param frustumPlanes defines the frustum to test
  26806. * @returns true if the mesh is completely in the frustum planes
  26807. */
  26808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26809. /**
  26810. * True if the mesh intersects another mesh or a SolidParticle object
  26811. * @param mesh defines a target mesh or SolidParticle to test
  26812. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  26813. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26814. * @returns true if there is an intersection
  26815. */
  26816. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26817. /**
  26818. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26819. * @param point defines the point to test
  26820. * @returns true if there is an intersection
  26821. */
  26822. intersectsPoint(point: Vector3): boolean;
  26823. /**
  26824. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26826. */
  26827. checkCollisions: boolean;
  26828. /**
  26829. * Gets Collider object used to compute collisions (not physics)
  26830. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26831. */
  26832. readonly collider: Nullable<Collider>;
  26833. /**
  26834. * Move the mesh using collision engine
  26835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26836. * @param displacement defines the requested displacement vector
  26837. * @returns the current mesh
  26838. */
  26839. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26840. private _onCollisionPositionChange;
  26841. /** @hidden */
  26842. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26843. /** @hidden */
  26844. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26845. /** @hidden */
  26846. _checkCollision(collider: Collider): AbstractMesh;
  26847. /** @hidden */
  26848. _generatePointsArray(): boolean;
  26849. /**
  26850. * Checks if the passed Ray intersects with the mesh
  26851. * @param ray defines the ray to use
  26852. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26854. * @returns the picking info
  26855. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26856. */
  26857. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26858. /**
  26859. * Clones the current mesh
  26860. * @param name defines the mesh name
  26861. * @param newParent defines the new mesh parent
  26862. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26863. * @returns the new mesh
  26864. */
  26865. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26866. /**
  26867. * Disposes all the submeshes of the current meshnp
  26868. * @returns the current mesh
  26869. */
  26870. releaseSubMeshes(): AbstractMesh;
  26871. /**
  26872. * Releases resources associated with this abstract mesh.
  26873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26875. */
  26876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26877. /**
  26878. * Adds the passed mesh as a child to the current mesh
  26879. * @param mesh defines the child mesh
  26880. * @returns the current mesh
  26881. */
  26882. addChild(mesh: AbstractMesh): AbstractMesh;
  26883. /**
  26884. * Removes the passed mesh from the current mesh children list
  26885. * @param mesh defines the child mesh
  26886. * @returns the current mesh
  26887. */
  26888. removeChild(mesh: AbstractMesh): AbstractMesh;
  26889. /** @hidden */
  26890. private _initFacetData;
  26891. /**
  26892. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26893. * This method can be called within the render loop.
  26894. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  26895. * @returns the current mesh
  26896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26897. */
  26898. updateFacetData(): AbstractMesh;
  26899. /**
  26900. * Returns the facetLocalNormals array.
  26901. * The normals are expressed in the mesh local spac
  26902. * @returns an array of Vector3
  26903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26904. */
  26905. getFacetLocalNormals(): Vector3[];
  26906. /**
  26907. * Returns the facetLocalPositions array.
  26908. * The facet positions are expressed in the mesh local space
  26909. * @returns an array of Vector3
  26910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26911. */
  26912. getFacetLocalPositions(): Vector3[];
  26913. /**
  26914. * Returns the facetLocalPartioning array
  26915. * @returns an array of array of numbers
  26916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26917. */
  26918. getFacetLocalPartitioning(): number[][];
  26919. /**
  26920. * Returns the i-th facet position in the world system.
  26921. * This method allocates a new Vector3 per call
  26922. * @param i defines the facet index
  26923. * @returns a new Vector3
  26924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26925. */
  26926. getFacetPosition(i: number): Vector3;
  26927. /**
  26928. * Sets the reference Vector3 with the i-th facet position in the world system
  26929. * @param i defines the facet index
  26930. * @param ref defines the target vector
  26931. * @returns the current mesh
  26932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26933. */
  26934. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26935. /**
  26936. * Returns the i-th facet normal in the world system.
  26937. * This method allocates a new Vector3 per call
  26938. * @param i defines the facet index
  26939. * @returns a new Vector3
  26940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26941. */
  26942. getFacetNormal(i: number): Vector3;
  26943. /**
  26944. * Sets the reference Vector3 with the i-th facet normal in the world system
  26945. * @param i defines the facet index
  26946. * @param ref defines the target vector
  26947. * @returns the current mesh
  26948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26949. */
  26950. getFacetNormalToRef(i: number, ref: Vector3): this;
  26951. /**
  26952. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  26953. * @param x defines x coordinate
  26954. * @param y defines y coordinate
  26955. * @param z defines z coordinate
  26956. * @returns the array of facet indexes
  26957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26958. */
  26959. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26960. /**
  26961. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26962. * @param projected sets as the (x,y,z) world projection on the facet
  26963. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  26964. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  26965. * @param x defines x coordinate
  26966. * @param y defines y coordinate
  26967. * @param z defines z coordinate
  26968. * @returns the face index if found (or null instead)
  26969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26970. */
  26971. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26972. /**
  26973. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26974. * @param projected sets as the (x,y,z) local projection on the facet
  26975. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  26976. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  26977. * @param x defines x coordinate
  26978. * @param y defines y coordinate
  26979. * @param z defines z coordinate
  26980. * @returns the face index if found (or null instead)
  26981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26982. */
  26983. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26984. /**
  26985. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26986. * @returns the parameters
  26987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26988. */
  26989. getFacetDataParameters(): any;
  26990. /**
  26991. * Disables the feature FacetData and frees the related memory
  26992. * @returns the current mesh
  26993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26994. */
  26995. disableFacetData(): AbstractMesh;
  26996. /**
  26997. * Updates the AbstractMesh indices array
  26998. * @param indices defines the data source
  26999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27000. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  27001. * @returns the current mesh
  27002. */
  27003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27004. /**
  27005. * Creates new normals data for the mesh
  27006. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27007. * @returns the current mesh
  27008. */
  27009. createNormals(updatable: boolean): AbstractMesh;
  27010. /**
  27011. * Align the mesh with a normal
  27012. * @param normal defines the normal to use
  27013. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27014. * @returns the current mesh
  27015. */
  27016. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27017. /** @hidden */
  27018. _checkOcclusionQuery(): boolean;
  27019. /**
  27020. * Disables the mesh edge rendering mode
  27021. * @returns the currentAbstractMesh
  27022. */
  27023. disableEdgesRendering(): AbstractMesh;
  27024. /**
  27025. * Enables the edge rendering mode on the mesh.
  27026. * This mode makes the mesh edges visible
  27027. * @param epsilon defines the maximal distance between two angles to detect a face
  27028. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27029. * @returns the currentAbstractMesh
  27030. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27031. */
  27032. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27033. }
  27034. }
  27035. declare module "babylonjs/Actions/actionEvent" {
  27036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27037. import { Nullable } from "babylonjs/types";
  27038. import { Sprite } from "babylonjs/Sprites/sprite";
  27039. import { Scene } from "babylonjs/scene";
  27040. import { Vector2 } from "babylonjs/Maths/math.vector";
  27041. /**
  27042. * Interface used to define ActionEvent
  27043. */
  27044. export interface IActionEvent {
  27045. /** The mesh or sprite that triggered the action */
  27046. source: any;
  27047. /** The X mouse cursor position at the time of the event */
  27048. pointerX: number;
  27049. /** The Y mouse cursor position at the time of the event */
  27050. pointerY: number;
  27051. /** The mesh that is currently pointed at (can be null) */
  27052. meshUnderPointer: Nullable<AbstractMesh>;
  27053. /** the original (browser) event that triggered the ActionEvent */
  27054. sourceEvent?: any;
  27055. /** additional data for the event */
  27056. additionalData?: any;
  27057. }
  27058. /**
  27059. * ActionEvent is the event being sent when an action is triggered.
  27060. */
  27061. export class ActionEvent implements IActionEvent {
  27062. /** The mesh or sprite that triggered the action */
  27063. source: any;
  27064. /** The X mouse cursor position at the time of the event */
  27065. pointerX: number;
  27066. /** The Y mouse cursor position at the time of the event */
  27067. pointerY: number;
  27068. /** The mesh that is currently pointed at (can be null) */
  27069. meshUnderPointer: Nullable<AbstractMesh>;
  27070. /** the original (browser) event that triggered the ActionEvent */
  27071. sourceEvent?: any;
  27072. /** additional data for the event */
  27073. additionalData?: any;
  27074. /**
  27075. * Creates a new ActionEvent
  27076. * @param source The mesh or sprite that triggered the action
  27077. * @param pointerX The X mouse cursor position at the time of the event
  27078. * @param pointerY The Y mouse cursor position at the time of the event
  27079. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27080. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27081. * @param additionalData additional data for the event
  27082. */
  27083. constructor(
  27084. /** The mesh or sprite that triggered the action */
  27085. source: any,
  27086. /** The X mouse cursor position at the time of the event */
  27087. pointerX: number,
  27088. /** The Y mouse cursor position at the time of the event */
  27089. pointerY: number,
  27090. /** The mesh that is currently pointed at (can be null) */
  27091. meshUnderPointer: Nullable<AbstractMesh>,
  27092. /** the original (browser) event that triggered the ActionEvent */
  27093. sourceEvent?: any,
  27094. /** additional data for the event */
  27095. additionalData?: any);
  27096. /**
  27097. * Helper function to auto-create an ActionEvent from a source mesh.
  27098. * @param source The source mesh that triggered the event
  27099. * @param evt The original (browser) event
  27100. * @param additionalData additional data for the event
  27101. * @returns the new ActionEvent
  27102. */
  27103. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27104. /**
  27105. * Helper function to auto-create an ActionEvent from a source sprite
  27106. * @param source The source sprite that triggered the event
  27107. * @param scene Scene associated with the sprite
  27108. * @param evt The original (browser) event
  27109. * @param additionalData additional data for the event
  27110. * @returns the new ActionEvent
  27111. */
  27112. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27113. /**
  27114. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27115. * @param scene the scene where the event occurred
  27116. * @param evt The original (browser) event
  27117. * @returns the new ActionEvent
  27118. */
  27119. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27120. /**
  27121. * Helper function to auto-create an ActionEvent from a primitive
  27122. * @param prim defines the target primitive
  27123. * @param pointerPos defines the pointer position
  27124. * @param evt The original (browser) event
  27125. * @param additionalData additional data for the event
  27126. * @returns the new ActionEvent
  27127. */
  27128. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27129. }
  27130. }
  27131. declare module "babylonjs/Actions/abstractActionManager" {
  27132. import { IDisposable } from "babylonjs/scene";
  27133. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27134. import { IAction } from "babylonjs/Actions/action";
  27135. import { Nullable } from "babylonjs/types";
  27136. /**
  27137. * Abstract class used to decouple action Manager from scene and meshes.
  27138. * Do not instantiate.
  27139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27140. */
  27141. export abstract class AbstractActionManager implements IDisposable {
  27142. /** Gets the list of active triggers */
  27143. static Triggers: {
  27144. [key: string]: number;
  27145. };
  27146. /** Gets the cursor to use when hovering items */
  27147. hoverCursor: string;
  27148. /** Gets the list of actions */
  27149. actions: IAction[];
  27150. /**
  27151. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27152. */
  27153. isRecursive: boolean;
  27154. /**
  27155. * Releases all associated resources
  27156. */
  27157. abstract dispose(): void;
  27158. /**
  27159. * Does this action manager has pointer triggers
  27160. */
  27161. abstract readonly hasPointerTriggers: boolean;
  27162. /**
  27163. * Does this action manager has pick triggers
  27164. */
  27165. abstract readonly hasPickTriggers: boolean;
  27166. /**
  27167. * Process a specific trigger
  27168. * @param trigger defines the trigger to process
  27169. * @param evt defines the event details to be processed
  27170. */
  27171. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27172. /**
  27173. * Does this action manager handles actions of any of the given triggers
  27174. * @param triggers defines the triggers to be tested
  27175. * @return a boolean indicating whether one (or more) of the triggers is handled
  27176. */
  27177. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27178. /**
  27179. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27180. * speed.
  27181. * @param triggerA defines the trigger to be tested
  27182. * @param triggerB defines the trigger to be tested
  27183. * @return a boolean indicating whether one (or more) of the triggers is handled
  27184. */
  27185. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27186. /**
  27187. * Does this action manager handles actions of a given trigger
  27188. * @param trigger defines the trigger to be tested
  27189. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27190. * @return whether the trigger is handled
  27191. */
  27192. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27193. /**
  27194. * Serialize this manager to a JSON object
  27195. * @param name defines the property name to store this manager
  27196. * @returns a JSON representation of this manager
  27197. */
  27198. abstract serialize(name: string): any;
  27199. /**
  27200. * Registers an action to this action manager
  27201. * @param action defines the action to be registered
  27202. * @return the action amended (prepared) after registration
  27203. */
  27204. abstract registerAction(action: IAction): Nullable<IAction>;
  27205. /**
  27206. * Unregisters an action to this action manager
  27207. * @param action defines the action to be unregistered
  27208. * @return a boolean indicating whether the action has been unregistered
  27209. */
  27210. abstract unregisterAction(action: IAction): Boolean;
  27211. /**
  27212. * Does exist one action manager with at least one trigger
  27213. **/
  27214. static readonly HasTriggers: boolean;
  27215. /**
  27216. * Does exist one action manager with at least one pick trigger
  27217. **/
  27218. static readonly HasPickTriggers: boolean;
  27219. /**
  27220. * Does exist one action manager that handles actions of a given trigger
  27221. * @param trigger defines the trigger to be tested
  27222. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27223. **/
  27224. static HasSpecificTrigger(trigger: number): boolean;
  27225. }
  27226. }
  27227. declare module "babylonjs/node" {
  27228. import { Scene } from "babylonjs/scene";
  27229. import { Nullable } from "babylonjs/types";
  27230. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27231. import { Engine } from "babylonjs/Engines/engine";
  27232. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27233. import { Observable } from "babylonjs/Misc/observable";
  27234. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27235. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27236. import { Animatable } from "babylonjs/Animations/animatable";
  27237. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27238. import { Animation } from "babylonjs/Animations/animation";
  27239. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27241. /**
  27242. * Defines how a node can be built from a string name.
  27243. */
  27244. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27245. /**
  27246. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27247. */
  27248. export class Node implements IBehaviorAware<Node> {
  27249. /** @hidden */
  27250. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27251. private static _NodeConstructors;
  27252. /**
  27253. * Add a new node constructor
  27254. * @param type defines the type name of the node to construct
  27255. * @param constructorFunc defines the constructor function
  27256. */
  27257. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27258. /**
  27259. * Returns a node constructor based on type name
  27260. * @param type defines the type name
  27261. * @param name defines the new node name
  27262. * @param scene defines the hosting scene
  27263. * @param options defines optional options to transmit to constructors
  27264. * @returns the new constructor or null
  27265. */
  27266. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27267. /**
  27268. * Gets or sets the name of the node
  27269. */
  27270. name: string;
  27271. /**
  27272. * Gets or sets the id of the node
  27273. */
  27274. id: string;
  27275. /**
  27276. * Gets or sets the unique id of the node
  27277. */
  27278. uniqueId: number;
  27279. /**
  27280. * Gets or sets a string used to store user defined state for the node
  27281. */
  27282. state: string;
  27283. /**
  27284. * Gets or sets an object used to store user defined information for the node
  27285. */
  27286. metadata: any;
  27287. /**
  27288. * For internal use only. Please do not use.
  27289. */
  27290. reservedDataStore: any;
  27291. /**
  27292. * List of inspectable custom properties (used by the Inspector)
  27293. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27294. */
  27295. inspectableCustomProperties: IInspectable[];
  27296. /**
  27297. * Gets or sets a boolean used to define if the node must be serialized
  27298. */
  27299. doNotSerialize: boolean;
  27300. /** @hidden */
  27301. _isDisposed: boolean;
  27302. /**
  27303. * Gets a list of Animations associated with the node
  27304. */
  27305. animations: import("babylonjs/Animations/animation").Animation[];
  27306. protected _ranges: {
  27307. [name: string]: Nullable<AnimationRange>;
  27308. };
  27309. /**
  27310. * Callback raised when the node is ready to be used
  27311. */
  27312. onReady: Nullable<(node: Node) => void>;
  27313. private _isEnabled;
  27314. private _isParentEnabled;
  27315. private _isReady;
  27316. /** @hidden */
  27317. _currentRenderId: number;
  27318. private _parentUpdateId;
  27319. /** @hidden */
  27320. _childUpdateId: number;
  27321. /** @hidden */
  27322. _waitingParentId: Nullable<string>;
  27323. /** @hidden */
  27324. _scene: Scene;
  27325. /** @hidden */
  27326. _cache: any;
  27327. private _parentNode;
  27328. private _children;
  27329. /** @hidden */
  27330. _worldMatrix: Matrix;
  27331. /** @hidden */
  27332. _worldMatrixDeterminant: number;
  27333. /** @hidden */
  27334. _worldMatrixDeterminantIsDirty: boolean;
  27335. /** @hidden */
  27336. private _sceneRootNodesIndex;
  27337. /**
  27338. * Gets a boolean indicating if the node has been disposed
  27339. * @returns true if the node was disposed
  27340. */
  27341. isDisposed(): boolean;
  27342. /**
  27343. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27344. * @see https://doc.babylonjs.com/how_to/parenting
  27345. */
  27346. parent: Nullable<Node>;
  27347. private addToSceneRootNodes;
  27348. private removeFromSceneRootNodes;
  27349. private _animationPropertiesOverride;
  27350. /**
  27351. * Gets or sets the animation properties override
  27352. */
  27353. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27354. /**
  27355. * Gets a string idenfifying the name of the class
  27356. * @returns "Node" string
  27357. */
  27358. getClassName(): string;
  27359. /** @hidden */
  27360. readonly _isNode: boolean;
  27361. /**
  27362. * An event triggered when the mesh is disposed
  27363. */
  27364. onDisposeObservable: Observable<Node>;
  27365. private _onDisposeObserver;
  27366. /**
  27367. * Sets a callback that will be raised when the node will be disposed
  27368. */
  27369. onDispose: () => void;
  27370. /**
  27371. * Creates a new Node
  27372. * @param name the name and id to be given to this node
  27373. * @param scene the scene this node will be added to
  27374. * @param addToRootNodes the node will be added to scene.rootNodes
  27375. */
  27376. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27377. /**
  27378. * Gets the scene of the node
  27379. * @returns a scene
  27380. */
  27381. getScene(): Scene;
  27382. /**
  27383. * Gets the engine of the node
  27384. * @returns a Engine
  27385. */
  27386. getEngine(): Engine;
  27387. private _behaviors;
  27388. /**
  27389. * Attach a behavior to the node
  27390. * @see http://doc.babylonjs.com/features/behaviour
  27391. * @param behavior defines the behavior to attach
  27392. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27393. * @returns the current Node
  27394. */
  27395. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27396. /**
  27397. * Remove an attached behavior
  27398. * @see http://doc.babylonjs.com/features/behaviour
  27399. * @param behavior defines the behavior to attach
  27400. * @returns the current Node
  27401. */
  27402. removeBehavior(behavior: Behavior<Node>): Node;
  27403. /**
  27404. * Gets the list of attached behaviors
  27405. * @see http://doc.babylonjs.com/features/behaviour
  27406. */
  27407. readonly behaviors: Behavior<Node>[];
  27408. /**
  27409. * Gets an attached behavior by name
  27410. * @param name defines the name of the behavior to look for
  27411. * @see http://doc.babylonjs.com/features/behaviour
  27412. * @returns null if behavior was not found else the requested behavior
  27413. */
  27414. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27415. /**
  27416. * Returns the latest update of the World matrix
  27417. * @returns a Matrix
  27418. */
  27419. getWorldMatrix(): Matrix;
  27420. /** @hidden */
  27421. _getWorldMatrixDeterminant(): number;
  27422. /**
  27423. * Returns directly the latest state of the mesh World matrix.
  27424. * A Matrix is returned.
  27425. */
  27426. readonly worldMatrixFromCache: Matrix;
  27427. /** @hidden */
  27428. _initCache(): void;
  27429. /** @hidden */
  27430. updateCache(force?: boolean): void;
  27431. /** @hidden */
  27432. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27433. /** @hidden */
  27434. _updateCache(ignoreParentClass?: boolean): void;
  27435. /** @hidden */
  27436. _isSynchronized(): boolean;
  27437. /** @hidden */
  27438. _markSyncedWithParent(): void;
  27439. /** @hidden */
  27440. isSynchronizedWithParent(): boolean;
  27441. /** @hidden */
  27442. isSynchronized(): boolean;
  27443. /**
  27444. * Is this node ready to be used/rendered
  27445. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27446. * @return true if the node is ready
  27447. */
  27448. isReady(completeCheck?: boolean): boolean;
  27449. /**
  27450. * Is this node enabled?
  27451. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  27452. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  27453. * @return whether this node (and its parent) is enabled
  27454. */
  27455. isEnabled(checkAncestors?: boolean): boolean;
  27456. /** @hidden */
  27457. protected _syncParentEnabledState(): void;
  27458. /**
  27459. * Set the enabled state of this node
  27460. * @param value defines the new enabled state
  27461. */
  27462. setEnabled(value: boolean): void;
  27463. /**
  27464. * Is this node a descendant of the given node?
  27465. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27466. * @param ancestor defines the parent node to inspect
  27467. * @returns a boolean indicating if this node is a descendant of the given node
  27468. */
  27469. isDescendantOf(ancestor: Node): boolean;
  27470. /** @hidden */
  27471. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27472. /**
  27473. * Will return all nodes that have this node as ascendant
  27474. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  27475. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27476. * @return all children nodes of all types
  27477. */
  27478. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27479. /**
  27480. * Get all child-meshes of this node
  27481. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  27482. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27483. * @returns an array of AbstractMesh
  27484. */
  27485. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27486. /**
  27487. * Get all direct children of this node
  27488. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27489. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  27490. * @returns an array of Node
  27491. */
  27492. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27493. /** @hidden */
  27494. _setReady(state: boolean): void;
  27495. /**
  27496. * Get an animation by name
  27497. * @param name defines the name of the animation to look for
  27498. * @returns null if not found else the requested animation
  27499. */
  27500. getAnimationByName(name: string): Nullable<Animation>;
  27501. /**
  27502. * Creates an animation range for this node
  27503. * @param name defines the name of the range
  27504. * @param from defines the starting key
  27505. * @param to defines the end key
  27506. */
  27507. createAnimationRange(name: string, from: number, to: number): void;
  27508. /**
  27509. * Delete a specific animation range
  27510. * @param name defines the name of the range to delete
  27511. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27512. */
  27513. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27514. /**
  27515. * Get an animation range by name
  27516. * @param name defines the name of the animation range to look for
  27517. * @returns null if not found else the requested animation range
  27518. */
  27519. getAnimationRange(name: string): Nullable<AnimationRange>;
  27520. /**
  27521. * Gets the list of all animation ranges defined on this node
  27522. * @returns an array
  27523. */
  27524. getAnimationRanges(): Nullable<AnimationRange>[];
  27525. /**
  27526. * Will start the animation sequence
  27527. * @param name defines the range frames for animation sequence
  27528. * @param loop defines if the animation should loop (false by default)
  27529. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27530. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27531. * @returns the object created for this animation. If range does not exist, it will return null
  27532. */
  27533. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27534. /**
  27535. * Serialize animation ranges into a JSON compatible object
  27536. * @returns serialization object
  27537. */
  27538. serializeAnimationRanges(): any;
  27539. /**
  27540. * Computes the world matrix of the node
  27541. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27542. * @returns the world matrix
  27543. */
  27544. computeWorldMatrix(force?: boolean): Matrix;
  27545. /**
  27546. * Releases resources associated with this node.
  27547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27549. */
  27550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27551. /**
  27552. * Parse animation range data from a serialization object and store them into a given node
  27553. * @param node defines where to store the animation ranges
  27554. * @param parsedNode defines the serialization object to read data from
  27555. * @param scene defines the hosting scene
  27556. */
  27557. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27558. /**
  27559. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27560. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27561. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  27562. * @returns the new bounding vectors
  27563. */
  27564. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27565. min: Vector3;
  27566. max: Vector3;
  27567. };
  27568. }
  27569. }
  27570. declare module "babylonjs/Animations/animation" {
  27571. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27572. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27573. import { Color3 } from "babylonjs/Maths/math.color";
  27574. import { Nullable } from "babylonjs/types";
  27575. import { Scene } from "babylonjs/scene";
  27576. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27577. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27578. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27579. import { Node } from "babylonjs/node";
  27580. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27581. import { Size } from "babylonjs/Maths/math.size";
  27582. import { Animatable } from "babylonjs/Animations/animatable";
  27583. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27584. /**
  27585. * @hidden
  27586. */
  27587. export class _IAnimationState {
  27588. key: number;
  27589. repeatCount: number;
  27590. workValue?: any;
  27591. loopMode?: number;
  27592. offsetValue?: any;
  27593. highLimitValue?: any;
  27594. }
  27595. /**
  27596. * Class used to store any kind of animation
  27597. */
  27598. export class Animation {
  27599. /**Name of the animation */
  27600. name: string;
  27601. /**Property to animate */
  27602. targetProperty: string;
  27603. /**The frames per second of the animation */
  27604. framePerSecond: number;
  27605. /**The data type of the animation */
  27606. dataType: number;
  27607. /**The loop mode of the animation */
  27608. loopMode?: number | undefined;
  27609. /**Specifies if blending should be enabled */
  27610. enableBlending?: boolean | undefined;
  27611. /**
  27612. * Use matrix interpolation instead of using direct key value when animating matrices
  27613. */
  27614. static AllowMatricesInterpolation: boolean;
  27615. /**
  27616. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27617. */
  27618. static AllowMatrixDecomposeForInterpolation: boolean;
  27619. /**
  27620. * Stores the key frames of the animation
  27621. */
  27622. private _keys;
  27623. /**
  27624. * Stores the easing function of the animation
  27625. */
  27626. private _easingFunction;
  27627. /**
  27628. * @hidden Internal use only
  27629. */
  27630. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27631. /**
  27632. * The set of event that will be linked to this animation
  27633. */
  27634. private _events;
  27635. /**
  27636. * Stores an array of target property paths
  27637. */
  27638. targetPropertyPath: string[];
  27639. /**
  27640. * Stores the blending speed of the animation
  27641. */
  27642. blendingSpeed: number;
  27643. /**
  27644. * Stores the animation ranges for the animation
  27645. */
  27646. private _ranges;
  27647. /**
  27648. * @hidden Internal use
  27649. */
  27650. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27651. /**
  27652. * Sets up an animation
  27653. * @param property The property to animate
  27654. * @param animationType The animation type to apply
  27655. * @param framePerSecond The frames per second of the animation
  27656. * @param easingFunction The easing function used in the animation
  27657. * @returns The created animation
  27658. */
  27659. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27660. /**
  27661. * Create and start an animation on a node
  27662. * @param name defines the name of the global animation that will be run on all nodes
  27663. * @param node defines the root node where the animation will take place
  27664. * @param targetProperty defines property to animate
  27665. * @param framePerSecond defines the number of frame per second yo use
  27666. * @param totalFrame defines the number of frames in total
  27667. * @param from defines the initial value
  27668. * @param to defines the final value
  27669. * @param loopMode defines which loop mode you want to use (off by default)
  27670. * @param easingFunction defines the easing function to use (linear by default)
  27671. * @param onAnimationEnd defines the callback to call when animation end
  27672. * @returns the animatable created for this animation
  27673. */
  27674. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27675. /**
  27676. * Create and start an animation on a node and its descendants
  27677. * @param name defines the name of the global animation that will be run on all nodes
  27678. * @param node defines the root node where the animation will take place
  27679. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  27680. * @param targetProperty defines property to animate
  27681. * @param framePerSecond defines the number of frame per second to use
  27682. * @param totalFrame defines the number of frames in total
  27683. * @param from defines the initial value
  27684. * @param to defines the final value
  27685. * @param loopMode defines which loop mode you want to use (off by default)
  27686. * @param easingFunction defines the easing function to use (linear by default)
  27687. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27688. * @returns the list of animatables created for all nodes
  27689. * @example https://www.babylonjs-playground.com/#MH0VLI
  27690. */
  27691. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  27692. /**
  27693. * Creates a new animation, merges it with the existing animations and starts it
  27694. * @param name Name of the animation
  27695. * @param node Node which contains the scene that begins the animations
  27696. * @param targetProperty Specifies which property to animate
  27697. * @param framePerSecond The frames per second of the animation
  27698. * @param totalFrame The total number of frames
  27699. * @param from The frame at the beginning of the animation
  27700. * @param to The frame at the end of the animation
  27701. * @param loopMode Specifies the loop mode of the animation
  27702. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27703. * @param onAnimationEnd Callback to run once the animation is complete
  27704. * @returns Nullable animation
  27705. */
  27706. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27707. /**
  27708. * Transition property of an host to the target Value
  27709. * @param property The property to transition
  27710. * @param targetValue The target Value of the property
  27711. * @param host The object where the property to animate belongs
  27712. * @param scene Scene used to run the animation
  27713. * @param frameRate Framerate (in frame/s) to use
  27714. * @param transition The transition type we want to use
  27715. * @param duration The duration of the animation, in milliseconds
  27716. * @param onAnimationEnd Callback trigger at the end of the animation
  27717. * @returns Nullable animation
  27718. */
  27719. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27720. /**
  27721. * Return the array of runtime animations currently using this animation
  27722. */
  27723. readonly runtimeAnimations: RuntimeAnimation[];
  27724. /**
  27725. * Specifies if any of the runtime animations are currently running
  27726. */
  27727. readonly hasRunningRuntimeAnimations: boolean;
  27728. /**
  27729. * Initializes the animation
  27730. * @param name Name of the animation
  27731. * @param targetProperty Property to animate
  27732. * @param framePerSecond The frames per second of the animation
  27733. * @param dataType The data type of the animation
  27734. * @param loopMode The loop mode of the animation
  27735. * @param enableBlending Specifies if blending should be enabled
  27736. */
  27737. constructor(
  27738. /**Name of the animation */
  27739. name: string,
  27740. /**Property to animate */
  27741. targetProperty: string,
  27742. /**The frames per second of the animation */
  27743. framePerSecond: number,
  27744. /**The data type of the animation */
  27745. dataType: number,
  27746. /**The loop mode of the animation */
  27747. loopMode?: number | undefined,
  27748. /**Specifies if blending should be enabled */
  27749. enableBlending?: boolean | undefined);
  27750. /**
  27751. * Converts the animation to a string
  27752. * @param fullDetails support for multiple levels of logging within scene loading
  27753. * @returns String form of the animation
  27754. */
  27755. toString(fullDetails?: boolean): string;
  27756. /**
  27757. * Add an event to this animation
  27758. * @param event Event to add
  27759. */
  27760. addEvent(event: AnimationEvent): void;
  27761. /**
  27762. * Remove all events found at the given frame
  27763. * @param frame The frame to remove events from
  27764. */
  27765. removeEvents(frame: number): void;
  27766. /**
  27767. * Retrieves all the events from the animation
  27768. * @returns Events from the animation
  27769. */
  27770. getEvents(): AnimationEvent[];
  27771. /**
  27772. * Creates an animation range
  27773. * @param name Name of the animation range
  27774. * @param from Starting frame of the animation range
  27775. * @param to Ending frame of the animation
  27776. */
  27777. createRange(name: string, from: number, to: number): void;
  27778. /**
  27779. * Deletes an animation range by name
  27780. * @param name Name of the animation range to delete
  27781. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27782. */
  27783. deleteRange(name: string, deleteFrames?: boolean): void;
  27784. /**
  27785. * Gets the animation range by name, or null if not defined
  27786. * @param name Name of the animation range
  27787. * @returns Nullable animation range
  27788. */
  27789. getRange(name: string): Nullable<AnimationRange>;
  27790. /**
  27791. * Gets the key frames from the animation
  27792. * @returns The key frames of the animation
  27793. */
  27794. getKeys(): Array<IAnimationKey>;
  27795. /**
  27796. * Gets the highest frame rate of the animation
  27797. * @returns Highest frame rate of the animation
  27798. */
  27799. getHighestFrame(): number;
  27800. /**
  27801. * Gets the easing function of the animation
  27802. * @returns Easing function of the animation
  27803. */
  27804. getEasingFunction(): IEasingFunction;
  27805. /**
  27806. * Sets the easing function of the animation
  27807. * @param easingFunction A custom mathematical formula for animation
  27808. */
  27809. setEasingFunction(easingFunction: EasingFunction): void;
  27810. /**
  27811. * Interpolates a scalar linearly
  27812. * @param startValue Start value of the animation curve
  27813. * @param endValue End value of the animation curve
  27814. * @param gradient Scalar amount to interpolate
  27815. * @returns Interpolated scalar value
  27816. */
  27817. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27818. /**
  27819. * Interpolates a scalar cubically
  27820. * @param startValue Start value of the animation curve
  27821. * @param outTangent End tangent of the animation
  27822. * @param endValue End value of the animation curve
  27823. * @param inTangent Start tangent of the animation curve
  27824. * @param gradient Scalar amount to interpolate
  27825. * @returns Interpolated scalar value
  27826. */
  27827. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27828. /**
  27829. * Interpolates a quaternion using a spherical linear interpolation
  27830. * @param startValue Start value of the animation curve
  27831. * @param endValue End value of the animation curve
  27832. * @param gradient Scalar amount to interpolate
  27833. * @returns Interpolated quaternion value
  27834. */
  27835. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27836. /**
  27837. * Interpolates a quaternion cubically
  27838. * @param startValue Start value of the animation curve
  27839. * @param outTangent End tangent of the animation curve
  27840. * @param endValue End value of the animation curve
  27841. * @param inTangent Start tangent of the animation curve
  27842. * @param gradient Scalar amount to interpolate
  27843. * @returns Interpolated quaternion value
  27844. */
  27845. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27846. /**
  27847. * Interpolates a Vector3 linearl
  27848. * @param startValue Start value of the animation curve
  27849. * @param endValue End value of the animation curve
  27850. * @param gradient Scalar amount to interpolate
  27851. * @returns Interpolated scalar value
  27852. */
  27853. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27854. /**
  27855. * Interpolates a Vector3 cubically
  27856. * @param startValue Start value of the animation curve
  27857. * @param outTangent End tangent of the animation
  27858. * @param endValue End value of the animation curve
  27859. * @param inTangent Start tangent of the animation curve
  27860. * @param gradient Scalar amount to interpolate
  27861. * @returns InterpolatedVector3 value
  27862. */
  27863. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27864. /**
  27865. * Interpolates a Vector2 linearly
  27866. * @param startValue Start value of the animation curve
  27867. * @param endValue End value of the animation curve
  27868. * @param gradient Scalar amount to interpolate
  27869. * @returns Interpolated Vector2 value
  27870. */
  27871. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27872. /**
  27873. * Interpolates a Vector2 cubically
  27874. * @param startValue Start value of the animation curve
  27875. * @param outTangent End tangent of the animation
  27876. * @param endValue End value of the animation curve
  27877. * @param inTangent Start tangent of the animation curve
  27878. * @param gradient Scalar amount to interpolate
  27879. * @returns Interpolated Vector2 value
  27880. */
  27881. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27882. /**
  27883. * Interpolates a size linearly
  27884. * @param startValue Start value of the animation curve
  27885. * @param endValue End value of the animation curve
  27886. * @param gradient Scalar amount to interpolate
  27887. * @returns Interpolated Size value
  27888. */
  27889. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27890. /**
  27891. * Interpolates a Color3 linearly
  27892. * @param startValue Start value of the animation curve
  27893. * @param endValue End value of the animation curve
  27894. * @param gradient Scalar amount to interpolate
  27895. * @returns Interpolated Color3 value
  27896. */
  27897. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27898. /**
  27899. * @hidden Internal use only
  27900. */
  27901. _getKeyValue(value: any): any;
  27902. /**
  27903. * @hidden Internal use only
  27904. */
  27905. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27906. /**
  27907. * Defines the function to use to interpolate matrices
  27908. * @param startValue defines the start matrix
  27909. * @param endValue defines the end matrix
  27910. * @param gradient defines the gradient between both matrices
  27911. * @param result defines an optional target matrix where to store the interpolation
  27912. * @returns the interpolated matrix
  27913. */
  27914. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27915. /**
  27916. * Makes a copy of the animation
  27917. * @returns Cloned animation
  27918. */
  27919. clone(): Animation;
  27920. /**
  27921. * Sets the key frames of the animation
  27922. * @param values The animation key frames to set
  27923. */
  27924. setKeys(values: Array<IAnimationKey>): void;
  27925. /**
  27926. * Serializes the animation to an object
  27927. * @returns Serialized object
  27928. */
  27929. serialize(): any;
  27930. /**
  27931. * Float animation type
  27932. */
  27933. private static _ANIMATIONTYPE_FLOAT;
  27934. /**
  27935. * Vector3 animation type
  27936. */
  27937. private static _ANIMATIONTYPE_VECTOR3;
  27938. /**
  27939. * Quaternion animation type
  27940. */
  27941. private static _ANIMATIONTYPE_QUATERNION;
  27942. /**
  27943. * Matrix animation type
  27944. */
  27945. private static _ANIMATIONTYPE_MATRIX;
  27946. /**
  27947. * Color3 animation type
  27948. */
  27949. private static _ANIMATIONTYPE_COLOR3;
  27950. /**
  27951. * Vector2 animation type
  27952. */
  27953. private static _ANIMATIONTYPE_VECTOR2;
  27954. /**
  27955. * Size animation type
  27956. */
  27957. private static _ANIMATIONTYPE_SIZE;
  27958. /**
  27959. * Relative Loop Mode
  27960. */
  27961. private static _ANIMATIONLOOPMODE_RELATIVE;
  27962. /**
  27963. * Cycle Loop Mode
  27964. */
  27965. private static _ANIMATIONLOOPMODE_CYCLE;
  27966. /**
  27967. * Constant Loop Mode
  27968. */
  27969. private static _ANIMATIONLOOPMODE_CONSTANT;
  27970. /**
  27971. * Get the float animation type
  27972. */
  27973. static readonly ANIMATIONTYPE_FLOAT: number;
  27974. /**
  27975. * Get the Vector3 animation type
  27976. */
  27977. static readonly ANIMATIONTYPE_VECTOR3: number;
  27978. /**
  27979. * Get the Vector2 animation type
  27980. */
  27981. static readonly ANIMATIONTYPE_VECTOR2: number;
  27982. /**
  27983. * Get the Size animation type
  27984. */
  27985. static readonly ANIMATIONTYPE_SIZE: number;
  27986. /**
  27987. * Get the Quaternion animation type
  27988. */
  27989. static readonly ANIMATIONTYPE_QUATERNION: number;
  27990. /**
  27991. * Get the Matrix animation type
  27992. */
  27993. static readonly ANIMATIONTYPE_MATRIX: number;
  27994. /**
  27995. * Get the Color3 animation type
  27996. */
  27997. static readonly ANIMATIONTYPE_COLOR3: number;
  27998. /**
  27999. * Get the Relative Loop Mode
  28000. */
  28001. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28002. /**
  28003. * Get the Cycle Loop Mode
  28004. */
  28005. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28006. /**
  28007. * Get the Constant Loop Mode
  28008. */
  28009. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28010. /** @hidden */
  28011. static _UniversalLerp(left: any, right: any, amount: number): any;
  28012. /**
  28013. * Parses an animation object and creates an animation
  28014. * @param parsedAnimation Parsed animation object
  28015. * @returns Animation object
  28016. */
  28017. static Parse(parsedAnimation: any): Animation;
  28018. /**
  28019. * Appends the serialized animations from the source animations
  28020. * @param source Source containing the animations
  28021. * @param destination Target to store the animations
  28022. */
  28023. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28024. }
  28025. }
  28026. declare module "babylonjs/Animations/animatable.interface" {
  28027. import { Nullable } from "babylonjs/types";
  28028. import { Animation } from "babylonjs/Animations/animation";
  28029. /**
  28030. * Interface containing an array of animations
  28031. */
  28032. export interface IAnimatable {
  28033. /**
  28034. * Array of animations
  28035. */
  28036. animations: Nullable<Array<Animation>>;
  28037. }
  28038. }
  28039. declare module "babylonjs/Materials/fresnelParameters" {
  28040. import { Color3 } from "babylonjs/Maths/math.color";
  28041. /**
  28042. * This represents all the required information to add a fresnel effect on a material:
  28043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28044. */
  28045. export class FresnelParameters {
  28046. private _isEnabled;
  28047. /**
  28048. * Define if the fresnel effect is enable or not.
  28049. */
  28050. isEnabled: boolean;
  28051. /**
  28052. * Define the color used on edges (grazing angle)
  28053. */
  28054. leftColor: Color3;
  28055. /**
  28056. * Define the color used on center
  28057. */
  28058. rightColor: Color3;
  28059. /**
  28060. * Define bias applied to computed fresnel term
  28061. */
  28062. bias: number;
  28063. /**
  28064. * Defined the power exponent applied to fresnel term
  28065. */
  28066. power: number;
  28067. /**
  28068. * Clones the current fresnel and its valuues
  28069. * @returns a clone fresnel configuration
  28070. */
  28071. clone(): FresnelParameters;
  28072. /**
  28073. * Serializes the current fresnel parameters to a JSON representation.
  28074. * @return the JSON serialization
  28075. */
  28076. serialize(): any;
  28077. /**
  28078. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28079. * @param parsedFresnelParameters Define the JSON representation
  28080. * @returns the parsed parameters
  28081. */
  28082. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28083. }
  28084. }
  28085. declare module "babylonjs/Misc/decorators" {
  28086. import { Nullable } from "babylonjs/types";
  28087. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28088. import { Scene } from "babylonjs/scene";
  28089. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28090. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28091. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28092. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28093. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28094. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28095. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28096. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28097. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28098. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28099. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28100. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28101. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28102. /**
  28103. * Decorator used to define property that can be serialized as reference to a camera
  28104. * @param sourceName defines the name of the property to decorate
  28105. */
  28106. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28107. /**
  28108. * Class used to help serialization objects
  28109. */
  28110. export class SerializationHelper {
  28111. /** @hidden */
  28112. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28113. /** @hidden */
  28114. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28115. /** @hidden */
  28116. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28117. /** @hidden */
  28118. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28119. /**
  28120. * Appends the serialized animations from the source animations
  28121. * @param source Source containing the animations
  28122. * @param destination Target to store the animations
  28123. */
  28124. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28125. /**
  28126. * Static function used to serialized a specific entity
  28127. * @param entity defines the entity to serialize
  28128. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28129. * @returns a JSON compatible object representing the serialization of the entity
  28130. */
  28131. static Serialize<T>(entity: T, serializationObject?: any): any;
  28132. /**
  28133. * Creates a new entity from a serialization data object
  28134. * @param creationFunction defines a function used to instanciated the new entity
  28135. * @param source defines the source serialization data
  28136. * @param scene defines the hosting scene
  28137. * @param rootUrl defines the root url for resources
  28138. * @returns a new entity
  28139. */
  28140. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28141. /**
  28142. * Clones an object
  28143. * @param creationFunction defines the function used to instanciate the new object
  28144. * @param source defines the source object
  28145. * @returns the cloned object
  28146. */
  28147. static Clone<T>(creationFunction: () => T, source: T): T;
  28148. /**
  28149. * Instanciates a new object based on a source one (some data will be shared between both object)
  28150. * @param creationFunction defines the function used to instanciate the new object
  28151. * @param source defines the source object
  28152. * @returns the new object
  28153. */
  28154. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28155. }
  28156. }
  28157. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28158. import { Nullable } from "babylonjs/types";
  28159. /**
  28160. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28161. */
  28162. export interface CubeMapInfo {
  28163. /**
  28164. * The pixel array for the front face.
  28165. * This is stored in format, left to right, up to down format.
  28166. */
  28167. front: Nullable<ArrayBufferView>;
  28168. /**
  28169. * The pixel array for the back face.
  28170. * This is stored in format, left to right, up to down format.
  28171. */
  28172. back: Nullable<ArrayBufferView>;
  28173. /**
  28174. * The pixel array for the left face.
  28175. * This is stored in format, left to right, up to down format.
  28176. */
  28177. left: Nullable<ArrayBufferView>;
  28178. /**
  28179. * The pixel array for the right face.
  28180. * This is stored in format, left to right, up to down format.
  28181. */
  28182. right: Nullable<ArrayBufferView>;
  28183. /**
  28184. * The pixel array for the up face.
  28185. * This is stored in format, left to right, up to down format.
  28186. */
  28187. up: Nullable<ArrayBufferView>;
  28188. /**
  28189. * The pixel array for the down face.
  28190. * This is stored in format, left to right, up to down format.
  28191. */
  28192. down: Nullable<ArrayBufferView>;
  28193. /**
  28194. * The size of the cubemap stored.
  28195. *
  28196. * Each faces will be size * size pixels.
  28197. */
  28198. size: number;
  28199. /**
  28200. * The format of the texture.
  28201. *
  28202. * RGBA, RGB.
  28203. */
  28204. format: number;
  28205. /**
  28206. * The type of the texture data.
  28207. *
  28208. * UNSIGNED_INT, FLOAT.
  28209. */
  28210. type: number;
  28211. /**
  28212. * Specifies whether the texture is in gamma space.
  28213. */
  28214. gammaSpace: boolean;
  28215. }
  28216. /**
  28217. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28218. */
  28219. export class PanoramaToCubeMapTools {
  28220. private static FACE_FRONT;
  28221. private static FACE_BACK;
  28222. private static FACE_RIGHT;
  28223. private static FACE_LEFT;
  28224. private static FACE_DOWN;
  28225. private static FACE_UP;
  28226. /**
  28227. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28228. *
  28229. * @param float32Array The source data.
  28230. * @param inputWidth The width of the input panorama.
  28231. * @param inputHeight The height of the input panorama.
  28232. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28233. * @return The cubemap data
  28234. */
  28235. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28236. private static CreateCubemapTexture;
  28237. private static CalcProjectionSpherical;
  28238. }
  28239. }
  28240. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28241. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28243. import { Nullable } from "babylonjs/types";
  28244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28245. /**
  28246. * Helper class dealing with the extraction of spherical polynomial dataArray
  28247. * from a cube map.
  28248. */
  28249. export class CubeMapToSphericalPolynomialTools {
  28250. private static FileFaces;
  28251. /**
  28252. * Converts a texture to the according Spherical Polynomial data.
  28253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28254. *
  28255. * @param texture The texture to extract the information from.
  28256. * @return The Spherical Polynomial data.
  28257. */
  28258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28259. /**
  28260. * Converts a cubemap to the according Spherical Polynomial data.
  28261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28262. *
  28263. * @param cubeInfo The Cube map to extract the information from.
  28264. * @return The Spherical Polynomial data.
  28265. */
  28266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28267. }
  28268. }
  28269. declare module "babylonjs/Misc/guid" {
  28270. /**
  28271. * Class used to manipulate GUIDs
  28272. */
  28273. export class GUID {
  28274. /**
  28275. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28276. * Be aware Math.random() could cause collisions, but:
  28277. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  28278. * @returns a pseudo random id
  28279. */
  28280. static RandomId(): string;
  28281. }
  28282. }
  28283. declare module "babylonjs/Materials/Textures/baseTexture" {
  28284. import { Observable } from "babylonjs/Misc/observable";
  28285. import { Nullable } from "babylonjs/types";
  28286. import { Scene } from "babylonjs/scene";
  28287. import { Matrix } from "babylonjs/Maths/math.vector";
  28288. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28289. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28290. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28291. import { ISize } from "babylonjs/Maths/math.size";
  28292. /**
  28293. * Base class of all the textures in babylon.
  28294. * It groups all the common properties the materials, post process, lights... might need
  28295. * in order to make a correct use of the texture.
  28296. */
  28297. export class BaseTexture implements IAnimatable {
  28298. /**
  28299. * Default anisotropic filtering level for the application.
  28300. * It is set to 4 as a good tradeoff between perf and quality.
  28301. */
  28302. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28303. /**
  28304. * Gets or sets the unique id of the texture
  28305. */
  28306. uniqueId: number;
  28307. /**
  28308. * Define the name of the texture.
  28309. */
  28310. name: string;
  28311. /**
  28312. * Gets or sets an object used to store user defined information.
  28313. */
  28314. metadata: any;
  28315. /**
  28316. * For internal use only. Please do not use.
  28317. */
  28318. reservedDataStore: any;
  28319. private _hasAlpha;
  28320. /**
  28321. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28322. */
  28323. hasAlpha: boolean;
  28324. /**
  28325. * Defines if the alpha value should be determined via the rgb values.
  28326. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28327. */
  28328. getAlphaFromRGB: boolean;
  28329. /**
  28330. * Intensity or strength of the texture.
  28331. * It is commonly used by materials to fine tune the intensity of the texture
  28332. */
  28333. level: number;
  28334. /**
  28335. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28336. * This is part of the texture as textures usually maps to one uv set.
  28337. */
  28338. coordinatesIndex: number;
  28339. private _coordinatesMode;
  28340. /**
  28341. * How a texture is mapped.
  28342. *
  28343. * | Value | Type | Description |
  28344. * | ----- | ----------------------------------- | ----------- |
  28345. * | 0 | EXPLICIT_MODE | |
  28346. * | 1 | SPHERICAL_MODE | |
  28347. * | 2 | PLANAR_MODE | |
  28348. * | 3 | CUBIC_MODE | |
  28349. * | 4 | PROJECTION_MODE | |
  28350. * | 5 | SKYBOX_MODE | |
  28351. * | 6 | INVCUBIC_MODE | |
  28352. * | 7 | EQUIRECTANGULAR_MODE | |
  28353. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28354. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28355. */
  28356. coordinatesMode: number;
  28357. /**
  28358. * | Value | Type | Description |
  28359. * | ----- | ------------------ | ----------- |
  28360. * | 0 | CLAMP_ADDRESSMODE | |
  28361. * | 1 | WRAP_ADDRESSMODE | |
  28362. * | 2 | MIRROR_ADDRESSMODE | |
  28363. */
  28364. wrapU: number;
  28365. /**
  28366. * | Value | Type | Description |
  28367. * | ----- | ------------------ | ----------- |
  28368. * | 0 | CLAMP_ADDRESSMODE | |
  28369. * | 1 | WRAP_ADDRESSMODE | |
  28370. * | 2 | MIRROR_ADDRESSMODE | |
  28371. */
  28372. wrapV: number;
  28373. /**
  28374. * | Value | Type | Description |
  28375. * | ----- | ------------------ | ----------- |
  28376. * | 0 | CLAMP_ADDRESSMODE | |
  28377. * | 1 | WRAP_ADDRESSMODE | |
  28378. * | 2 | MIRROR_ADDRESSMODE | |
  28379. */
  28380. wrapR: number;
  28381. /**
  28382. * With compliant hardware and browser (supporting anisotropic filtering)
  28383. * this defines the level of anisotropic filtering in the texture.
  28384. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28385. */
  28386. anisotropicFilteringLevel: number;
  28387. /**
  28388. * Define if the texture is a cube texture or if false a 2d texture.
  28389. */
  28390. isCube: boolean;
  28391. /**
  28392. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28393. */
  28394. is3D: boolean;
  28395. /**
  28396. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28397. * HDR texture are usually stored in linear space.
  28398. * This only impacts the PBR and Background materials
  28399. */
  28400. gammaSpace: boolean;
  28401. /**
  28402. * Gets whether or not the texture contains RGBD data.
  28403. */
  28404. readonly isRGBD: boolean;
  28405. /**
  28406. * Is Z inverted in the texture (useful in a cube texture).
  28407. */
  28408. invertZ: boolean;
  28409. /**
  28410. * Are mip maps generated for this texture or not.
  28411. */
  28412. readonly noMipmap: boolean;
  28413. /**
  28414. * @hidden
  28415. */
  28416. lodLevelInAlpha: boolean;
  28417. /**
  28418. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28419. */
  28420. lodGenerationOffset: number;
  28421. /**
  28422. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28423. */
  28424. lodGenerationScale: number;
  28425. /**
  28426. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28427. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28428. * average roughness values.
  28429. */
  28430. linearSpecularLOD: boolean;
  28431. /**
  28432. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28433. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28434. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28435. */
  28436. irradianceTexture: Nullable<BaseTexture>;
  28437. /**
  28438. * Define if the texture is a render target.
  28439. */
  28440. isRenderTarget: boolean;
  28441. /**
  28442. * Define the unique id of the texture in the scene.
  28443. */
  28444. readonly uid: string;
  28445. /**
  28446. * Return a string representation of the texture.
  28447. * @returns the texture as a string
  28448. */
  28449. toString(): string;
  28450. /**
  28451. * Get the class name of the texture.
  28452. * @returns "BaseTexture"
  28453. */
  28454. getClassName(): string;
  28455. /**
  28456. * Define the list of animation attached to the texture.
  28457. */
  28458. animations: import("babylonjs/Animations/animation").Animation[];
  28459. /**
  28460. * An event triggered when the texture is disposed.
  28461. */
  28462. onDisposeObservable: Observable<BaseTexture>;
  28463. private _onDisposeObserver;
  28464. /**
  28465. * Callback triggered when the texture has been disposed.
  28466. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28467. */
  28468. onDispose: () => void;
  28469. /**
  28470. * Define the current state of the loading sequence when in delayed load mode.
  28471. */
  28472. delayLoadState: number;
  28473. private _scene;
  28474. /** @hidden */
  28475. _texture: Nullable<InternalTexture>;
  28476. private _uid;
  28477. /**
  28478. * Define if the texture is preventinga material to render or not.
  28479. * If not and the texture is not ready, the engine will use a default black texture instead.
  28480. */
  28481. readonly isBlocking: boolean;
  28482. /**
  28483. * Instantiates a new BaseTexture.
  28484. * Base class of all the textures in babylon.
  28485. * It groups all the common properties the materials, post process, lights... might need
  28486. * in order to make a correct use of the texture.
  28487. * @param scene Define the scene the texture blongs to
  28488. */
  28489. constructor(scene: Nullable<Scene>);
  28490. /**
  28491. * Get the scene the texture belongs to.
  28492. * @returns the scene or null if undefined
  28493. */
  28494. getScene(): Nullable<Scene>;
  28495. /**
  28496. * Get the texture transform matrix used to offset tile the texture for istance.
  28497. * @returns the transformation matrix
  28498. */
  28499. getTextureMatrix(): Matrix;
  28500. /**
  28501. * Get the texture reflection matrix used to rotate/transform the reflection.
  28502. * @returns the reflection matrix
  28503. */
  28504. getReflectionTextureMatrix(): Matrix;
  28505. /**
  28506. * Get the underlying lower level texture from Babylon.
  28507. * @returns the insternal texture
  28508. */
  28509. getInternalTexture(): Nullable<InternalTexture>;
  28510. /**
  28511. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28512. * @returns true if ready or not blocking
  28513. */
  28514. isReadyOrNotBlocking(): boolean;
  28515. /**
  28516. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28517. * @returns true if fully ready
  28518. */
  28519. isReady(): boolean;
  28520. private _cachedSize;
  28521. /**
  28522. * Get the size of the texture.
  28523. * @returns the texture size.
  28524. */
  28525. getSize(): ISize;
  28526. /**
  28527. * Get the base size of the texture.
  28528. * It can be different from the size if the texture has been resized for POT for instance
  28529. * @returns the base size
  28530. */
  28531. getBaseSize(): ISize;
  28532. /**
  28533. * Update the sampling mode of the texture.
  28534. * Default is Trilinear mode.
  28535. *
  28536. * | Value | Type | Description |
  28537. * | ----- | ------------------ | ----------- |
  28538. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28539. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28540. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28541. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28542. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28543. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28544. * | 7 | NEAREST_LINEAR | |
  28545. * | 8 | NEAREST_NEAREST | |
  28546. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28547. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28548. * | 11 | LINEAR_LINEAR | |
  28549. * | 12 | LINEAR_NEAREST | |
  28550. *
  28551. * > _mag_: magnification filter (close to the viewer)
  28552. * > _min_: minification filter (far from the viewer)
  28553. * > _mip_: filter used between mip map levels
  28554. *@param samplingMode Define the new sampling mode of the texture
  28555. */
  28556. updateSamplingMode(samplingMode: number): void;
  28557. /**
  28558. * Scales the texture if is `canRescale()`
  28559. * @param ratio the resize factor we want to use to rescale
  28560. */
  28561. scale(ratio: number): void;
  28562. /**
  28563. * Get if the texture can rescale.
  28564. */
  28565. readonly canRescale: boolean;
  28566. /** @hidden */
  28567. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28568. /** @hidden */
  28569. _rebuild(): void;
  28570. /**
  28571. * Triggers the load sequence in delayed load mode.
  28572. */
  28573. delayLoad(): void;
  28574. /**
  28575. * Clones the texture.
  28576. * @returns the cloned texture
  28577. */
  28578. clone(): Nullable<BaseTexture>;
  28579. /**
  28580. * Get the texture underlying type (INT, FLOAT...)
  28581. */
  28582. readonly textureType: number;
  28583. /**
  28584. * Get the texture underlying format (RGB, RGBA...)
  28585. */
  28586. readonly textureFormat: number;
  28587. /**
  28588. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28589. * This will returns an RGBA array buffer containing either in values (0-255) or
  28590. * float values (0-1) depending of the underlying buffer type.
  28591. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28592. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28593. * @param buffer defines a user defined buffer to fill with data (can be null)
  28594. * @returns The Array buffer containing the pixels data.
  28595. */
  28596. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28597. /**
  28598. * Release and destroy the underlying lower level texture aka internalTexture.
  28599. */
  28600. releaseInternalTexture(): void;
  28601. /**
  28602. * Get the polynomial representation of the texture data.
  28603. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28604. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28605. */
  28606. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28607. /** @hidden */
  28608. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28609. /** @hidden */
  28610. readonly _lodTextureMid: Nullable<BaseTexture>;
  28611. /** @hidden */
  28612. readonly _lodTextureLow: Nullable<BaseTexture>;
  28613. /**
  28614. * Dispose the texture and release its associated resources.
  28615. */
  28616. dispose(): void;
  28617. /**
  28618. * Serialize the texture into a JSON representation that can be parsed later on.
  28619. * @returns the JSON representation of the texture
  28620. */
  28621. serialize(): any;
  28622. /**
  28623. * Helper function to be called back once a list of texture contains only ready textures.
  28624. * @param textures Define the list of textures to wait for
  28625. * @param callback Define the callback triggered once the entire list will be ready
  28626. */
  28627. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28628. }
  28629. }
  28630. declare module "babylonjs/Materials/Textures/internalTexture" {
  28631. import { Observable } from "babylonjs/Misc/observable";
  28632. import { Nullable, int } from "babylonjs/types";
  28633. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28634. import { Engine } from "babylonjs/Engines/engine";
  28635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28636. /**
  28637. * Class used to store data associated with WebGL texture data for the engine
  28638. * This class should not be used directly
  28639. */
  28640. export class InternalTexture {
  28641. /** @hidden */
  28642. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28643. /**
  28644. * The source of the texture data is unknown
  28645. */
  28646. static DATASOURCE_UNKNOWN: number;
  28647. /**
  28648. * Texture data comes from an URL
  28649. */
  28650. static DATASOURCE_URL: number;
  28651. /**
  28652. * Texture data is only used for temporary storage
  28653. */
  28654. static DATASOURCE_TEMP: number;
  28655. /**
  28656. * Texture data comes from raw data (ArrayBuffer)
  28657. */
  28658. static DATASOURCE_RAW: number;
  28659. /**
  28660. * Texture content is dynamic (video or dynamic texture)
  28661. */
  28662. static DATASOURCE_DYNAMIC: number;
  28663. /**
  28664. * Texture content is generated by rendering to it
  28665. */
  28666. static DATASOURCE_RENDERTARGET: number;
  28667. /**
  28668. * Texture content is part of a multi render target process
  28669. */
  28670. static DATASOURCE_MULTIRENDERTARGET: number;
  28671. /**
  28672. * Texture data comes from a cube data file
  28673. */
  28674. static DATASOURCE_CUBE: number;
  28675. /**
  28676. * Texture data comes from a raw cube data
  28677. */
  28678. static DATASOURCE_CUBERAW: number;
  28679. /**
  28680. * Texture data come from a prefiltered cube data file
  28681. */
  28682. static DATASOURCE_CUBEPREFILTERED: number;
  28683. /**
  28684. * Texture content is raw 3D data
  28685. */
  28686. static DATASOURCE_RAW3D: number;
  28687. /**
  28688. * Texture content is a depth texture
  28689. */
  28690. static DATASOURCE_DEPTHTEXTURE: number;
  28691. /**
  28692. * Texture data comes from a raw cube data encoded with RGBD
  28693. */
  28694. static DATASOURCE_CUBERAW_RGBD: number;
  28695. /**
  28696. * Defines if the texture is ready
  28697. */
  28698. isReady: boolean;
  28699. /**
  28700. * Defines if the texture is a cube texture
  28701. */
  28702. isCube: boolean;
  28703. /**
  28704. * Defines if the texture contains 3D data
  28705. */
  28706. is3D: boolean;
  28707. /**
  28708. * Defines if the texture contains multiview data
  28709. */
  28710. isMultiview: boolean;
  28711. /**
  28712. * Gets the URL used to load this texture
  28713. */
  28714. url: string;
  28715. /**
  28716. * Gets the sampling mode of the texture
  28717. */
  28718. samplingMode: number;
  28719. /**
  28720. * Gets a boolean indicating if the texture needs mipmaps generation
  28721. */
  28722. generateMipMaps: boolean;
  28723. /**
  28724. * Gets the number of samples used by the texture (WebGL2+ only)
  28725. */
  28726. samples: number;
  28727. /**
  28728. * Gets the type of the texture (int, float...)
  28729. */
  28730. type: number;
  28731. /**
  28732. * Gets the format of the texture (RGB, RGBA...)
  28733. */
  28734. format: number;
  28735. /**
  28736. * Observable called when the texture is loaded
  28737. */
  28738. onLoadedObservable: Observable<InternalTexture>;
  28739. /**
  28740. * Gets the width of the texture
  28741. */
  28742. width: number;
  28743. /**
  28744. * Gets the height of the texture
  28745. */
  28746. height: number;
  28747. /**
  28748. * Gets the depth of the texture
  28749. */
  28750. depth: number;
  28751. /**
  28752. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28753. */
  28754. baseWidth: number;
  28755. /**
  28756. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28757. */
  28758. baseHeight: number;
  28759. /**
  28760. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28761. */
  28762. baseDepth: number;
  28763. /**
  28764. * Gets a boolean indicating if the texture is inverted on Y axis
  28765. */
  28766. invertY: boolean;
  28767. /** @hidden */
  28768. _invertVScale: boolean;
  28769. /** @hidden */
  28770. _associatedChannel: number;
  28771. /** @hidden */
  28772. _dataSource: number;
  28773. /** @hidden */
  28774. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28775. /** @hidden */
  28776. _bufferView: Nullable<ArrayBufferView>;
  28777. /** @hidden */
  28778. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28779. /** @hidden */
  28780. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28781. /** @hidden */
  28782. _size: number;
  28783. /** @hidden */
  28784. _extension: string;
  28785. /** @hidden */
  28786. _files: Nullable<string[]>;
  28787. /** @hidden */
  28788. _workingCanvas: Nullable<HTMLCanvasElement>;
  28789. /** @hidden */
  28790. _workingContext: Nullable<CanvasRenderingContext2D>;
  28791. /** @hidden */
  28792. _framebuffer: Nullable<WebGLFramebuffer>;
  28793. /** @hidden */
  28794. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28795. /** @hidden */
  28796. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28797. /** @hidden */
  28798. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28799. /** @hidden */
  28800. _attachments: Nullable<number[]>;
  28801. /** @hidden */
  28802. _cachedCoordinatesMode: Nullable<number>;
  28803. /** @hidden */
  28804. _cachedWrapU: Nullable<number>;
  28805. /** @hidden */
  28806. _cachedWrapV: Nullable<number>;
  28807. /** @hidden */
  28808. _cachedWrapR: Nullable<number>;
  28809. /** @hidden */
  28810. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28811. /** @hidden */
  28812. _isDisabled: boolean;
  28813. /** @hidden */
  28814. _compression: Nullable<string>;
  28815. /** @hidden */
  28816. _generateStencilBuffer: boolean;
  28817. /** @hidden */
  28818. _generateDepthBuffer: boolean;
  28819. /** @hidden */
  28820. _comparisonFunction: number;
  28821. /** @hidden */
  28822. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28823. /** @hidden */
  28824. _lodGenerationScale: number;
  28825. /** @hidden */
  28826. _lodGenerationOffset: number;
  28827. /** @hidden */
  28828. _colorTextureArray: Nullable<WebGLTexture>;
  28829. /** @hidden */
  28830. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28831. /** @hidden */
  28832. _lodTextureHigh: Nullable<BaseTexture>;
  28833. /** @hidden */
  28834. _lodTextureMid: Nullable<BaseTexture>;
  28835. /** @hidden */
  28836. _lodTextureLow: Nullable<BaseTexture>;
  28837. /** @hidden */
  28838. _isRGBD: boolean;
  28839. /** @hidden */
  28840. _linearSpecularLOD: boolean;
  28841. /** @hidden */
  28842. _irradianceTexture: Nullable<BaseTexture>;
  28843. /** @hidden */
  28844. _webGLTexture: Nullable<WebGLTexture>;
  28845. /** @hidden */
  28846. _references: number;
  28847. private _engine;
  28848. /**
  28849. * Gets the Engine the texture belongs to.
  28850. * @returns The babylon engine
  28851. */
  28852. getEngine(): Engine;
  28853. /**
  28854. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28855. */
  28856. readonly dataSource: number;
  28857. /**
  28858. * Creates a new InternalTexture
  28859. * @param engine defines the engine to use
  28860. * @param dataSource defines the type of data that will be used
  28861. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28862. */
  28863. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28864. /**
  28865. * Increments the number of references (ie. the number of Texture that point to it)
  28866. */
  28867. incrementReferences(): void;
  28868. /**
  28869. * Change the size of the texture (not the size of the content)
  28870. * @param width defines the new width
  28871. * @param height defines the new height
  28872. * @param depth defines the new depth (1 by default)
  28873. */
  28874. updateSize(width: int, height: int, depth?: int): void;
  28875. /** @hidden */
  28876. _rebuild(): void;
  28877. /** @hidden */
  28878. _swapAndDie(target: InternalTexture): void;
  28879. /**
  28880. * Dispose the current allocated resources
  28881. */
  28882. dispose(): void;
  28883. }
  28884. }
  28885. declare module "babylonjs/Materials/effect" {
  28886. import { Observable } from "babylonjs/Misc/observable";
  28887. import { Nullable } from "babylonjs/types";
  28888. import { IDisposable } from "babylonjs/scene";
  28889. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28890. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28891. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28892. import { Engine } from "babylonjs/Engines/engine";
  28893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28896. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28898. /**
  28899. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28900. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28901. */
  28902. export class EffectFallbacks {
  28903. private _defines;
  28904. private _currentRank;
  28905. private _maxRank;
  28906. private _mesh;
  28907. /**
  28908. * Removes the fallback from the bound mesh.
  28909. */
  28910. unBindMesh(): void;
  28911. /**
  28912. * Adds a fallback on the specified property.
  28913. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28914. * @param define The name of the define in the shader
  28915. */
  28916. addFallback(rank: number, define: string): void;
  28917. /**
  28918. * Sets the mesh to use CPU skinning when needing to fallback.
  28919. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28920. * @param mesh The mesh to use the fallbacks.
  28921. */
  28922. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28923. /**
  28924. * Checks to see if more fallbacks are still availible.
  28925. */
  28926. readonly isMoreFallbacks: boolean;
  28927. /**
  28928. * Removes the defines that should be removed when falling back.
  28929. * @param currentDefines defines the current define statements for the shader.
  28930. * @param effect defines the current effect we try to compile
  28931. * @returns The resulting defines with defines of the current rank removed.
  28932. */
  28933. reduce(currentDefines: string, effect: Effect): string;
  28934. }
  28935. /**
  28936. * Options to be used when creating an effect.
  28937. */
  28938. export class EffectCreationOptions {
  28939. /**
  28940. * Atrributes that will be used in the shader.
  28941. */
  28942. attributes: string[];
  28943. /**
  28944. * Uniform varible names that will be set in the shader.
  28945. */
  28946. uniformsNames: string[];
  28947. /**
  28948. * Uniform buffer varible names that will be set in the shader.
  28949. */
  28950. uniformBuffersNames: string[];
  28951. /**
  28952. * Sampler texture variable names that will be set in the shader.
  28953. */
  28954. samplers: string[];
  28955. /**
  28956. * Define statements that will be set in the shader.
  28957. */
  28958. defines: any;
  28959. /**
  28960. * Possible fallbacks for this effect to improve performance when needed.
  28961. */
  28962. fallbacks: Nullable<EffectFallbacks>;
  28963. /**
  28964. * Callback that will be called when the shader is compiled.
  28965. */
  28966. onCompiled: Nullable<(effect: Effect) => void>;
  28967. /**
  28968. * Callback that will be called if an error occurs during shader compilation.
  28969. */
  28970. onError: Nullable<(effect: Effect, errors: string) => void>;
  28971. /**
  28972. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28973. */
  28974. indexParameters: any;
  28975. /**
  28976. * Max number of lights that can be used in the shader.
  28977. */
  28978. maxSimultaneousLights: number;
  28979. /**
  28980. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28981. */
  28982. transformFeedbackVaryings: Nullable<string[]>;
  28983. }
  28984. /**
  28985. * Effect containing vertex and fragment shader that can be executed on an object.
  28986. */
  28987. export class Effect implements IDisposable {
  28988. /**
  28989. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28990. */
  28991. static ShadersRepository: string;
  28992. /**
  28993. * Name of the effect.
  28994. */
  28995. name: any;
  28996. /**
  28997. * String container all the define statements that should be set on the shader.
  28998. */
  28999. defines: string;
  29000. /**
  29001. * Callback that will be called when the shader is compiled.
  29002. */
  29003. onCompiled: Nullable<(effect: Effect) => void>;
  29004. /**
  29005. * Callback that will be called if an error occurs during shader compilation.
  29006. */
  29007. onError: Nullable<(effect: Effect, errors: string) => void>;
  29008. /**
  29009. * Callback that will be called when effect is bound.
  29010. */
  29011. onBind: Nullable<(effect: Effect) => void>;
  29012. /**
  29013. * Unique ID of the effect.
  29014. */
  29015. uniqueId: number;
  29016. /**
  29017. * Observable that will be called when the shader is compiled.
  29018. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29019. */
  29020. onCompileObservable: Observable<Effect>;
  29021. /**
  29022. * Observable that will be called if an error occurs during shader compilation.
  29023. */
  29024. onErrorObservable: Observable<Effect>;
  29025. /** @hidden */
  29026. _onBindObservable: Nullable<Observable<Effect>>;
  29027. /**
  29028. * Observable that will be called when effect is bound.
  29029. */
  29030. readonly onBindObservable: Observable<Effect>;
  29031. /** @hidden */
  29032. _bonesComputationForcedToCPU: boolean;
  29033. private static _uniqueIdSeed;
  29034. private _engine;
  29035. private _uniformBuffersNames;
  29036. private _uniformsNames;
  29037. private _samplerList;
  29038. private _samplers;
  29039. private _isReady;
  29040. private _compilationError;
  29041. private _attributesNames;
  29042. private _attributes;
  29043. private _uniforms;
  29044. /**
  29045. * Key for the effect.
  29046. * @hidden
  29047. */
  29048. _key: string;
  29049. private _indexParameters;
  29050. private _fallbacks;
  29051. private _vertexSourceCode;
  29052. private _fragmentSourceCode;
  29053. private _vertexSourceCodeOverride;
  29054. private _fragmentSourceCodeOverride;
  29055. private _transformFeedbackVaryings;
  29056. /**
  29057. * Compiled shader to webGL program.
  29058. * @hidden
  29059. */
  29060. _pipelineContext: Nullable<IPipelineContext>;
  29061. private _valueCache;
  29062. private static _baseCache;
  29063. /**
  29064. * Instantiates an effect.
  29065. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29066. * @param baseName Name of the effect.
  29067. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29068. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29069. * @param samplers List of sampler variables that will be passed to the shader.
  29070. * @param engine Engine to be used to render the effect
  29071. * @param defines Define statements to be added to the shader.
  29072. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29073. * @param onCompiled Callback that will be called when the shader is compiled.
  29074. * @param onError Callback that will be called if an error occurs during shader compilation.
  29075. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29076. */
  29077. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29078. private _useFinalCode;
  29079. /**
  29080. * Unique key for this effect
  29081. */
  29082. readonly key: string;
  29083. /**
  29084. * If the effect has been compiled and prepared.
  29085. * @returns if the effect is compiled and prepared.
  29086. */
  29087. isReady(): boolean;
  29088. /**
  29089. * The engine the effect was initialized with.
  29090. * @returns the engine.
  29091. */
  29092. getEngine(): Engine;
  29093. /**
  29094. * The pipeline context for this effect
  29095. * @returns the associated pipeline context
  29096. */
  29097. getPipelineContext(): Nullable<IPipelineContext>;
  29098. /**
  29099. * The set of names of attribute variables for the shader.
  29100. * @returns An array of attribute names.
  29101. */
  29102. getAttributesNames(): string[];
  29103. /**
  29104. * Returns the attribute at the given index.
  29105. * @param index The index of the attribute.
  29106. * @returns The location of the attribute.
  29107. */
  29108. getAttributeLocation(index: number): number;
  29109. /**
  29110. * Returns the attribute based on the name of the variable.
  29111. * @param name of the attribute to look up.
  29112. * @returns the attribute location.
  29113. */
  29114. getAttributeLocationByName(name: string): number;
  29115. /**
  29116. * The number of attributes.
  29117. * @returns the numnber of attributes.
  29118. */
  29119. getAttributesCount(): number;
  29120. /**
  29121. * Gets the index of a uniform variable.
  29122. * @param uniformName of the uniform to look up.
  29123. * @returns the index.
  29124. */
  29125. getUniformIndex(uniformName: string): number;
  29126. /**
  29127. * Returns the attribute based on the name of the variable.
  29128. * @param uniformName of the uniform to look up.
  29129. * @returns the location of the uniform.
  29130. */
  29131. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29132. /**
  29133. * Returns an array of sampler variable names
  29134. * @returns The array of sampler variable neames.
  29135. */
  29136. getSamplers(): string[];
  29137. /**
  29138. * The error from the last compilation.
  29139. * @returns the error string.
  29140. */
  29141. getCompilationError(): string;
  29142. /**
  29143. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29144. * @param func The callback to be used.
  29145. */
  29146. executeWhenCompiled(func: (effect: Effect) => void): void;
  29147. private _checkIsReady;
  29148. /** @hidden */
  29149. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29150. /** @hidden */
  29151. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29152. /** @hidden */
  29153. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29154. /**
  29155. * Recompiles the webGL program
  29156. * @param vertexSourceCode The source code for the vertex shader.
  29157. * @param fragmentSourceCode The source code for the fragment shader.
  29158. * @param onCompiled Callback called when completed.
  29159. * @param onError Callback called on error.
  29160. * @hidden
  29161. */
  29162. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29163. /**
  29164. * Prepares the effect
  29165. * @hidden
  29166. */
  29167. _prepareEffect(): void;
  29168. /**
  29169. * Checks if the effect is supported. (Must be called after compilation)
  29170. */
  29171. readonly isSupported: boolean;
  29172. /**
  29173. * Binds a texture to the engine to be used as output of the shader.
  29174. * @param channel Name of the output variable.
  29175. * @param texture Texture to bind.
  29176. * @hidden
  29177. */
  29178. _bindTexture(channel: string, texture: InternalTexture): void;
  29179. /**
  29180. * Sets a texture on the engine to be used in the shader.
  29181. * @param channel Name of the sampler variable.
  29182. * @param texture Texture to set.
  29183. */
  29184. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29185. /**
  29186. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29187. * @param channel Name of the sampler variable.
  29188. * @param texture Texture to set.
  29189. */
  29190. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29191. /**
  29192. * Sets an array of textures on the engine to be used in the shader.
  29193. * @param channel Name of the variable.
  29194. * @param textures Textures to set.
  29195. */
  29196. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29197. /**
  29198. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  29199. * @param channel Name of the sampler variable.
  29200. * @param postProcess Post process to get the input texture from.
  29201. */
  29202. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29203. /**
  29204. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29205. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  29206. * @param channel Name of the sampler variable.
  29207. * @param postProcess Post process to get the output texture from.
  29208. */
  29209. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29210. /** @hidden */
  29211. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29212. /** @hidden */
  29213. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29214. /** @hidden */
  29215. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29216. /** @hidden */
  29217. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29218. /**
  29219. * Binds a buffer to a uniform.
  29220. * @param buffer Buffer to bind.
  29221. * @param name Name of the uniform variable to bind to.
  29222. */
  29223. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29224. /**
  29225. * Binds block to a uniform.
  29226. * @param blockName Name of the block to bind.
  29227. * @param index Index to bind.
  29228. */
  29229. bindUniformBlock(blockName: string, index: number): void;
  29230. /**
  29231. * Sets an interger value on a uniform variable.
  29232. * @param uniformName Name of the variable.
  29233. * @param value Value to be set.
  29234. * @returns this effect.
  29235. */
  29236. setInt(uniformName: string, value: number): Effect;
  29237. /**
  29238. * Sets an int array on a uniform variable.
  29239. * @param uniformName Name of the variable.
  29240. * @param array array to be set.
  29241. * @returns this effect.
  29242. */
  29243. setIntArray(uniformName: string, array: Int32Array): Effect;
  29244. /**
  29245. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29246. * @param uniformName Name of the variable.
  29247. * @param array array to be set.
  29248. * @returns this effect.
  29249. */
  29250. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29251. /**
  29252. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29253. * @param uniformName Name of the variable.
  29254. * @param array array to be set.
  29255. * @returns this effect.
  29256. */
  29257. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29258. /**
  29259. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29260. * @param uniformName Name of the variable.
  29261. * @param array array to be set.
  29262. * @returns this effect.
  29263. */
  29264. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29265. /**
  29266. * Sets an float array on a uniform variable.
  29267. * @param uniformName Name of the variable.
  29268. * @param array array to be set.
  29269. * @returns this effect.
  29270. */
  29271. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29272. /**
  29273. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29274. * @param uniformName Name of the variable.
  29275. * @param array array to be set.
  29276. * @returns this effect.
  29277. */
  29278. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29279. /**
  29280. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29281. * @param uniformName Name of the variable.
  29282. * @param array array to be set.
  29283. * @returns this effect.
  29284. */
  29285. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29286. /**
  29287. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29288. * @param uniformName Name of the variable.
  29289. * @param array array to be set.
  29290. * @returns this effect.
  29291. */
  29292. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29293. /**
  29294. * Sets an array on a uniform variable.
  29295. * @param uniformName Name of the variable.
  29296. * @param array array to be set.
  29297. * @returns this effect.
  29298. */
  29299. setArray(uniformName: string, array: number[]): Effect;
  29300. /**
  29301. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29302. * @param uniformName Name of the variable.
  29303. * @param array array to be set.
  29304. * @returns this effect.
  29305. */
  29306. setArray2(uniformName: string, array: number[]): Effect;
  29307. /**
  29308. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29309. * @param uniformName Name of the variable.
  29310. * @param array array to be set.
  29311. * @returns this effect.
  29312. */
  29313. setArray3(uniformName: string, array: number[]): Effect;
  29314. /**
  29315. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29316. * @param uniformName Name of the variable.
  29317. * @param array array to be set.
  29318. * @returns this effect.
  29319. */
  29320. setArray4(uniformName: string, array: number[]): Effect;
  29321. /**
  29322. * Sets matrices on a uniform variable.
  29323. * @param uniformName Name of the variable.
  29324. * @param matrices matrices to be set.
  29325. * @returns this effect.
  29326. */
  29327. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29328. /**
  29329. * Sets matrix on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param matrix matrix to be set.
  29332. * @returns this effect.
  29333. */
  29334. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29335. /**
  29336. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  29337. * @param uniformName Name of the variable.
  29338. * @param matrix matrix to be set.
  29339. * @returns this effect.
  29340. */
  29341. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29342. /**
  29343. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29344. * @param uniformName Name of the variable.
  29345. * @param matrix matrix to be set.
  29346. * @returns this effect.
  29347. */
  29348. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29349. /**
  29350. * Sets a float on a uniform variable.
  29351. * @param uniformName Name of the variable.
  29352. * @param value value to be set.
  29353. * @returns this effect.
  29354. */
  29355. setFloat(uniformName: string, value: number): Effect;
  29356. /**
  29357. * Sets a boolean on a uniform variable.
  29358. * @param uniformName Name of the variable.
  29359. * @param bool value to be set.
  29360. * @returns this effect.
  29361. */
  29362. setBool(uniformName: string, bool: boolean): Effect;
  29363. /**
  29364. * Sets a Vector2 on a uniform variable.
  29365. * @param uniformName Name of the variable.
  29366. * @param vector2 vector2 to be set.
  29367. * @returns this effect.
  29368. */
  29369. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29370. /**
  29371. * Sets a float2 on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param x First float in float2.
  29374. * @param y Second float in float2.
  29375. * @returns this effect.
  29376. */
  29377. setFloat2(uniformName: string, x: number, y: number): Effect;
  29378. /**
  29379. * Sets a Vector3 on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param vector3 Value to be set.
  29382. * @returns this effect.
  29383. */
  29384. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29385. /**
  29386. * Sets a float3 on a uniform variable.
  29387. * @param uniformName Name of the variable.
  29388. * @param x First float in float3.
  29389. * @param y Second float in float3.
  29390. * @param z Third float in float3.
  29391. * @returns this effect.
  29392. */
  29393. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29394. /**
  29395. * Sets a Vector4 on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param vector4 Value to be set.
  29398. * @returns this effect.
  29399. */
  29400. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29401. /**
  29402. * Sets a float4 on a uniform variable.
  29403. * @param uniformName Name of the variable.
  29404. * @param x First float in float4.
  29405. * @param y Second float in float4.
  29406. * @param z Third float in float4.
  29407. * @param w Fourth float in float4.
  29408. * @returns this effect.
  29409. */
  29410. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29411. /**
  29412. * Sets a Color3 on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param color3 Value to be set.
  29415. * @returns this effect.
  29416. */
  29417. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29418. /**
  29419. * Sets a Color4 on a uniform variable.
  29420. * @param uniformName Name of the variable.
  29421. * @param color3 Value to be set.
  29422. * @param alpha Alpha value to be set.
  29423. * @returns this effect.
  29424. */
  29425. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29426. /**
  29427. * Sets a Color4 on a uniform variable
  29428. * @param uniformName defines the name of the variable
  29429. * @param color4 defines the value to be set
  29430. * @returns this effect.
  29431. */
  29432. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29433. /** Release all associated resources */
  29434. dispose(): void;
  29435. /**
  29436. * This function will add a new shader to the shader store
  29437. * @param name the name of the shader
  29438. * @param pixelShader optional pixel shader content
  29439. * @param vertexShader optional vertex shader content
  29440. */
  29441. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29442. /**
  29443. * Store of each shader (The can be looked up using effect.key)
  29444. */
  29445. static ShadersStore: {
  29446. [key: string]: string;
  29447. };
  29448. /**
  29449. * Store of each included file for a shader (The can be looked up using effect.key)
  29450. */
  29451. static IncludesShadersStore: {
  29452. [key: string]: string;
  29453. };
  29454. /**
  29455. * Resets the cache of effects.
  29456. */
  29457. static ResetCache(): void;
  29458. }
  29459. }
  29460. declare module "babylonjs/Materials/uniformBuffer" {
  29461. import { Nullable, FloatArray } from "babylonjs/types";
  29462. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29463. import { Engine } from "babylonjs/Engines/engine";
  29464. import { Effect } from "babylonjs/Materials/effect";
  29465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29466. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29467. import { Color3 } from "babylonjs/Maths/math.color";
  29468. /**
  29469. * Uniform buffer objects.
  29470. *
  29471. * Handles blocks of uniform on the GPU.
  29472. *
  29473. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29474. *
  29475. * For more information, please refer to :
  29476. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29477. */
  29478. export class UniformBuffer {
  29479. private _engine;
  29480. private _buffer;
  29481. private _data;
  29482. private _bufferData;
  29483. private _dynamic?;
  29484. private _uniformLocations;
  29485. private _uniformSizes;
  29486. private _uniformLocationPointer;
  29487. private _needSync;
  29488. private _noUBO;
  29489. private _currentEffect;
  29490. private static _MAX_UNIFORM_SIZE;
  29491. private static _tempBuffer;
  29492. /**
  29493. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29494. * This is dynamic to allow compat with webgl 1 and 2.
  29495. * You will need to pass the name of the uniform as well as the value.
  29496. */
  29497. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29498. /**
  29499. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29500. * This is dynamic to allow compat with webgl 1 and 2.
  29501. * You will need to pass the name of the uniform as well as the value.
  29502. */
  29503. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29504. /**
  29505. * Lambda to Update a single float in a uniform buffer.
  29506. * This is dynamic to allow compat with webgl 1 and 2.
  29507. * You will need to pass the name of the uniform as well as the value.
  29508. */
  29509. updateFloat: (name: string, x: number) => void;
  29510. /**
  29511. * Lambda to Update a vec2 of float in a uniform buffer.
  29512. * This is dynamic to allow compat with webgl 1 and 2.
  29513. * You will need to pass the name of the uniform as well as the value.
  29514. */
  29515. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29516. /**
  29517. * Lambda to Update a vec3 of float in a uniform buffer.
  29518. * This is dynamic to allow compat with webgl 1 and 2.
  29519. * You will need to pass the name of the uniform as well as the value.
  29520. */
  29521. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29522. /**
  29523. * Lambda to Update a vec4 of float in a uniform buffer.
  29524. * This is dynamic to allow compat with webgl 1 and 2.
  29525. * You will need to pass the name of the uniform as well as the value.
  29526. */
  29527. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29528. /**
  29529. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29530. * This is dynamic to allow compat with webgl 1 and 2.
  29531. * You will need to pass the name of the uniform as well as the value.
  29532. */
  29533. updateMatrix: (name: string, mat: Matrix) => void;
  29534. /**
  29535. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29536. * This is dynamic to allow compat with webgl 1 and 2.
  29537. * You will need to pass the name of the uniform as well as the value.
  29538. */
  29539. updateVector3: (name: string, vector: Vector3) => void;
  29540. /**
  29541. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29542. * This is dynamic to allow compat with webgl 1 and 2.
  29543. * You will need to pass the name of the uniform as well as the value.
  29544. */
  29545. updateVector4: (name: string, vector: Vector4) => void;
  29546. /**
  29547. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29548. * This is dynamic to allow compat with webgl 1 and 2.
  29549. * You will need to pass the name of the uniform as well as the value.
  29550. */
  29551. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29552. /**
  29553. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29554. * This is dynamic to allow compat with webgl 1 and 2.
  29555. * You will need to pass the name of the uniform as well as the value.
  29556. */
  29557. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29558. /**
  29559. * Instantiates a new Uniform buffer objects.
  29560. *
  29561. * Handles blocks of uniform on the GPU.
  29562. *
  29563. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29564. *
  29565. * For more information, please refer to :
  29566. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29567. * @param engine Define the engine the buffer is associated with
  29568. * @param data Define the data contained in the buffer
  29569. * @param dynamic Define if the buffer is updatable
  29570. */
  29571. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29572. /**
  29573. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29574. * or just falling back on setUniformXXX calls.
  29575. */
  29576. readonly useUbo: boolean;
  29577. /**
  29578. * Indicates if the WebGL underlying uniform buffer is in sync
  29579. * with the javascript cache data.
  29580. */
  29581. readonly isSync: boolean;
  29582. /**
  29583. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29584. * Also, a dynamic UniformBuffer will disable cache verification and always
  29585. * update the underlying WebGL uniform buffer to the GPU.
  29586. * @returns if Dynamic, otherwise false
  29587. */
  29588. isDynamic(): boolean;
  29589. /**
  29590. * The data cache on JS side.
  29591. * @returns the underlying data as a float array
  29592. */
  29593. getData(): Float32Array;
  29594. /**
  29595. * The underlying WebGL Uniform buffer.
  29596. * @returns the webgl buffer
  29597. */
  29598. getBuffer(): Nullable<DataBuffer>;
  29599. /**
  29600. * std140 layout specifies how to align data within an UBO structure.
  29601. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29602. * for specs.
  29603. */
  29604. private _fillAlignment;
  29605. /**
  29606. * Adds an uniform in the buffer.
  29607. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29608. * for the layout to be correct !
  29609. * @param name Name of the uniform, as used in the uniform block in the shader.
  29610. * @param size Data size, or data directly.
  29611. */
  29612. addUniform(name: string, size: number | number[]): void;
  29613. /**
  29614. * Adds a Matrix 4x4 to the uniform buffer.
  29615. * @param name Name of the uniform, as used in the uniform block in the shader.
  29616. * @param mat A 4x4 matrix.
  29617. */
  29618. addMatrix(name: string, mat: Matrix): void;
  29619. /**
  29620. * Adds a vec2 to the uniform buffer.
  29621. * @param name Name of the uniform, as used in the uniform block in the shader.
  29622. * @param x Define the x component value of the vec2
  29623. * @param y Define the y component value of the vec2
  29624. */
  29625. addFloat2(name: string, x: number, y: number): void;
  29626. /**
  29627. * Adds a vec3 to the uniform buffer.
  29628. * @param name Name of the uniform, as used in the uniform block in the shader.
  29629. * @param x Define the x component value of the vec3
  29630. * @param y Define the y component value of the vec3
  29631. * @param z Define the z component value of the vec3
  29632. */
  29633. addFloat3(name: string, x: number, y: number, z: number): void;
  29634. /**
  29635. * Adds a vec3 to the uniform buffer.
  29636. * @param name Name of the uniform, as used in the uniform block in the shader.
  29637. * @param color Define the vec3 from a Color
  29638. */
  29639. addColor3(name: string, color: Color3): void;
  29640. /**
  29641. * Adds a vec4 to the uniform buffer.
  29642. * @param name Name of the uniform, as used in the uniform block in the shader.
  29643. * @param color Define the rgb components from a Color
  29644. * @param alpha Define the a component of the vec4
  29645. */
  29646. addColor4(name: string, color: Color3, alpha: number): void;
  29647. /**
  29648. * Adds a vec3 to the uniform buffer.
  29649. * @param name Name of the uniform, as used in the uniform block in the shader.
  29650. * @param vector Define the vec3 components from a Vector
  29651. */
  29652. addVector3(name: string, vector: Vector3): void;
  29653. /**
  29654. * Adds a Matrix 3x3 to the uniform buffer.
  29655. * @param name Name of the uniform, as used in the uniform block in the shader.
  29656. */
  29657. addMatrix3x3(name: string): void;
  29658. /**
  29659. * Adds a Matrix 2x2 to the uniform buffer.
  29660. * @param name Name of the uniform, as used in the uniform block in the shader.
  29661. */
  29662. addMatrix2x2(name: string): void;
  29663. /**
  29664. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29665. */
  29666. create(): void;
  29667. /** @hidden */
  29668. _rebuild(): void;
  29669. /**
  29670. * Updates the WebGL Uniform Buffer on the GPU.
  29671. * If the `dynamic` flag is set to true, no cache comparison is done.
  29672. * Otherwise, the buffer will be updated only if the cache differs.
  29673. */
  29674. update(): void;
  29675. /**
  29676. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29677. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29678. * @param data Define the flattened data
  29679. * @param size Define the size of the data.
  29680. */
  29681. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29682. private _updateMatrix3x3ForUniform;
  29683. private _updateMatrix3x3ForEffect;
  29684. private _updateMatrix2x2ForEffect;
  29685. private _updateMatrix2x2ForUniform;
  29686. private _updateFloatForEffect;
  29687. private _updateFloatForUniform;
  29688. private _updateFloat2ForEffect;
  29689. private _updateFloat2ForUniform;
  29690. private _updateFloat3ForEffect;
  29691. private _updateFloat3ForUniform;
  29692. private _updateFloat4ForEffect;
  29693. private _updateFloat4ForUniform;
  29694. private _updateMatrixForEffect;
  29695. private _updateMatrixForUniform;
  29696. private _updateVector3ForEffect;
  29697. private _updateVector3ForUniform;
  29698. private _updateVector4ForEffect;
  29699. private _updateVector4ForUniform;
  29700. private _updateColor3ForEffect;
  29701. private _updateColor3ForUniform;
  29702. private _updateColor4ForEffect;
  29703. private _updateColor4ForUniform;
  29704. /**
  29705. * Sets a sampler uniform on the effect.
  29706. * @param name Define the name of the sampler.
  29707. * @param texture Define the texture to set in the sampler
  29708. */
  29709. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29710. /**
  29711. * Directly updates the value of the uniform in the cache AND on the GPU.
  29712. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29713. * @param data Define the flattened data
  29714. */
  29715. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29716. /**
  29717. * Binds this uniform buffer to an effect.
  29718. * @param effect Define the effect to bind the buffer to
  29719. * @param name Name of the uniform block in the shader.
  29720. */
  29721. bindToEffect(effect: Effect, name: string): void;
  29722. /**
  29723. * Disposes the uniform buffer.
  29724. */
  29725. dispose(): void;
  29726. }
  29727. }
  29728. declare module "babylonjs/Audio/analyser" {
  29729. import { Scene } from "babylonjs/scene";
  29730. /**
  29731. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29733. */
  29734. export class Analyser {
  29735. /**
  29736. * Gets or sets the smoothing
  29737. * @ignorenaming
  29738. */
  29739. SMOOTHING: number;
  29740. /**
  29741. * Gets or sets the FFT table size
  29742. * @ignorenaming
  29743. */
  29744. FFT_SIZE: number;
  29745. /**
  29746. * Gets or sets the bar graph amplitude
  29747. * @ignorenaming
  29748. */
  29749. BARGRAPHAMPLITUDE: number;
  29750. /**
  29751. * Gets or sets the position of the debug canvas
  29752. * @ignorenaming
  29753. */
  29754. DEBUGCANVASPOS: {
  29755. x: number;
  29756. y: number;
  29757. };
  29758. /**
  29759. * Gets or sets the debug canvas size
  29760. * @ignorenaming
  29761. */
  29762. DEBUGCANVASSIZE: {
  29763. width: number;
  29764. height: number;
  29765. };
  29766. private _byteFreqs;
  29767. private _byteTime;
  29768. private _floatFreqs;
  29769. private _webAudioAnalyser;
  29770. private _debugCanvas;
  29771. private _debugCanvasContext;
  29772. private _scene;
  29773. private _registerFunc;
  29774. private _audioEngine;
  29775. /**
  29776. * Creates a new analyser
  29777. * @param scene defines hosting scene
  29778. */
  29779. constructor(scene: Scene);
  29780. /**
  29781. * Get the number of data values you will have to play with for the visualization
  29782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29783. * @returns a number
  29784. */
  29785. getFrequencyBinCount(): number;
  29786. /**
  29787. * Gets the current frequency data as a byte array
  29788. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29789. * @returns a Uint8Array
  29790. */
  29791. getByteFrequencyData(): Uint8Array;
  29792. /**
  29793. * Gets the current waveform as a byte array
  29794. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29795. * @returns a Uint8Array
  29796. */
  29797. getByteTimeDomainData(): Uint8Array;
  29798. /**
  29799. * Gets the current frequency data as a float array
  29800. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29801. * @returns a Float32Array
  29802. */
  29803. getFloatFrequencyData(): Float32Array;
  29804. /**
  29805. * Renders the debug canvas
  29806. */
  29807. drawDebugCanvas(): void;
  29808. /**
  29809. * Stops rendering the debug canvas and removes it
  29810. */
  29811. stopDebugCanvas(): void;
  29812. /**
  29813. * Connects two audio nodes
  29814. * @param inputAudioNode defines first node to connect
  29815. * @param outputAudioNode defines second node to connect
  29816. */
  29817. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29818. /**
  29819. * Releases all associated resources
  29820. */
  29821. dispose(): void;
  29822. }
  29823. }
  29824. declare module "babylonjs/Audio/audioEngine" {
  29825. import { IDisposable } from "babylonjs/scene";
  29826. import { Analyser } from "babylonjs/Audio/analyser";
  29827. import { Nullable } from "babylonjs/types";
  29828. import { Observable } from "babylonjs/Misc/observable";
  29829. /**
  29830. * This represents an audio engine and it is responsible
  29831. * to play, synchronize and analyse sounds throughout the application.
  29832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29833. */
  29834. export interface IAudioEngine extends IDisposable {
  29835. /**
  29836. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29837. */
  29838. readonly canUseWebAudio: boolean;
  29839. /**
  29840. * Gets the current AudioContext if available.
  29841. */
  29842. readonly audioContext: Nullable<AudioContext>;
  29843. /**
  29844. * The master gain node defines the global audio volume of your audio engine.
  29845. */
  29846. readonly masterGain: GainNode;
  29847. /**
  29848. * Gets whether or not mp3 are supported by your browser.
  29849. */
  29850. readonly isMP3supported: boolean;
  29851. /**
  29852. * Gets whether or not ogg are supported by your browser.
  29853. */
  29854. readonly isOGGsupported: boolean;
  29855. /**
  29856. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29857. * @ignoreNaming
  29858. */
  29859. WarnedWebAudioUnsupported: boolean;
  29860. /**
  29861. * Defines if the audio engine relies on a custom unlocked button.
  29862. * In this case, the embedded button will not be displayed.
  29863. */
  29864. useCustomUnlockedButton: boolean;
  29865. /**
  29866. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29867. */
  29868. readonly unlocked: boolean;
  29869. /**
  29870. * Event raised when audio has been unlocked on the browser.
  29871. */
  29872. onAudioUnlockedObservable: Observable<AudioEngine>;
  29873. /**
  29874. * Event raised when audio has been locked on the browser.
  29875. */
  29876. onAudioLockedObservable: Observable<AudioEngine>;
  29877. /**
  29878. * Flags the audio engine in Locked state.
  29879. * This happens due to new browser policies preventing audio to autoplay.
  29880. */
  29881. lock(): void;
  29882. /**
  29883. * Unlocks the audio engine once a user action has been done on the dom.
  29884. * This is helpful to resume play once browser policies have been satisfied.
  29885. */
  29886. unlock(): void;
  29887. }
  29888. /**
  29889. * This represents the default audio engine used in babylon.
  29890. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29892. */
  29893. export class AudioEngine implements IAudioEngine {
  29894. private _audioContext;
  29895. private _audioContextInitialized;
  29896. private _muteButton;
  29897. private _hostElement;
  29898. /**
  29899. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29900. */
  29901. canUseWebAudio: boolean;
  29902. /**
  29903. * The master gain node defines the global audio volume of your audio engine.
  29904. */
  29905. masterGain: GainNode;
  29906. /**
  29907. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29908. * @ignoreNaming
  29909. */
  29910. WarnedWebAudioUnsupported: boolean;
  29911. /**
  29912. * Gets whether or not mp3 are supported by your browser.
  29913. */
  29914. isMP3supported: boolean;
  29915. /**
  29916. * Gets whether or not ogg are supported by your browser.
  29917. */
  29918. isOGGsupported: boolean;
  29919. /**
  29920. * Gets whether audio has been unlocked on the device.
  29921. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29922. * a user interaction has happened.
  29923. */
  29924. unlocked: boolean;
  29925. /**
  29926. * Defines if the audio engine relies on a custom unlocked button.
  29927. * In this case, the embedded button will not be displayed.
  29928. */
  29929. useCustomUnlockedButton: boolean;
  29930. /**
  29931. * Event raised when audio has been unlocked on the browser.
  29932. */
  29933. onAudioUnlockedObservable: Observable<AudioEngine>;
  29934. /**
  29935. * Event raised when audio has been locked on the browser.
  29936. */
  29937. onAudioLockedObservable: Observable<AudioEngine>;
  29938. /**
  29939. * Gets the current AudioContext if available.
  29940. */
  29941. readonly audioContext: Nullable<AudioContext>;
  29942. private _connectedAnalyser;
  29943. /**
  29944. * Instantiates a new audio engine.
  29945. *
  29946. * There should be only one per page as some browsers restrict the number
  29947. * of audio contexts you can create.
  29948. * @param hostElement defines the host element where to display the mute icon if necessary
  29949. */
  29950. constructor(hostElement?: Nullable<HTMLElement>);
  29951. /**
  29952. * Flags the audio engine in Locked state.
  29953. * This happens due to new browser policies preventing audio to autoplay.
  29954. */
  29955. lock(): void;
  29956. /**
  29957. * Unlocks the audio engine once a user action has been done on the dom.
  29958. * This is helpful to resume play once browser policies have been satisfied.
  29959. */
  29960. unlock(): void;
  29961. private _resumeAudioContext;
  29962. private _initializeAudioContext;
  29963. private _tryToRun;
  29964. private _triggerRunningState;
  29965. private _triggerSuspendedState;
  29966. private _displayMuteButton;
  29967. private _moveButtonToTopLeft;
  29968. private _onResize;
  29969. private _hideMuteButton;
  29970. /**
  29971. * Destroy and release the resources associated with the audio ccontext.
  29972. */
  29973. dispose(): void;
  29974. /**
  29975. * Gets the global volume sets on the master gain.
  29976. * @returns the global volume if set or -1 otherwise
  29977. */
  29978. getGlobalVolume(): number;
  29979. /**
  29980. * Sets the global volume of your experience (sets on the master gain).
  29981. * @param newVolume Defines the new global volume of the application
  29982. */
  29983. setGlobalVolume(newVolume: number): void;
  29984. /**
  29985. * Connect the audio engine to an audio analyser allowing some amazing
  29986. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29988. * @param analyser The analyser to connect to the engine
  29989. */
  29990. connectToAnalyser(analyser: Analyser): void;
  29991. }
  29992. }
  29993. declare module "babylonjs/Loading/loadingScreen" {
  29994. /**
  29995. * Interface used to present a loading screen while loading a scene
  29996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29997. */
  29998. export interface ILoadingScreen {
  29999. /**
  30000. * Function called to display the loading screen
  30001. */
  30002. displayLoadingUI: () => void;
  30003. /**
  30004. * Function called to hide the loading screen
  30005. */
  30006. hideLoadingUI: () => void;
  30007. /**
  30008. * Gets or sets the color to use for the background
  30009. */
  30010. loadingUIBackgroundColor: string;
  30011. /**
  30012. * Gets or sets the text to display while loading
  30013. */
  30014. loadingUIText: string;
  30015. }
  30016. /**
  30017. * Class used for the default loading screen
  30018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30019. */
  30020. export class DefaultLoadingScreen implements ILoadingScreen {
  30021. private _renderingCanvas;
  30022. private _loadingText;
  30023. private _loadingDivBackgroundColor;
  30024. private _loadingDiv;
  30025. private _loadingTextDiv;
  30026. /** Gets or sets the logo url to use for the default loading screen */
  30027. static DefaultLogoUrl: string;
  30028. /** Gets or sets the spinner url to use for the default loading screen */
  30029. static DefaultSpinnerUrl: string;
  30030. /**
  30031. * Creates a new default loading screen
  30032. * @param _renderingCanvas defines the canvas used to render the scene
  30033. * @param _loadingText defines the default text to display
  30034. * @param _loadingDivBackgroundColor defines the default background color
  30035. */
  30036. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30037. /**
  30038. * Function called to display the loading screen
  30039. */
  30040. displayLoadingUI(): void;
  30041. /**
  30042. * Function called to hide the loading screen
  30043. */
  30044. hideLoadingUI(): void;
  30045. /**
  30046. * Gets or sets the text to display while loading
  30047. */
  30048. loadingUIText: string;
  30049. /**
  30050. * Gets or sets the color to use for the background
  30051. */
  30052. loadingUIBackgroundColor: string;
  30053. private _resizeLoadingUI;
  30054. }
  30055. }
  30056. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30057. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30058. import { Engine } from "babylonjs/Engines/engine";
  30059. import { Nullable } from "babylonjs/types";
  30060. /** @hidden */
  30061. export class WebGLPipelineContext implements IPipelineContext {
  30062. engine: Engine;
  30063. program: Nullable<WebGLProgram>;
  30064. context?: WebGLRenderingContext;
  30065. vertexShader?: WebGLShader;
  30066. fragmentShader?: WebGLShader;
  30067. isParallelCompiled: boolean;
  30068. onCompiled?: () => void;
  30069. transformFeedback?: WebGLTransformFeedback | null;
  30070. readonly isAsync: boolean;
  30071. readonly isReady: boolean;
  30072. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30073. }
  30074. }
  30075. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30076. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30077. /** @hidden */
  30078. export class WebGLDataBuffer extends DataBuffer {
  30079. private _buffer;
  30080. constructor(resource: WebGLBuffer);
  30081. readonly underlyingResource: any;
  30082. }
  30083. }
  30084. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30085. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30086. /** @hidden */
  30087. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30088. attributeProcessor(attribute: string): string;
  30089. varyingProcessor(varying: string, isFragment: boolean): string;
  30090. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30091. }
  30092. }
  30093. declare module "babylonjs/Misc/perfCounter" {
  30094. /**
  30095. * This class is used to track a performance counter which is number based.
  30096. * The user has access to many properties which give statistics of different nature.
  30097. *
  30098. * The implementer can track two kinds of Performance Counter: time and count.
  30099. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  30100. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  30101. */
  30102. export class PerfCounter {
  30103. /**
  30104. * Gets or sets a global boolean to turn on and off all the counters
  30105. */
  30106. static Enabled: boolean;
  30107. /**
  30108. * Returns the smallest value ever
  30109. */
  30110. readonly min: number;
  30111. /**
  30112. * Returns the biggest value ever
  30113. */
  30114. readonly max: number;
  30115. /**
  30116. * Returns the average value since the performance counter is running
  30117. */
  30118. readonly average: number;
  30119. /**
  30120. * Returns the average value of the last second the counter was monitored
  30121. */
  30122. readonly lastSecAverage: number;
  30123. /**
  30124. * Returns the current value
  30125. */
  30126. readonly current: number;
  30127. /**
  30128. * Gets the accumulated total
  30129. */
  30130. readonly total: number;
  30131. /**
  30132. * Gets the total value count
  30133. */
  30134. readonly count: number;
  30135. /**
  30136. * Creates a new counter
  30137. */
  30138. constructor();
  30139. /**
  30140. * Call this method to start monitoring a new frame.
  30141. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  30142. */
  30143. fetchNewFrame(): void;
  30144. /**
  30145. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30146. * @param newCount the count value to add to the monitored count
  30147. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  30148. */
  30149. addCount(newCount: number, fetchResult: boolean): void;
  30150. /**
  30151. * Start monitoring this performance counter
  30152. */
  30153. beginMonitoring(): void;
  30154. /**
  30155. * Compute the time lapsed since the previous beginMonitoring() call.
  30156. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  30157. */
  30158. endMonitoring(newFrame?: boolean): void;
  30159. private _fetchResult;
  30160. private _startMonitoringTime;
  30161. private _min;
  30162. private _max;
  30163. private _average;
  30164. private _current;
  30165. private _totalValueCount;
  30166. private _totalAccumulated;
  30167. private _lastSecAverage;
  30168. private _lastSecAccumulated;
  30169. private _lastSecTime;
  30170. private _lastSecValueCount;
  30171. }
  30172. }
  30173. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30174. /**
  30175. * Interface for any object that can request an animation frame
  30176. */
  30177. export interface ICustomAnimationFrameRequester {
  30178. /**
  30179. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30180. */
  30181. renderFunction?: Function;
  30182. /**
  30183. * Called to request the next frame to render to
  30184. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30185. */
  30186. requestAnimationFrame: Function;
  30187. /**
  30188. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30189. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30190. */
  30191. requestID?: number;
  30192. }
  30193. }
  30194. declare module "babylonjs/Materials/Textures/videoTexture" {
  30195. import { Observable } from "babylonjs/Misc/observable";
  30196. import { Nullable } from "babylonjs/types";
  30197. import { Scene } from "babylonjs/scene";
  30198. import { Texture } from "babylonjs/Materials/Textures/texture";
  30199. /**
  30200. * Settings for finer control over video usage
  30201. */
  30202. export interface VideoTextureSettings {
  30203. /**
  30204. * Applies `autoplay` to video, if specified
  30205. */
  30206. autoPlay?: boolean;
  30207. /**
  30208. * Applies `loop` to video, if specified
  30209. */
  30210. loop?: boolean;
  30211. /**
  30212. * Automatically updates internal texture from video at every frame in the render loop
  30213. */
  30214. autoUpdateTexture: boolean;
  30215. /**
  30216. * Image src displayed during the video loading or until the user interacts with the video.
  30217. */
  30218. poster?: string;
  30219. }
  30220. /**
  30221. * If you want to display a video in your scene, this is the special texture for that.
  30222. * This special texture works similar to other textures, with the exception of a few parameters.
  30223. * @see https://doc.babylonjs.com/how_to/video_texture
  30224. */
  30225. export class VideoTexture extends Texture {
  30226. /**
  30227. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30228. */
  30229. readonly autoUpdateTexture: boolean;
  30230. /**
  30231. * The video instance used by the texture internally
  30232. */
  30233. readonly video: HTMLVideoElement;
  30234. private _onUserActionRequestedObservable;
  30235. /**
  30236. * Event triggerd when a dom action is required by the user to play the video.
  30237. * This happens due to recent changes in browser policies preventing video to auto start.
  30238. */
  30239. readonly onUserActionRequestedObservable: Observable<Texture>;
  30240. private _generateMipMaps;
  30241. private _engine;
  30242. private _stillImageCaptured;
  30243. private _displayingPosterTexture;
  30244. private _settings;
  30245. private _createInternalTextureOnEvent;
  30246. /**
  30247. * Creates a video texture.
  30248. * If you want to display a video in your scene, this is the special texture for that.
  30249. * This special texture works similar to other textures, with the exception of a few parameters.
  30250. * @see https://doc.babylonjs.com/how_to/video_texture
  30251. * @param name optional name, will detect from video source, if not defined
  30252. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30253. * @param scene is obviously the current scene.
  30254. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30255. * @param invertY is false by default but can be used to invert video on Y axis
  30256. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30257. * @param settings allows finer control over video usage
  30258. */
  30259. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30260. private _getName;
  30261. private _getVideo;
  30262. private _createInternalTexture;
  30263. private reset;
  30264. /**
  30265. * @hidden Internal method to initiate `update`.
  30266. */
  30267. _rebuild(): void;
  30268. /**
  30269. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30270. */
  30271. update(): void;
  30272. /**
  30273. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30274. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30275. */
  30276. updateTexture(isVisible: boolean): void;
  30277. protected _updateInternalTexture: () => void;
  30278. /**
  30279. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30280. * @param url New url.
  30281. */
  30282. updateURL(url: string): void;
  30283. /**
  30284. * Dispose the texture and release its associated resources.
  30285. */
  30286. dispose(): void;
  30287. /**
  30288. * Creates a video texture straight from a stream.
  30289. * @param scene Define the scene the texture should be created in
  30290. * @param stream Define the stream the texture should be created from
  30291. * @returns The created video texture as a promise
  30292. */
  30293. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30294. /**
  30295. * Creates a video texture straight from your WebCam video feed.
  30296. * @param scene Define the scene the texture should be created in
  30297. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30298. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30299. * @returns The created video texture as a promise
  30300. */
  30301. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30302. minWidth: number;
  30303. maxWidth: number;
  30304. minHeight: number;
  30305. maxHeight: number;
  30306. deviceId: string;
  30307. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30308. /**
  30309. * Creates a video texture straight from your WebCam video feed.
  30310. * @param scene Define the scene the texture should be created in
  30311. * @param onReady Define a callback to triggered once the texture will be ready
  30312. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30313. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30314. */
  30315. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30316. minWidth: number;
  30317. maxWidth: number;
  30318. minHeight: number;
  30319. maxHeight: number;
  30320. deviceId: string;
  30321. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30322. }
  30323. }
  30324. declare module "babylonjs/Engines/engine" {
  30325. import { Observable } from "babylonjs/Misc/observable";
  30326. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30327. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30328. import { Scene } from "babylonjs/scene";
  30329. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30330. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30331. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30332. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30335. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30337. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30338. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30339. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30340. import { WebRequest } from "babylonjs/Misc/webRequest";
  30341. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30342. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30343. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30344. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30345. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30346. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30347. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30348. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30349. import { Material } from "babylonjs/Materials/material";
  30350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30352. /**
  30353. * Defines the interface used by objects containing a viewport (like a camera)
  30354. */
  30355. interface IViewportOwnerLike {
  30356. /**
  30357. * Gets or sets the viewport
  30358. */
  30359. viewport: IViewportLike;
  30360. }
  30361. /**
  30362. * Interface for attribute information associated with buffer instanciation
  30363. */
  30364. export class InstancingAttributeInfo {
  30365. /**
  30366. * Index/offset of the attribute in the vertex shader
  30367. */
  30368. index: number;
  30369. /**
  30370. * size of the attribute, 1, 2, 3 or 4
  30371. */
  30372. attributeSize: number;
  30373. /**
  30374. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30375. * default is FLOAT
  30376. */
  30377. attribyteType: number;
  30378. /**
  30379. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30380. */
  30381. normalized: boolean;
  30382. /**
  30383. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30384. */
  30385. offset: number;
  30386. /**
  30387. * Name of the GLSL attribute, for debugging purpose only
  30388. */
  30389. attributeName: string;
  30390. }
  30391. /**
  30392. * Define options used to create a depth texture
  30393. */
  30394. export class DepthTextureCreationOptions {
  30395. /** Specifies whether or not a stencil should be allocated in the texture */
  30396. generateStencil?: boolean;
  30397. /** Specifies whether or not bilinear filtering is enable on the texture */
  30398. bilinearFiltering?: boolean;
  30399. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30400. comparisonFunction?: number;
  30401. /** Specifies if the created texture is a cube texture */
  30402. isCube?: boolean;
  30403. }
  30404. /**
  30405. * Class used to describe the capabilities of the engine relatively to the current browser
  30406. */
  30407. export class EngineCapabilities {
  30408. /** Maximum textures units per fragment shader */
  30409. maxTexturesImageUnits: number;
  30410. /** Maximum texture units per vertex shader */
  30411. maxVertexTextureImageUnits: number;
  30412. /** Maximum textures units in the entire pipeline */
  30413. maxCombinedTexturesImageUnits: number;
  30414. /** Maximum texture size */
  30415. maxTextureSize: number;
  30416. /** Maximum cube texture size */
  30417. maxCubemapTextureSize: number;
  30418. /** Maximum render texture size */
  30419. maxRenderTextureSize: number;
  30420. /** Maximum number of vertex attributes */
  30421. maxVertexAttribs: number;
  30422. /** Maximum number of varyings */
  30423. maxVaryingVectors: number;
  30424. /** Maximum number of uniforms per vertex shader */
  30425. maxVertexUniformVectors: number;
  30426. /** Maximum number of uniforms per fragment shader */
  30427. maxFragmentUniformVectors: number;
  30428. /** Defines if standard derivates (dx/dy) are supported */
  30429. standardDerivatives: boolean;
  30430. /** Defines if s3tc texture compression is supported */
  30431. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30432. /** Defines if pvrtc texture compression is supported */
  30433. pvrtc: any;
  30434. /** Defines if etc1 texture compression is supported */
  30435. etc1: any;
  30436. /** Defines if etc2 texture compression is supported */
  30437. etc2: any;
  30438. /** Defines if astc texture compression is supported */
  30439. astc: any;
  30440. /** Defines if float textures are supported */
  30441. textureFloat: boolean;
  30442. /** Defines if vertex array objects are supported */
  30443. vertexArrayObject: boolean;
  30444. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30445. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30446. /** Gets the maximum level of anisotropy supported */
  30447. maxAnisotropy: number;
  30448. /** Defines if instancing is supported */
  30449. instancedArrays: boolean;
  30450. /** Defines if 32 bits indices are supported */
  30451. uintIndices: boolean;
  30452. /** Defines if high precision shaders are supported */
  30453. highPrecisionShaderSupported: boolean;
  30454. /** Defines if depth reading in the fragment shader is supported */
  30455. fragmentDepthSupported: boolean;
  30456. /** Defines if float texture linear filtering is supported*/
  30457. textureFloatLinearFiltering: boolean;
  30458. /** Defines if rendering to float textures is supported */
  30459. textureFloatRender: boolean;
  30460. /** Defines if half float textures are supported*/
  30461. textureHalfFloat: boolean;
  30462. /** Defines if half float texture linear filtering is supported*/
  30463. textureHalfFloatLinearFiltering: boolean;
  30464. /** Defines if rendering to half float textures is supported */
  30465. textureHalfFloatRender: boolean;
  30466. /** Defines if textureLOD shader command is supported */
  30467. textureLOD: boolean;
  30468. /** Defines if draw buffers extension is supported */
  30469. drawBuffersExtension: boolean;
  30470. /** Defines if depth textures are supported */
  30471. depthTextureExtension: boolean;
  30472. /** Defines if float color buffer are supported */
  30473. colorBufferFloat: boolean;
  30474. /** Gets disjoint timer query extension (null if not supported) */
  30475. timerQuery: EXT_disjoint_timer_query;
  30476. /** Defines if timestamp can be used with timer query */
  30477. canUseTimestampForTimerQuery: boolean;
  30478. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30479. multiview: any;
  30480. /** Function used to let the system compiles shaders in background */
  30481. parallelShaderCompile: {
  30482. COMPLETION_STATUS_KHR: number;
  30483. };
  30484. /** Max number of texture samples for MSAA */
  30485. maxMSAASamples: number;
  30486. }
  30487. /** Interface defining initialization parameters for Engine class */
  30488. export interface EngineOptions extends WebGLContextAttributes {
  30489. /**
  30490. * Defines if the engine should no exceed a specified device ratio
  30491. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30492. */
  30493. limitDeviceRatio?: number;
  30494. /**
  30495. * Defines if webvr should be enabled automatically
  30496. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30497. */
  30498. autoEnableWebVR?: boolean;
  30499. /**
  30500. * Defines if webgl2 should be turned off even if supported
  30501. * @see http://doc.babylonjs.com/features/webgl2
  30502. */
  30503. disableWebGL2Support?: boolean;
  30504. /**
  30505. * Defines if webaudio should be initialized as well
  30506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30507. */
  30508. audioEngine?: boolean;
  30509. /**
  30510. * Defines if animations should run using a deterministic lock step
  30511. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30512. */
  30513. deterministicLockstep?: boolean;
  30514. /** Defines the maximum steps to use with deterministic lock step mode */
  30515. lockstepMaxSteps?: number;
  30516. /**
  30517. * Defines that engine should ignore context lost events
  30518. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30519. */
  30520. doNotHandleContextLost?: boolean;
  30521. /**
  30522. * Defines that engine should ignore modifying touch action attribute and style
  30523. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30524. */
  30525. doNotHandleTouchAction?: boolean;
  30526. /**
  30527. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30528. */
  30529. useHighPrecisionFloats?: boolean;
  30530. }
  30531. /**
  30532. * Defines the interface used by display changed events
  30533. */
  30534. export interface IDisplayChangedEventArgs {
  30535. /** Gets the vrDisplay object (if any) */
  30536. vrDisplay: Nullable<any>;
  30537. /** Gets a boolean indicating if webVR is supported */
  30538. vrSupported: boolean;
  30539. }
  30540. /**
  30541. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30542. */
  30543. export class Engine {
  30544. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30545. static ExceptionList: ({
  30546. key: string;
  30547. capture: string;
  30548. captureConstraint: number;
  30549. targets: string[];
  30550. } | {
  30551. key: string;
  30552. capture: null;
  30553. captureConstraint: null;
  30554. targets: string[];
  30555. })[];
  30556. /** Gets the list of created engines */
  30557. static readonly Instances: Engine[];
  30558. /**
  30559. * Gets the latest created engine
  30560. */
  30561. static readonly LastCreatedEngine: Nullable<Engine>;
  30562. /**
  30563. * Gets the latest created scene
  30564. */
  30565. static readonly LastCreatedScene: Nullable<Scene>;
  30566. /**
  30567. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30568. * @param flag defines which part of the materials must be marked as dirty
  30569. * @param predicate defines a predicate used to filter which materials should be affected
  30570. */
  30571. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30572. /** @hidden */
  30573. static _TextureLoaders: IInternalTextureLoader[];
  30574. /** Defines that alpha blending is disabled */
  30575. static readonly ALPHA_DISABLE: number;
  30576. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30577. static readonly ALPHA_ADD: number;
  30578. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30579. static readonly ALPHA_COMBINE: number;
  30580. /** Defines that alpha blending to DEST - SRC * DEST */
  30581. static readonly ALPHA_SUBTRACT: number;
  30582. /** Defines that alpha blending to SRC * DEST */
  30583. static readonly ALPHA_MULTIPLY: number;
  30584. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30585. static readonly ALPHA_MAXIMIZED: number;
  30586. /** Defines that alpha blending to SRC + DEST */
  30587. static readonly ALPHA_ONEONE: number;
  30588. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30589. static readonly ALPHA_PREMULTIPLIED: number;
  30590. /**
  30591. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30592. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30593. */
  30594. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30595. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30596. static readonly ALPHA_INTERPOLATE: number;
  30597. /**
  30598. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30599. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30600. */
  30601. static readonly ALPHA_SCREENMODE: number;
  30602. /** Defines that the ressource is not delayed*/
  30603. static readonly DELAYLOADSTATE_NONE: number;
  30604. /** Defines that the ressource was successfully delay loaded */
  30605. static readonly DELAYLOADSTATE_LOADED: number;
  30606. /** Defines that the ressource is currently delay loading */
  30607. static readonly DELAYLOADSTATE_LOADING: number;
  30608. /** Defines that the ressource is delayed and has not started loading */
  30609. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30611. static readonly NEVER: number;
  30612. /** 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 */
  30613. static readonly ALWAYS: number;
  30614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30615. static readonly LESS: number;
  30616. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30617. static readonly EQUAL: number;
  30618. /** 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 */
  30619. static readonly LEQUAL: number;
  30620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30621. static readonly GREATER: number;
  30622. /** 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 */
  30623. static readonly GEQUAL: number;
  30624. /** 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 */
  30625. static readonly NOTEQUAL: number;
  30626. /** Passed to stencilOperation to specify that stencil value must be kept */
  30627. static readonly KEEP: number;
  30628. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30629. static readonly REPLACE: number;
  30630. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30631. static readonly INCR: number;
  30632. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30633. static readonly DECR: number;
  30634. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30635. static readonly INVERT: number;
  30636. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30637. static readonly INCR_WRAP: number;
  30638. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30639. static readonly DECR_WRAP: number;
  30640. /** Texture is not repeating outside of 0..1 UVs */
  30641. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30642. /** Texture is repeating outside of 0..1 UVs */
  30643. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30644. /** Texture is repeating and mirrored */
  30645. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30646. /** ALPHA */
  30647. static readonly TEXTUREFORMAT_ALPHA: number;
  30648. /** LUMINANCE */
  30649. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30650. /** LUMINANCE_ALPHA */
  30651. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30652. /** RGB */
  30653. static readonly TEXTUREFORMAT_RGB: number;
  30654. /** RGBA */
  30655. static readonly TEXTUREFORMAT_RGBA: number;
  30656. /** RED */
  30657. static readonly TEXTUREFORMAT_RED: number;
  30658. /** RED (2nd reference) */
  30659. static readonly TEXTUREFORMAT_R: number;
  30660. /** RG */
  30661. static readonly TEXTUREFORMAT_RG: number;
  30662. /** RED_INTEGER */
  30663. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30664. /** RED_INTEGER (2nd reference) */
  30665. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30666. /** RG_INTEGER */
  30667. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30668. /** RGB_INTEGER */
  30669. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30670. /** RGBA_INTEGER */
  30671. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30672. /** UNSIGNED_BYTE */
  30673. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30674. /** UNSIGNED_BYTE (2nd reference) */
  30675. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30676. /** FLOAT */
  30677. static readonly TEXTURETYPE_FLOAT: number;
  30678. /** HALF_FLOAT */
  30679. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30680. /** BYTE */
  30681. static readonly TEXTURETYPE_BYTE: number;
  30682. /** SHORT */
  30683. static readonly TEXTURETYPE_SHORT: number;
  30684. /** UNSIGNED_SHORT */
  30685. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30686. /** INT */
  30687. static readonly TEXTURETYPE_INT: number;
  30688. /** UNSIGNED_INT */
  30689. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30690. /** UNSIGNED_SHORT_4_4_4_4 */
  30691. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30692. /** UNSIGNED_SHORT_5_5_5_1 */
  30693. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30694. /** UNSIGNED_SHORT_5_6_5 */
  30695. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30696. /** UNSIGNED_INT_2_10_10_10_REV */
  30697. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30698. /** UNSIGNED_INT_24_8 */
  30699. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30700. /** UNSIGNED_INT_10F_11F_11F_REV */
  30701. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30702. /** UNSIGNED_INT_5_9_9_9_REV */
  30703. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30704. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30705. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30706. /** nearest is mag = nearest and min = nearest and mip = linear */
  30707. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30708. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30709. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30710. /** Trilinear is mag = linear and min = linear and mip = linear */
  30711. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30712. /** nearest is mag = nearest and min = nearest and mip = linear */
  30713. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30714. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30715. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30716. /** Trilinear is mag = linear and min = linear and mip = linear */
  30717. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30718. /** mag = nearest and min = nearest and mip = nearest */
  30719. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30720. /** mag = nearest and min = linear and mip = nearest */
  30721. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30722. /** mag = nearest and min = linear and mip = linear */
  30723. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30724. /** mag = nearest and min = linear and mip = none */
  30725. static readonly TEXTURE_NEAREST_LINEAR: number;
  30726. /** mag = nearest and min = nearest and mip = none */
  30727. static readonly TEXTURE_NEAREST_NEAREST: number;
  30728. /** mag = linear and min = nearest and mip = nearest */
  30729. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30730. /** mag = linear and min = nearest and mip = linear */
  30731. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30732. /** mag = linear and min = linear and mip = none */
  30733. static readonly TEXTURE_LINEAR_LINEAR: number;
  30734. /** mag = linear and min = nearest and mip = none */
  30735. static readonly TEXTURE_LINEAR_NEAREST: number;
  30736. /** Explicit coordinates mode */
  30737. static readonly TEXTURE_EXPLICIT_MODE: number;
  30738. /** Spherical coordinates mode */
  30739. static readonly TEXTURE_SPHERICAL_MODE: number;
  30740. /** Planar coordinates mode */
  30741. static readonly TEXTURE_PLANAR_MODE: number;
  30742. /** Cubic coordinates mode */
  30743. static readonly TEXTURE_CUBIC_MODE: number;
  30744. /** Projection coordinates mode */
  30745. static readonly TEXTURE_PROJECTION_MODE: number;
  30746. /** Skybox coordinates mode */
  30747. static readonly TEXTURE_SKYBOX_MODE: number;
  30748. /** Inverse Cubic coordinates mode */
  30749. static readonly TEXTURE_INVCUBIC_MODE: number;
  30750. /** Equirectangular coordinates mode */
  30751. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30752. /** Equirectangular Fixed coordinates mode */
  30753. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30754. /** Equirectangular Fixed Mirrored coordinates mode */
  30755. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30756. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30757. static readonly SCALEMODE_FLOOR: number;
  30758. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30759. static readonly SCALEMODE_NEAREST: number;
  30760. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30761. static readonly SCALEMODE_CEILING: number;
  30762. /**
  30763. * Returns the current npm package of the sdk
  30764. */
  30765. static readonly NpmPackage: string;
  30766. /**
  30767. * Returns the current version of the framework
  30768. */
  30769. static readonly Version: string;
  30770. /**
  30771. * Returns a string describing the current engine
  30772. */
  30773. readonly description: string;
  30774. /**
  30775. * Gets or sets the epsilon value used by collision engine
  30776. */
  30777. static CollisionsEpsilon: number;
  30778. /**
  30779. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30780. */
  30781. static ShadersRepository: string;
  30782. /**
  30783. * Method called to create the default loading screen.
  30784. * This can be overriden in your own app.
  30785. * @param canvas The rendering canvas element
  30786. * @returns The loading screen
  30787. */
  30788. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30789. /**
  30790. * Method called to create the default rescale post process on each engine.
  30791. */
  30792. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30793. /** @hidden */
  30794. _shaderProcessor: IShaderProcessor;
  30795. /**
  30796. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30797. */
  30798. forcePOTTextures: boolean;
  30799. /**
  30800. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30801. */
  30802. isFullscreen: boolean;
  30803. /**
  30804. * Gets a boolean indicating if the pointer is currently locked
  30805. */
  30806. isPointerLock: boolean;
  30807. /**
  30808. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30809. */
  30810. cullBackFaces: boolean;
  30811. /**
  30812. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30813. */
  30814. renderEvenInBackground: boolean;
  30815. /**
  30816. * Gets or sets a boolean indicating that cache can be kept between frames
  30817. */
  30818. preventCacheWipeBetweenFrames: boolean;
  30819. /**
  30820. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30821. **/
  30822. enableOfflineSupport: boolean;
  30823. /**
  30824. * 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)
  30825. **/
  30826. disableManifestCheck: boolean;
  30827. /**
  30828. * Gets the list of created scenes
  30829. */
  30830. scenes: Scene[];
  30831. /**
  30832. * Event raised when a new scene is created
  30833. */
  30834. onNewSceneAddedObservable: Observable<Scene>;
  30835. /**
  30836. * Gets the list of created postprocesses
  30837. */
  30838. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30839. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30840. validateShaderPrograms: boolean;
  30841. /**
  30842. * Observable event triggered each time the rendering canvas is resized
  30843. */
  30844. onResizeObservable: Observable<Engine>;
  30845. /**
  30846. * Observable event triggered each time the canvas loses focus
  30847. */
  30848. onCanvasBlurObservable: Observable<Engine>;
  30849. /**
  30850. * Observable event triggered each time the canvas gains focus
  30851. */
  30852. onCanvasFocusObservable: Observable<Engine>;
  30853. /**
  30854. * Observable event triggered each time the canvas receives pointerout event
  30855. */
  30856. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30857. /**
  30858. * Observable event triggered before each texture is initialized
  30859. */
  30860. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30861. /**
  30862. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30863. */
  30864. disableUniformBuffers: boolean;
  30865. /** @hidden */
  30866. _uniformBuffers: UniformBuffer[];
  30867. /**
  30868. * Gets a boolean indicating that the engine supports uniform buffers
  30869. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30870. */
  30871. readonly supportsUniformBuffers: boolean;
  30872. /**
  30873. * Observable raised when the engine begins a new frame
  30874. */
  30875. onBeginFrameObservable: Observable<Engine>;
  30876. /**
  30877. * If set, will be used to request the next animation frame for the render loop
  30878. */
  30879. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30880. /**
  30881. * Observable raised when the engine ends the current frame
  30882. */
  30883. onEndFrameObservable: Observable<Engine>;
  30884. /**
  30885. * Observable raised when the engine is about to compile a shader
  30886. */
  30887. onBeforeShaderCompilationObservable: Observable<Engine>;
  30888. /**
  30889. * Observable raised when the engine has jsut compiled a shader
  30890. */
  30891. onAfterShaderCompilationObservable: Observable<Engine>;
  30892. /** @hidden */
  30893. _gl: WebGLRenderingContext;
  30894. private _renderingCanvas;
  30895. private _windowIsBackground;
  30896. private _webGLVersion;
  30897. protected _highPrecisionShadersAllowed: boolean;
  30898. /** @hidden */
  30899. readonly _shouldUseHighPrecisionShader: boolean;
  30900. /**
  30901. * Gets a boolean indicating that only power of 2 textures are supported
  30902. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30903. */
  30904. readonly needPOTTextures: boolean;
  30905. /** @hidden */
  30906. _badOS: boolean;
  30907. /** @hidden */
  30908. _badDesktopOS: boolean;
  30909. /**
  30910. * Gets the audio engine
  30911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30912. * @ignorenaming
  30913. */
  30914. static audioEngine: IAudioEngine;
  30915. /**
  30916. * Default AudioEngine factory responsible of creating the Audio Engine.
  30917. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30918. */
  30919. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30920. /**
  30921. * Default offline support factory responsible of creating a tool used to store data locally.
  30922. * By default, this will create a Database object if the workload has been embedded.
  30923. */
  30924. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30925. private _onFocus;
  30926. private _onBlur;
  30927. private _onCanvasPointerOut;
  30928. private _onCanvasBlur;
  30929. private _onCanvasFocus;
  30930. private _onFullscreenChange;
  30931. private _onPointerLockChange;
  30932. private _hardwareScalingLevel;
  30933. /** @hidden */
  30934. _caps: EngineCapabilities;
  30935. private _pointerLockRequested;
  30936. private _isStencilEnable;
  30937. private _colorWrite;
  30938. private _loadingScreen;
  30939. /** @hidden */
  30940. _drawCalls: PerfCounter;
  30941. private _glVersion;
  30942. private _glRenderer;
  30943. private _glVendor;
  30944. private _videoTextureSupported;
  30945. private _renderingQueueLaunched;
  30946. private _activeRenderLoops;
  30947. private _deterministicLockstep;
  30948. private _lockstepMaxSteps;
  30949. /**
  30950. * Observable signaled when a context lost event is raised
  30951. */
  30952. onContextLostObservable: Observable<Engine>;
  30953. /**
  30954. * Observable signaled when a context restored event is raised
  30955. */
  30956. onContextRestoredObservable: Observable<Engine>;
  30957. private _onContextLost;
  30958. private _onContextRestored;
  30959. private _contextWasLost;
  30960. /** @hidden */
  30961. _doNotHandleContextLost: boolean;
  30962. /**
  30963. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30965. */
  30966. doNotHandleContextLost: boolean;
  30967. private _performanceMonitor;
  30968. private _fps;
  30969. private _deltaTime;
  30970. /**
  30971. * Turn this value on if you want to pause FPS computation when in background
  30972. */
  30973. disablePerformanceMonitorInBackground: boolean;
  30974. /**
  30975. * Gets the performance monitor attached to this engine
  30976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30977. */
  30978. readonly performanceMonitor: PerformanceMonitor;
  30979. /**
  30980. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30981. */
  30982. disableVertexArrayObjects: boolean;
  30983. /** @hidden */
  30984. protected _depthCullingState: _DepthCullingState;
  30985. /** @hidden */
  30986. protected _stencilState: _StencilState;
  30987. /** @hidden */
  30988. protected _alphaState: _AlphaState;
  30989. /** @hidden */
  30990. protected _alphaMode: number;
  30991. /** @hidden */
  30992. _internalTexturesCache: InternalTexture[];
  30993. /** @hidden */
  30994. protected _activeChannel: number;
  30995. private _currentTextureChannel;
  30996. /** @hidden */
  30997. protected _boundTexturesCache: {
  30998. [key: string]: Nullable<InternalTexture>;
  30999. };
  31000. /** @hidden */
  31001. protected _currentEffect: Nullable<Effect>;
  31002. /** @hidden */
  31003. protected _currentProgram: Nullable<WebGLProgram>;
  31004. private _compiledEffects;
  31005. private _vertexAttribArraysEnabled;
  31006. /** @hidden */
  31007. protected _cachedViewport: Nullable<IViewportLike>;
  31008. private _cachedVertexArrayObject;
  31009. /** @hidden */
  31010. protected _cachedVertexBuffers: any;
  31011. /** @hidden */
  31012. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31013. /** @hidden */
  31014. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31015. /** @hidden */
  31016. _currentRenderTarget: Nullable<InternalTexture>;
  31017. private _uintIndicesCurrentlySet;
  31018. private _currentBoundBuffer;
  31019. /** @hidden */
  31020. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31021. private _currentBufferPointers;
  31022. private _currentInstanceLocations;
  31023. private _currentInstanceBuffers;
  31024. private _textureUnits;
  31025. /** @hidden */
  31026. _workingCanvas: Nullable<HTMLCanvasElement>;
  31027. /** @hidden */
  31028. _workingContext: Nullable<CanvasRenderingContext2D>;
  31029. private _rescalePostProcess;
  31030. private _dummyFramebuffer;
  31031. private _externalData;
  31032. /** @hidden */
  31033. _bindedRenderFunction: any;
  31034. private _vaoRecordInProgress;
  31035. private _mustWipeVertexAttributes;
  31036. private _emptyTexture;
  31037. private _emptyCubeTexture;
  31038. private _emptyTexture3D;
  31039. /** @hidden */
  31040. _frameHandler: number;
  31041. private _nextFreeTextureSlots;
  31042. private _maxSimultaneousTextures;
  31043. private _activeRequests;
  31044. private _texturesSupported;
  31045. /** @hidden */
  31046. _textureFormatInUse: Nullable<string>;
  31047. /**
  31048. * Gets the list of texture formats supported
  31049. */
  31050. readonly texturesSupported: Array<string>;
  31051. /**
  31052. * Gets the list of texture formats in use
  31053. */
  31054. readonly textureFormatInUse: Nullable<string>;
  31055. /**
  31056. * Gets the current viewport
  31057. */
  31058. readonly currentViewport: Nullable<IViewportLike>;
  31059. /**
  31060. * Gets the default empty texture
  31061. */
  31062. readonly emptyTexture: InternalTexture;
  31063. /**
  31064. * Gets the default empty 3D texture
  31065. */
  31066. readonly emptyTexture3D: InternalTexture;
  31067. /**
  31068. * Gets the default empty cube texture
  31069. */
  31070. readonly emptyCubeTexture: InternalTexture;
  31071. /**
  31072. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31073. */
  31074. readonly premultipliedAlpha: boolean;
  31075. /**
  31076. * Creates a new engine
  31077. * @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
  31078. * @param antialias defines enable antialiasing (default: false)
  31079. * @param options defines further options to be sent to the getContext() function
  31080. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31081. */
  31082. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31083. /**
  31084. * Initializes a webVR display and starts listening to display change events
  31085. * The onVRDisplayChangedObservable will be notified upon these changes
  31086. * @returns The onVRDisplayChangedObservable
  31087. */
  31088. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31089. /** @hidden */
  31090. _prepareVRComponent(): void;
  31091. /** @hidden */
  31092. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31093. /** @hidden */
  31094. _submitVRFrame(): void;
  31095. /**
  31096. * Call this function to leave webVR mode
  31097. * Will do nothing if webVR is not supported or if there is no webVR device
  31098. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31099. */
  31100. disableVR(): void;
  31101. /**
  31102. * Gets a boolean indicating that the system is in VR mode and is presenting
  31103. * @returns true if VR mode is engaged
  31104. */
  31105. isVRPresenting(): boolean;
  31106. /** @hidden */
  31107. _requestVRFrame(): void;
  31108. private _disableTouchAction;
  31109. private _rebuildInternalTextures;
  31110. private _rebuildEffects;
  31111. /**
  31112. * Gets a boolean indicating if all created effects are ready
  31113. * @returns true if all effects are ready
  31114. */
  31115. areAllEffectsReady(): boolean;
  31116. private _rebuildBuffers;
  31117. private _initGLContext;
  31118. /**
  31119. * Gets version of the current webGL context
  31120. */
  31121. readonly webGLVersion: number;
  31122. /**
  31123. * Gets a string idenfifying the name of the class
  31124. * @returns "Engine" string
  31125. */
  31126. getClassName(): string;
  31127. /**
  31128. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31129. */
  31130. readonly isStencilEnable: boolean;
  31131. /** @hidden */
  31132. _prepareWorkingCanvas(): void;
  31133. /**
  31134. * Reset the texture cache to empty state
  31135. */
  31136. resetTextureCache(): void;
  31137. /**
  31138. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31140. * @returns true if engine is in deterministic lock step mode
  31141. */
  31142. isDeterministicLockStep(): boolean;
  31143. /**
  31144. * Gets the max steps when engine is running in deterministic lock step
  31145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31146. * @returns the max steps
  31147. */
  31148. getLockstepMaxSteps(): number;
  31149. /**
  31150. * Gets an object containing information about the current webGL context
  31151. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31152. */
  31153. getGlInfo(): {
  31154. vendor: string;
  31155. renderer: string;
  31156. version: string;
  31157. };
  31158. /**
  31159. * Gets current aspect ratio
  31160. * @param viewportOwner defines the camera to use to get the aspect ratio
  31161. * @param useScreen defines if screen size must be used (or the current render target if any)
  31162. * @returns a number defining the aspect ratio
  31163. */
  31164. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31165. /**
  31166. * Gets current screen aspect ratio
  31167. * @returns a number defining the aspect ratio
  31168. */
  31169. getScreenAspectRatio(): number;
  31170. /**
  31171. * Gets the current render width
  31172. * @param useScreen defines if screen size must be used (or the current render target if any)
  31173. * @returns a number defining the current render width
  31174. */
  31175. getRenderWidth(useScreen?: boolean): number;
  31176. /**
  31177. * Gets the current render height
  31178. * @param useScreen defines if screen size must be used (or the current render target if any)
  31179. * @returns a number defining the current render height
  31180. */
  31181. getRenderHeight(useScreen?: boolean): number;
  31182. /**
  31183. * Gets the HTML canvas attached with the current webGL context
  31184. * @returns a HTML canvas
  31185. */
  31186. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31187. /**
  31188. * Gets host window
  31189. * @returns the host window object
  31190. */
  31191. getHostWindow(): Window;
  31192. /**
  31193. * Gets host document
  31194. * @returns the host document object
  31195. */
  31196. getHostDocument(): Document;
  31197. /**
  31198. * Gets the client rect of the HTML canvas attached with the current webGL context
  31199. * @returns a client rectanglee
  31200. */
  31201. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31202. /**
  31203. * Defines the hardware scaling level.
  31204. * By default the hardware scaling level is computed from the window device ratio.
  31205. * 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.
  31206. * @param level defines the level to use
  31207. */
  31208. setHardwareScalingLevel(level: number): void;
  31209. /**
  31210. * Gets the current hardware scaling level.
  31211. * By default the hardware scaling level is computed from the window device ratio.
  31212. * 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.
  31213. * @returns a number indicating the current hardware scaling level
  31214. */
  31215. getHardwareScalingLevel(): number;
  31216. /**
  31217. * Gets the list of loaded textures
  31218. * @returns an array containing all loaded textures
  31219. */
  31220. getLoadedTexturesCache(): InternalTexture[];
  31221. /**
  31222. * Gets the object containing all engine capabilities
  31223. * @returns the EngineCapabilities object
  31224. */
  31225. getCaps(): EngineCapabilities;
  31226. /**
  31227. * Gets the current depth function
  31228. * @returns a number defining the depth function
  31229. */
  31230. getDepthFunction(): Nullable<number>;
  31231. /**
  31232. * Sets the current depth function
  31233. * @param depthFunc defines the function to use
  31234. */
  31235. setDepthFunction(depthFunc: number): void;
  31236. /**
  31237. * Sets the current depth function to GREATER
  31238. */
  31239. setDepthFunctionToGreater(): void;
  31240. /**
  31241. * Sets the current depth function to GEQUAL
  31242. */
  31243. setDepthFunctionToGreaterOrEqual(): void;
  31244. /**
  31245. * Sets the current depth function to LESS
  31246. */
  31247. setDepthFunctionToLess(): void;
  31248. private _cachedStencilBuffer;
  31249. private _cachedStencilFunction;
  31250. private _cachedStencilMask;
  31251. private _cachedStencilOperationPass;
  31252. private _cachedStencilOperationFail;
  31253. private _cachedStencilOperationDepthFail;
  31254. private _cachedStencilReference;
  31255. /**
  31256. * Caches the the state of the stencil buffer
  31257. */
  31258. cacheStencilState(): void;
  31259. /**
  31260. * Restores the state of the stencil buffer
  31261. */
  31262. restoreStencilState(): void;
  31263. /**
  31264. * Sets the current depth function to LEQUAL
  31265. */
  31266. setDepthFunctionToLessOrEqual(): void;
  31267. /**
  31268. * Gets a boolean indicating if stencil buffer is enabled
  31269. * @returns the current stencil buffer state
  31270. */
  31271. getStencilBuffer(): boolean;
  31272. /**
  31273. * Enable or disable the stencil buffer
  31274. * @param enable defines if the stencil buffer must be enabled or disabled
  31275. */
  31276. setStencilBuffer(enable: boolean): void;
  31277. /**
  31278. * Gets the current stencil mask
  31279. * @returns a number defining the new stencil mask to use
  31280. */
  31281. getStencilMask(): number;
  31282. /**
  31283. * Sets the current stencil mask
  31284. * @param mask defines the new stencil mask to use
  31285. */
  31286. setStencilMask(mask: number): void;
  31287. /**
  31288. * Gets the current stencil function
  31289. * @returns a number defining the stencil function to use
  31290. */
  31291. getStencilFunction(): number;
  31292. /**
  31293. * Gets the current stencil reference value
  31294. * @returns a number defining the stencil reference value to use
  31295. */
  31296. getStencilFunctionReference(): number;
  31297. /**
  31298. * Gets the current stencil mask
  31299. * @returns a number defining the stencil mask to use
  31300. */
  31301. getStencilFunctionMask(): number;
  31302. /**
  31303. * Sets the current stencil function
  31304. * @param stencilFunc defines the new stencil function to use
  31305. */
  31306. setStencilFunction(stencilFunc: number): void;
  31307. /**
  31308. * Sets the current stencil reference
  31309. * @param reference defines the new stencil reference to use
  31310. */
  31311. setStencilFunctionReference(reference: number): void;
  31312. /**
  31313. * Sets the current stencil mask
  31314. * @param mask defines the new stencil mask to use
  31315. */
  31316. setStencilFunctionMask(mask: number): void;
  31317. /**
  31318. * Gets the current stencil operation when stencil fails
  31319. * @returns a number defining stencil operation to use when stencil fails
  31320. */
  31321. getStencilOperationFail(): number;
  31322. /**
  31323. * Gets the current stencil operation when depth fails
  31324. * @returns a number defining stencil operation to use when depth fails
  31325. */
  31326. getStencilOperationDepthFail(): number;
  31327. /**
  31328. * Gets the current stencil operation when stencil passes
  31329. * @returns a number defining stencil operation to use when stencil passes
  31330. */
  31331. getStencilOperationPass(): number;
  31332. /**
  31333. * Sets the stencil operation to use when stencil fails
  31334. * @param operation defines the stencil operation to use when stencil fails
  31335. */
  31336. setStencilOperationFail(operation: number): void;
  31337. /**
  31338. * Sets the stencil operation to use when depth fails
  31339. * @param operation defines the stencil operation to use when depth fails
  31340. */
  31341. setStencilOperationDepthFail(operation: number): void;
  31342. /**
  31343. * Sets the stencil operation to use when stencil passes
  31344. * @param operation defines the stencil operation to use when stencil passes
  31345. */
  31346. setStencilOperationPass(operation: number): void;
  31347. /**
  31348. * Sets a boolean indicating if the dithering state is enabled or disabled
  31349. * @param value defines the dithering state
  31350. */
  31351. setDitheringState(value: boolean): void;
  31352. /**
  31353. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31354. * @param value defines the rasterizer state
  31355. */
  31356. setRasterizerState(value: boolean): void;
  31357. /**
  31358. * stop executing a render loop function and remove it from the execution array
  31359. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31360. */
  31361. stopRenderLoop(renderFunction?: () => void): void;
  31362. /** @hidden */
  31363. _renderLoop(): void;
  31364. /**
  31365. * Register and execute a render loop. The engine can have more than one render function
  31366. * @param renderFunction defines the function to continuously execute
  31367. */
  31368. runRenderLoop(renderFunction: () => void): void;
  31369. /**
  31370. * Toggle full screen mode
  31371. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31372. */
  31373. switchFullscreen(requestPointerLock: boolean): void;
  31374. /**
  31375. * Enters full screen mode
  31376. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31377. */
  31378. enterFullscreen(requestPointerLock: boolean): void;
  31379. /**
  31380. * Exits full screen mode
  31381. */
  31382. exitFullscreen(): void;
  31383. /**
  31384. * Enters Pointerlock mode
  31385. */
  31386. enterPointerlock(): void;
  31387. /**
  31388. * Exits Pointerlock mode
  31389. */
  31390. exitPointerlock(): void;
  31391. /**
  31392. * Clear the current render buffer or the current render target (if any is set up)
  31393. * @param color defines the color to use
  31394. * @param backBuffer defines if the back buffer must be cleared
  31395. * @param depth defines if the depth buffer must be cleared
  31396. * @param stencil defines if the stencil buffer must be cleared
  31397. */
  31398. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31399. /**
  31400. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31401. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31402. * @param y defines the y-coordinate of the corner of the clear rectangle
  31403. * @param width defines the width of the clear rectangle
  31404. * @param height defines the height of the clear rectangle
  31405. * @param clearColor defines the clear color
  31406. */
  31407. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31408. /**
  31409. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31410. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31411. * @param y defines the y-coordinate of the corner of the clear rectangle
  31412. * @param width defines the width of the clear rectangle
  31413. * @param height defines the height of the clear rectangle
  31414. */
  31415. enableScissor(x: number, y: number, width: number, height: number): void;
  31416. /**
  31417. * Disable previously set scissor test rectangle
  31418. */
  31419. disableScissor(): void;
  31420. private _viewportCached;
  31421. /** @hidden */
  31422. _viewport(x: number, y: number, width: number, height: number): void;
  31423. /**
  31424. * Set the WebGL's viewport
  31425. * @param viewport defines the viewport element to be used
  31426. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31427. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31428. */
  31429. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31430. /**
  31431. * Directly set the WebGL Viewport
  31432. * @param x defines the x coordinate of the viewport (in screen space)
  31433. * @param y defines the y coordinate of the viewport (in screen space)
  31434. * @param width defines the width of the viewport (in screen space)
  31435. * @param height defines the height of the viewport (in screen space)
  31436. * @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
  31437. */
  31438. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31439. /**
  31440. * Begin a new frame
  31441. */
  31442. beginFrame(): void;
  31443. /**
  31444. * Enf the current frame
  31445. */
  31446. endFrame(): void;
  31447. /**
  31448. * Resize the view according to the canvas' size
  31449. */
  31450. resize(): void;
  31451. /**
  31452. * Force a specific size of the canvas
  31453. * @param width defines the new canvas' width
  31454. * @param height defines the new canvas' height
  31455. */
  31456. setSize(width: number, height: number): void;
  31457. /**
  31458. * Binds the frame buffer to the specified texture.
  31459. * @param texture The texture to render to or null for the default canvas
  31460. * @param faceIndex The face of the texture to render to in case of cube texture
  31461. * @param requiredWidth The width of the target to render to
  31462. * @param requiredHeight The height of the target to render to
  31463. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31464. * @param depthStencilTexture The depth stencil texture to use to render
  31465. * @param lodLevel defines le lod level to bind to the frame buffer
  31466. */
  31467. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31468. /** @hidden */
  31469. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31470. /**
  31471. * Unbind the current render target texture from the webGL context
  31472. * @param texture defines the render target texture to unbind
  31473. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31474. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31475. */
  31476. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31477. /**
  31478. * Force the mipmap generation for the given render target texture
  31479. * @param texture defines the render target texture to use
  31480. */
  31481. generateMipMapsForCubemap(texture: InternalTexture): void;
  31482. /**
  31483. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31484. */
  31485. flushFramebuffer(): void;
  31486. /**
  31487. * Unbind the current render target and bind the default framebuffer
  31488. */
  31489. restoreDefaultFramebuffer(): void;
  31490. /**
  31491. * Create an uniform buffer
  31492. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31493. * @param elements defines the content of the uniform buffer
  31494. * @returns the webGL uniform buffer
  31495. */
  31496. createUniformBuffer(elements: FloatArray): DataBuffer;
  31497. /**
  31498. * Create a dynamic uniform buffer
  31499. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31500. * @param elements defines the content of the uniform buffer
  31501. * @returns the webGL uniform buffer
  31502. */
  31503. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31504. /**
  31505. * Update an existing uniform buffer
  31506. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31507. * @param uniformBuffer defines the target uniform buffer
  31508. * @param elements defines the content to update
  31509. * @param offset defines the offset in the uniform buffer where update should start
  31510. * @param count defines the size of the data to update
  31511. */
  31512. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31513. private _resetVertexBufferBinding;
  31514. /**
  31515. * Creates a vertex buffer
  31516. * @param data the data for the vertex buffer
  31517. * @returns the new WebGL static buffer
  31518. */
  31519. createVertexBuffer(data: DataArray): DataBuffer;
  31520. /**
  31521. * Creates a dynamic vertex buffer
  31522. * @param data the data for the dynamic vertex buffer
  31523. * @returns the new WebGL dynamic buffer
  31524. */
  31525. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31526. /**
  31527. * Update a dynamic index buffer
  31528. * @param indexBuffer defines the target index buffer
  31529. * @param indices defines the data to update
  31530. * @param offset defines the offset in the target index buffer where update should start
  31531. */
  31532. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31533. /**
  31534. * Updates a dynamic vertex buffer.
  31535. * @param vertexBuffer the vertex buffer to update
  31536. * @param data the data used to update the vertex buffer
  31537. * @param byteOffset the byte offset of the data
  31538. * @param byteLength the byte length of the data
  31539. */
  31540. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31541. private _resetIndexBufferBinding;
  31542. /**
  31543. * Creates a new index buffer
  31544. * @param indices defines the content of the index buffer
  31545. * @param updatable defines if the index buffer must be updatable
  31546. * @returns a new webGL buffer
  31547. */
  31548. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31549. /**
  31550. * Bind a webGL buffer to the webGL context
  31551. * @param buffer defines the buffer to bind
  31552. */
  31553. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31554. /**
  31555. * Bind an uniform buffer to the current webGL context
  31556. * @param buffer defines the buffer to bind
  31557. */
  31558. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31559. /**
  31560. * Bind a buffer to the current webGL context at a given location
  31561. * @param buffer defines the buffer to bind
  31562. * @param location defines the index where to bind the buffer
  31563. */
  31564. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31565. /**
  31566. * Bind a specific block at a given index in a specific shader program
  31567. * @param pipelineContext defines the pipeline context to use
  31568. * @param blockName defines the block name
  31569. * @param index defines the index where to bind the block
  31570. */
  31571. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31572. private bindIndexBuffer;
  31573. private bindBuffer;
  31574. /**
  31575. * update the bound buffer with the given data
  31576. * @param data defines the data to update
  31577. */
  31578. updateArrayBuffer(data: Float32Array): void;
  31579. private _vertexAttribPointer;
  31580. private _bindIndexBufferWithCache;
  31581. private _bindVertexBuffersAttributes;
  31582. /**
  31583. * Records a vertex array object
  31584. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31585. * @param vertexBuffers defines the list of vertex buffers to store
  31586. * @param indexBuffer defines the index buffer to store
  31587. * @param effect defines the effect to store
  31588. * @returns the new vertex array object
  31589. */
  31590. recordVertexArrayObject(vertexBuffers: {
  31591. [key: string]: VertexBuffer;
  31592. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31593. /**
  31594. * Bind a specific vertex array object
  31595. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31596. * @param vertexArrayObject defines the vertex array object to bind
  31597. * @param indexBuffer defines the index buffer to bind
  31598. */
  31599. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31600. /**
  31601. * Bind webGl buffers directly to the webGL context
  31602. * @param vertexBuffer defines the vertex buffer to bind
  31603. * @param indexBuffer defines the index buffer to bind
  31604. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31605. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31606. * @param effect defines the effect associated with the vertex buffer
  31607. */
  31608. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31609. private _unbindVertexArrayObject;
  31610. /**
  31611. * Bind a list of vertex buffers to the webGL context
  31612. * @param vertexBuffers defines the list of vertex buffers to bind
  31613. * @param indexBuffer defines the index buffer to bind
  31614. * @param effect defines the effect associated with the vertex buffers
  31615. */
  31616. bindBuffers(vertexBuffers: {
  31617. [key: string]: Nullable<VertexBuffer>;
  31618. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31619. /**
  31620. * Unbind all instance attributes
  31621. */
  31622. unbindInstanceAttributes(): void;
  31623. /**
  31624. * Release and free the memory of a vertex array object
  31625. * @param vao defines the vertex array object to delete
  31626. */
  31627. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31628. /** @hidden */
  31629. _releaseBuffer(buffer: DataBuffer): boolean;
  31630. /**
  31631. * Creates a webGL buffer to use with instanciation
  31632. * @param capacity defines the size of the buffer
  31633. * @returns the webGL buffer
  31634. */
  31635. createInstancesBuffer(capacity: number): DataBuffer;
  31636. /**
  31637. * Delete a webGL buffer used with instanciation
  31638. * @param buffer defines the webGL buffer to delete
  31639. */
  31640. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31641. /**
  31642. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31643. * @param instancesBuffer defines the webGL buffer to update and bind
  31644. * @param data defines the data to store in the buffer
  31645. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31646. */
  31647. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31648. /**
  31649. * Apply all cached states (depth, culling, stencil and alpha)
  31650. */
  31651. applyStates(): void;
  31652. /**
  31653. * Send a draw order
  31654. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31655. * @param indexStart defines the starting index
  31656. * @param indexCount defines the number of index to draw
  31657. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31658. */
  31659. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31660. /**
  31661. * Draw a list of points
  31662. * @param verticesStart defines the index of first vertex to draw
  31663. * @param verticesCount defines the count of vertices to draw
  31664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31665. */
  31666. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31667. /**
  31668. * Draw a list of unindexed primitives
  31669. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31670. * @param verticesStart defines the index of first vertex to draw
  31671. * @param verticesCount defines the count of vertices to draw
  31672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31673. */
  31674. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31675. /**
  31676. * Draw a list of indexed primitives
  31677. * @param fillMode defines the primitive to use
  31678. * @param indexStart defines the starting index
  31679. * @param indexCount defines the number of index to draw
  31680. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31681. */
  31682. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31683. /**
  31684. * Draw a list of unindexed primitives
  31685. * @param fillMode defines the primitive to use
  31686. * @param verticesStart defines the index of first vertex to draw
  31687. * @param verticesCount defines the count of vertices to draw
  31688. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31689. */
  31690. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31691. private _drawMode;
  31692. /** @hidden */
  31693. _releaseEffect(effect: Effect): void;
  31694. /** @hidden */
  31695. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31696. /**
  31697. * Create a new effect (used to store vertex/fragment shaders)
  31698. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31699. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31700. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31701. * @param samplers defines an array of string used to represent textures
  31702. * @param defines defines the string containing the defines to use to compile the shaders
  31703. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31704. * @param onCompiled defines a function to call when the effect creation is successful
  31705. * @param onError defines a function to call when the effect creation has failed
  31706. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31707. * @returns the new Effect
  31708. */
  31709. 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;
  31710. private _compileShader;
  31711. private _compileRawShader;
  31712. /**
  31713. * Directly creates a webGL program
  31714. * @param pipelineContext defines the pipeline context to attach to
  31715. * @param vertexCode defines the vertex shader code to use
  31716. * @param fragmentCode defines the fragment shader code to use
  31717. * @param context defines the webGL context to use (if not set, the current one will be used)
  31718. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31719. * @returns the new webGL program
  31720. */
  31721. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31722. /**
  31723. * Creates a webGL program
  31724. * @param pipelineContext defines the pipeline context to attach to
  31725. * @param vertexCode defines the vertex shader code to use
  31726. * @param fragmentCode defines the fragment shader code to use
  31727. * @param defines defines the string containing the defines to use to compile the shaders
  31728. * @param context defines the webGL context to use (if not set, the current one will be used)
  31729. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31730. * @returns the new webGL program
  31731. */
  31732. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31733. /**
  31734. * Creates a new pipeline context
  31735. * @returns the new pipeline
  31736. */
  31737. createPipelineContext(): WebGLPipelineContext;
  31738. private _createShaderProgram;
  31739. private _finalizePipelineContext;
  31740. /** @hidden */
  31741. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31742. /** @hidden */
  31743. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31744. /** @hidden */
  31745. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31746. /**
  31747. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31748. * @param pipelineContext defines the pipeline context to use
  31749. * @param uniformsNames defines the list of uniform names
  31750. * @returns an array of webGL uniform locations
  31751. */
  31752. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31753. /**
  31754. * Gets the lsit of active attributes for a given webGL program
  31755. * @param pipelineContext defines the pipeline context to use
  31756. * @param attributesNames defines the list of attribute names to get
  31757. * @returns an array of indices indicating the offset of each attribute
  31758. */
  31759. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31760. /**
  31761. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31762. * @param effect defines the effect to activate
  31763. */
  31764. enableEffect(effect: Nullable<Effect>): void;
  31765. /**
  31766. * Set the value of an uniform to an array of int32
  31767. * @param uniform defines the webGL uniform location where to store the value
  31768. * @param array defines the array of int32 to store
  31769. */
  31770. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31771. /**
  31772. * Set the value of an uniform to an array of int32 (stored as vec2)
  31773. * @param uniform defines the webGL uniform location where to store the value
  31774. * @param array defines the array of int32 to store
  31775. */
  31776. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31777. /**
  31778. * Set the value of an uniform to an array of int32 (stored as vec3)
  31779. * @param uniform defines the webGL uniform location where to store the value
  31780. * @param array defines the array of int32 to store
  31781. */
  31782. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31783. /**
  31784. * Set the value of an uniform to an array of int32 (stored as vec4)
  31785. * @param uniform defines the webGL uniform location where to store the value
  31786. * @param array defines the array of int32 to store
  31787. */
  31788. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31789. /**
  31790. * Set the value of an uniform to an array of float32
  31791. * @param uniform defines the webGL uniform location where to store the value
  31792. * @param array defines the array of float32 to store
  31793. */
  31794. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31795. /**
  31796. * Set the value of an uniform to an array of float32 (stored as vec2)
  31797. * @param uniform defines the webGL uniform location where to store the value
  31798. * @param array defines the array of float32 to store
  31799. */
  31800. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31801. /**
  31802. * Set the value of an uniform to an array of float32 (stored as vec3)
  31803. * @param uniform defines the webGL uniform location where to store the value
  31804. * @param array defines the array of float32 to store
  31805. */
  31806. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31807. /**
  31808. * Set the value of an uniform to an array of float32 (stored as vec4)
  31809. * @param uniform defines the webGL uniform location where to store the value
  31810. * @param array defines the array of float32 to store
  31811. */
  31812. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31813. /**
  31814. * Set the value of an uniform to an array of number
  31815. * @param uniform defines the webGL uniform location where to store the value
  31816. * @param array defines the array of number to store
  31817. */
  31818. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31819. /**
  31820. * Set the value of an uniform to an array of number (stored as vec2)
  31821. * @param uniform defines the webGL uniform location where to store the value
  31822. * @param array defines the array of number to store
  31823. */
  31824. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31825. /**
  31826. * Set the value of an uniform to an array of number (stored as vec3)
  31827. * @param uniform defines the webGL uniform location where to store the value
  31828. * @param array defines the array of number to store
  31829. */
  31830. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31831. /**
  31832. * Set the value of an uniform to an array of number (stored as vec4)
  31833. * @param uniform defines the webGL uniform location where to store the value
  31834. * @param array defines the array of number to store
  31835. */
  31836. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31837. /**
  31838. * Set the value of an uniform to an array of float32 (stored as matrices)
  31839. * @param uniform defines the webGL uniform location where to store the value
  31840. * @param matrices defines the array of float32 to store
  31841. */
  31842. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31843. /**
  31844. * Set the value of an uniform to a matrix (3x3)
  31845. * @param uniform defines the webGL uniform location where to store the value
  31846. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31847. */
  31848. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31849. /**
  31850. * Set the value of an uniform to a matrix (2x2)
  31851. * @param uniform defines the webGL uniform location where to store the value
  31852. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31853. */
  31854. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31855. /**
  31856. * Set the value of an uniform to a number (int)
  31857. * @param uniform defines the webGL uniform location where to store the value
  31858. * @param value defines the int number to store
  31859. */
  31860. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31861. /**
  31862. * Set the value of an uniform to a number (float)
  31863. * @param uniform defines the webGL uniform location where to store the value
  31864. * @param value defines the float number to store
  31865. */
  31866. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31867. /**
  31868. * Set the value of an uniform to a vec2
  31869. * @param uniform defines the webGL uniform location where to store the value
  31870. * @param x defines the 1st component of the value
  31871. * @param y defines the 2nd component of the value
  31872. */
  31873. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31874. /**
  31875. * Set the value of an uniform to a vec3
  31876. * @param uniform defines the webGL uniform location where to store the value
  31877. * @param x defines the 1st component of the value
  31878. * @param y defines the 2nd component of the value
  31879. * @param z defines the 3rd component of the value
  31880. */
  31881. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31882. /**
  31883. * Set the value of an uniform to a boolean
  31884. * @param uniform defines the webGL uniform location where to store the value
  31885. * @param bool defines the boolean to store
  31886. */
  31887. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31888. /**
  31889. * Set the value of an uniform to a vec4
  31890. * @param uniform defines the webGL uniform location where to store the value
  31891. * @param x defines the 1st component of the value
  31892. * @param y defines the 2nd component of the value
  31893. * @param z defines the 3rd component of the value
  31894. * @param w defines the 4th component of the value
  31895. */
  31896. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31897. /**
  31898. * Sets a Color4 on a uniform variable
  31899. * @param uniform defines the uniform location
  31900. * @param color4 defines the value to be set
  31901. */
  31902. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31903. /**
  31904. * Set various states to the webGL context
  31905. * @param culling defines backface culling state
  31906. * @param zOffset defines the value to apply to zOffset (0 by default)
  31907. * @param force defines if states must be applied even if cache is up to date
  31908. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31909. */
  31910. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31911. /**
  31912. * Set the z offset to apply to current rendering
  31913. * @param value defines the offset to apply
  31914. */
  31915. setZOffset(value: number): void;
  31916. /**
  31917. * Gets the current value of the zOffset
  31918. * @returns the current zOffset state
  31919. */
  31920. getZOffset(): number;
  31921. /**
  31922. * Enable or disable depth buffering
  31923. * @param enable defines the state to set
  31924. */
  31925. setDepthBuffer(enable: boolean): void;
  31926. /**
  31927. * Gets a boolean indicating if depth writing is enabled
  31928. * @returns the current depth writing state
  31929. */
  31930. getDepthWrite(): boolean;
  31931. /**
  31932. * Enable or disable depth writing
  31933. * @param enable defines the state to set
  31934. */
  31935. setDepthWrite(enable: boolean): void;
  31936. /**
  31937. * Enable or disable color writing
  31938. * @param enable defines the state to set
  31939. */
  31940. setColorWrite(enable: boolean): void;
  31941. /**
  31942. * Gets a boolean indicating if color writing is enabled
  31943. * @returns the current color writing state
  31944. */
  31945. getColorWrite(): boolean;
  31946. /**
  31947. * Sets alpha constants used by some alpha blending modes
  31948. * @param r defines the red component
  31949. * @param g defines the green component
  31950. * @param b defines the blue component
  31951. * @param a defines the alpha component
  31952. */
  31953. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31954. /**
  31955. * Sets the current alpha mode
  31956. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31957. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31958. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31959. */
  31960. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31961. /**
  31962. * Gets the current alpha mode
  31963. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31964. * @returns the current alpha mode
  31965. */
  31966. getAlphaMode(): number;
  31967. /**
  31968. * Clears the list of texture accessible through engine.
  31969. * This can help preventing texture load conflict due to name collision.
  31970. */
  31971. clearInternalTexturesCache(): void;
  31972. /**
  31973. * Force the entire cache to be cleared
  31974. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31975. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31976. */
  31977. wipeCaches(bruteForce?: boolean): void;
  31978. /**
  31979. * Set the compressed texture format to use, based on the formats you have, and the formats
  31980. * supported by the hardware / browser.
  31981. *
  31982. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31983. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31984. * to API arguments needed to compressed textures. This puts the burden on the container
  31985. * generator to house the arcane code for determining these for current & future formats.
  31986. *
  31987. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31988. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31989. *
  31990. * Note: The result of this call is not taken into account when a texture is base64.
  31991. *
  31992. * @param formatsAvailable defines the list of those format families you have created
  31993. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31994. *
  31995. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31996. * @returns The extension selected.
  31997. */
  31998. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31999. /** @hidden */
  32000. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32001. min: number;
  32002. mag: number;
  32003. };
  32004. /** @hidden */
  32005. _createTexture(): WebGLTexture;
  32006. /**
  32007. * Usually called from Texture.ts.
  32008. * Passed information to create a WebGLTexture
  32009. * @param urlArg defines a value which contains one of the following:
  32010. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32011. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32012. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32013. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32014. * @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)
  32015. * @param scene needed for loading to the correct scene
  32016. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32017. * @param onLoad optional callback to be called upon successful completion
  32018. * @param onError optional callback to be called upon failure
  32019. * @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
  32020. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32021. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32022. * @param forcedExtension defines the extension to use to pick the right loader
  32023. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32024. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32025. */
  32026. 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;
  32027. /**
  32028. * @hidden
  32029. * Rescales a texture
  32030. * @param source input texutre
  32031. * @param destination destination texture
  32032. * @param scene scene to use to render the resize
  32033. * @param internalFormat format to use when resizing
  32034. * @param onComplete callback to be called when resize has completed
  32035. */
  32036. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32037. private _unpackFlipYCached;
  32038. /**
  32039. * In case you are sharing the context with other applications, it might
  32040. * be interested to not cache the unpack flip y state to ensure a consistent
  32041. * value would be set.
  32042. */
  32043. enableUnpackFlipYCached: boolean;
  32044. /** @hidden */
  32045. _unpackFlipY(value: boolean): void;
  32046. /** @hidden */
  32047. _getUnpackAlignement(): number;
  32048. /**
  32049. * Creates a dynamic texture
  32050. * @param width defines the width of the texture
  32051. * @param height defines the height of the texture
  32052. * @param generateMipMaps defines if the engine should generate the mip levels
  32053. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32054. * @returns the dynamic texture inside an InternalTexture
  32055. */
  32056. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32057. /**
  32058. * Update the sampling mode of a given texture
  32059. * @param samplingMode defines the required sampling mode
  32060. * @param texture defines the texture to update
  32061. */
  32062. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32063. /**
  32064. * Update the content of a dynamic texture
  32065. * @param texture defines the texture to update
  32066. * @param canvas defines the canvas containing the source
  32067. * @param invertY defines if data must be stored with Y axis inverted
  32068. * @param premulAlpha defines if alpha is stored as premultiplied
  32069. * @param format defines the format of the data
  32070. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32071. */
  32072. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32073. /**
  32074. * Update a video texture
  32075. * @param texture defines the texture to update
  32076. * @param video defines the video element to use
  32077. * @param invertY defines if data must be stored with Y axis inverted
  32078. */
  32079. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32080. /**
  32081. * Updates a depth texture Comparison Mode and Function.
  32082. * If the comparison Function is equal to 0, the mode will be set to none.
  32083. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32084. * @param texture The texture to set the comparison function for
  32085. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32086. */
  32087. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32088. /** @hidden */
  32089. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32090. width: number;
  32091. height: number;
  32092. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32093. /**
  32094. * Creates a depth stencil texture.
  32095. * This is only available in WebGL 2 or with the depth texture extension available.
  32096. * @param size The size of face edge in the texture.
  32097. * @param options The options defining the texture.
  32098. * @returns The texture
  32099. */
  32100. createDepthStencilTexture(size: number | {
  32101. width: number;
  32102. height: number;
  32103. }, options: DepthTextureCreationOptions): InternalTexture;
  32104. /**
  32105. * Creates a depth stencil texture.
  32106. * This is only available in WebGL 2 or with the depth texture extension available.
  32107. * @param size The size of face edge in the texture.
  32108. * @param options The options defining the texture.
  32109. * @returns The texture
  32110. */
  32111. private _createDepthStencilTexture;
  32112. /**
  32113. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32114. * @param renderTarget The render target to set the frame buffer for
  32115. */
  32116. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32117. /**
  32118. * Creates a new render target texture
  32119. * @param size defines the size of the texture
  32120. * @param options defines the options used to create the texture
  32121. * @returns a new render target texture stored in an InternalTexture
  32122. */
  32123. createRenderTargetTexture(size: number | {
  32124. width: number;
  32125. height: number;
  32126. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32127. /** @hidden */
  32128. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32129. /**
  32130. * Updates the sample count of a render target texture
  32131. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32132. * @param texture defines the texture to update
  32133. * @param samples defines the sample count to set
  32134. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32135. */
  32136. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32137. /** @hidden */
  32138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32139. /** @hidden */
  32140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32141. /** @hidden */
  32142. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32143. /** @hidden */
  32144. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32145. /**
  32146. * @hidden
  32147. */
  32148. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32149. private _prepareWebGLTextureContinuation;
  32150. private _prepareWebGLTexture;
  32151. /** @hidden */
  32152. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32153. /** @hidden */
  32154. _releaseFramebufferObjects(texture: InternalTexture): void;
  32155. /** @hidden */
  32156. _releaseTexture(texture: InternalTexture): void;
  32157. private setProgram;
  32158. private _boundUniforms;
  32159. /**
  32160. * Binds an effect to the webGL context
  32161. * @param effect defines the effect to bind
  32162. */
  32163. bindSamplers(effect: Effect): void;
  32164. private _activateCurrentTexture;
  32165. /** @hidden */
  32166. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32167. /** @hidden */
  32168. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32169. /**
  32170. * Sets a texture to the webGL context from a postprocess
  32171. * @param channel defines the channel to use
  32172. * @param postProcess defines the source postprocess
  32173. */
  32174. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32175. /**
  32176. * Binds the output of the passed in post process to the texture channel specified
  32177. * @param channel The channel the texture should be bound to
  32178. * @param postProcess The post process which's output should be bound
  32179. */
  32180. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32181. /**
  32182. * Unbind all textures from the webGL context
  32183. */
  32184. unbindAllTextures(): void;
  32185. /**
  32186. * Sets a texture to the according uniform.
  32187. * @param channel The texture channel
  32188. * @param uniform The uniform to set
  32189. * @param texture The texture to apply
  32190. */
  32191. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32192. /**
  32193. * Sets a depth stencil texture from a render target to the according uniform.
  32194. * @param channel The texture channel
  32195. * @param uniform The uniform to set
  32196. * @param texture The render target texture containing the depth stencil texture to apply
  32197. */
  32198. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32199. private _bindSamplerUniformToChannel;
  32200. private _getTextureWrapMode;
  32201. private _setTexture;
  32202. /**
  32203. * Sets an array of texture to the webGL context
  32204. * @param channel defines the channel where the texture array must be set
  32205. * @param uniform defines the associated uniform location
  32206. * @param textures defines the array of textures to bind
  32207. */
  32208. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32209. /** @hidden */
  32210. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32211. private _setTextureParameterFloat;
  32212. private _setTextureParameterInteger;
  32213. /**
  32214. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32215. * @param x defines the x coordinate of the rectangle where pixels must be read
  32216. * @param y defines the y coordinate of the rectangle where pixels must be read
  32217. * @param width defines the width of the rectangle where pixels must be read
  32218. * @param height defines the height of the rectangle where pixels must be read
  32219. * @returns a Uint8Array containing RGBA colors
  32220. */
  32221. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32222. /**
  32223. * Add an externaly attached data from its key.
  32224. * This method call will fail and return false, if such key already exists.
  32225. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32226. * @param key the unique key that identifies the data
  32227. * @param data the data object to associate to the key for this Engine instance
  32228. * @return true if no such key were already present and the data was added successfully, false otherwise
  32229. */
  32230. addExternalData<T>(key: string, data: T): boolean;
  32231. /**
  32232. * Get an externaly attached data from its key
  32233. * @param key the unique key that identifies the data
  32234. * @return the associated data, if present (can be null), or undefined if not present
  32235. */
  32236. getExternalData<T>(key: string): T;
  32237. /**
  32238. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32239. * @param key the unique key that identifies the data
  32240. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32241. * @return the associated data, can be null if the factory returned null.
  32242. */
  32243. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32244. /**
  32245. * Remove an externaly attached data from the Engine instance
  32246. * @param key the unique key that identifies the data
  32247. * @return true if the data was successfully removed, false if it doesn't exist
  32248. */
  32249. removeExternalData(key: string): boolean;
  32250. /**
  32251. * Unbind all vertex attributes from the webGL context
  32252. */
  32253. unbindAllAttributes(): void;
  32254. /**
  32255. * 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
  32256. */
  32257. releaseEffects(): void;
  32258. /**
  32259. * Dispose and release all associated resources
  32260. */
  32261. dispose(): void;
  32262. /**
  32263. * Display the loading screen
  32264. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32265. */
  32266. displayLoadingUI(): void;
  32267. /**
  32268. * Hide the loading screen
  32269. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32270. */
  32271. hideLoadingUI(): void;
  32272. /**
  32273. * Gets the current loading screen object
  32274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32275. */
  32276. /**
  32277. * Sets the current loading screen object
  32278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32279. */
  32280. loadingScreen: ILoadingScreen;
  32281. /**
  32282. * Sets the current loading screen text
  32283. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32284. */
  32285. loadingUIText: string;
  32286. /**
  32287. * Sets the current loading screen background color
  32288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32289. */
  32290. loadingUIBackgroundColor: string;
  32291. /**
  32292. * Attach a new callback raised when context lost event is fired
  32293. * @param callback defines the callback to call
  32294. */
  32295. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32296. /**
  32297. * Attach a new callback raised when context restored event is fired
  32298. * @param callback defines the callback to call
  32299. */
  32300. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32301. /**
  32302. * Gets the source code of the vertex shader associated with a specific webGL program
  32303. * @param program defines the program to use
  32304. * @returns a string containing the source code of the vertex shader associated with the program
  32305. */
  32306. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32307. /**
  32308. * Gets the source code of the fragment shader associated with a specific webGL program
  32309. * @param program defines the program to use
  32310. * @returns a string containing the source code of the fragment shader associated with the program
  32311. */
  32312. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32313. /**
  32314. * Get the current error code of the webGL context
  32315. * @returns the error code
  32316. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32317. */
  32318. getError(): number;
  32319. /**
  32320. * Gets the current framerate
  32321. * @returns a number representing the framerate
  32322. */
  32323. getFps(): number;
  32324. /**
  32325. * Gets the time spent between current and previous frame
  32326. * @returns a number representing the delta time in ms
  32327. */
  32328. getDeltaTime(): number;
  32329. private _measureFps;
  32330. /** @hidden */
  32331. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32332. private _canRenderToFloatFramebuffer;
  32333. private _canRenderToHalfFloatFramebuffer;
  32334. private _canRenderToFramebuffer;
  32335. /** @hidden */
  32336. _getWebGLTextureType(type: number): number;
  32337. /** @hidden */
  32338. _getInternalFormat(format: number): number;
  32339. /** @hidden */
  32340. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32341. /** @hidden */
  32342. _getRGBAMultiSampleBufferFormat(type: number): number;
  32343. /** @hidden */
  32344. _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;
  32345. /** @hidden */
  32346. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32347. /**
  32348. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32349. * @returns true if the engine can be created
  32350. * @ignorenaming
  32351. */
  32352. static isSupported(): boolean;
  32353. /**
  32354. * Find the next highest power of two.
  32355. * @param x Number to start search from.
  32356. * @return Next highest power of two.
  32357. */
  32358. static CeilingPOT(x: number): number;
  32359. /**
  32360. * Find the next lowest power of two.
  32361. * @param x Number to start search from.
  32362. * @return Next lowest power of two.
  32363. */
  32364. static FloorPOT(x: number): number;
  32365. /**
  32366. * Find the nearest power of two.
  32367. * @param x Number to start search from.
  32368. * @return Next nearest power of two.
  32369. */
  32370. static NearestPOT(x: number): number;
  32371. /**
  32372. * Get the closest exponent of two
  32373. * @param value defines the value to approximate
  32374. * @param max defines the maximum value to return
  32375. * @param mode defines how to define the closest value
  32376. * @returns closest exponent of two of the given value
  32377. */
  32378. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32379. /**
  32380. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32381. * @param func - the function to be called
  32382. * @param requester - the object that will request the next frame. Falls back to window.
  32383. * @returns frame number
  32384. */
  32385. static QueueNewFrame(func: () => void, requester?: any): number;
  32386. /**
  32387. * Ask the browser to promote the current element to pointerlock mode
  32388. * @param element defines the DOM element to promote
  32389. */
  32390. static _RequestPointerlock(element: HTMLElement): void;
  32391. /**
  32392. * Asks the browser to exit pointerlock mode
  32393. */
  32394. static _ExitPointerlock(): void;
  32395. /**
  32396. * Ask the browser to promote the current element to fullscreen rendering mode
  32397. * @param element defines the DOM element to promote
  32398. */
  32399. static _RequestFullscreen(element: HTMLElement): void;
  32400. /**
  32401. * Asks the browser to exit fullscreen mode
  32402. */
  32403. static _ExitFullscreen(): void;
  32404. }
  32405. }
  32406. declare module "babylonjs/Engines/engineStore" {
  32407. import { Nullable } from "babylonjs/types";
  32408. import { Engine } from "babylonjs/Engines/engine";
  32409. import { Scene } from "babylonjs/scene";
  32410. /**
  32411. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32412. * during the life time of the application.
  32413. */
  32414. export class EngineStore {
  32415. /** Gets the list of created engines */
  32416. static Instances: import("babylonjs/Engines/engine").Engine[];
  32417. /** @hidden */
  32418. static _LastCreatedScene: Nullable<Scene>;
  32419. /**
  32420. * Gets the latest created engine
  32421. */
  32422. static readonly LastCreatedEngine: Nullable<Engine>;
  32423. /**
  32424. * Gets the latest created scene
  32425. */
  32426. static readonly LastCreatedScene: Nullable<Scene>;
  32427. /**
  32428. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32429. * @ignorenaming
  32430. */
  32431. static UseFallbackTexture: boolean;
  32432. /**
  32433. * Texture content used if a texture cannot loaded
  32434. * @ignorenaming
  32435. */
  32436. static FallbackTexture: string;
  32437. }
  32438. }
  32439. declare module "babylonjs/Misc/promise" {
  32440. /**
  32441. * Helper class that provides a small promise polyfill
  32442. */
  32443. export class PromisePolyfill {
  32444. /**
  32445. * Static function used to check if the polyfill is required
  32446. * If this is the case then the function will inject the polyfill to window.Promise
  32447. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32448. */
  32449. static Apply(force?: boolean): void;
  32450. }
  32451. }
  32452. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32453. /**
  32454. * Interface for screenshot methods with describe argument called `size` as object with options
  32455. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32456. */
  32457. export interface IScreenshotSize {
  32458. /**
  32459. * number in pixels for canvas height
  32460. */
  32461. height?: number;
  32462. /**
  32463. * multiplier allowing render at a higher or lower resolution
  32464. * If value is defined then height and width will be ignored and taken from camera
  32465. */
  32466. precision?: number;
  32467. /**
  32468. * number in pixels for canvas width
  32469. */
  32470. width?: number;
  32471. }
  32472. }
  32473. declare module "babylonjs/Misc/tools" {
  32474. import { Nullable, float } from "babylonjs/types";
  32475. import { DomManagement } from "babylonjs/Misc/domManagement";
  32476. import { WebRequest } from "babylonjs/Misc/webRequest";
  32477. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32478. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32479. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32480. import { Camera } from "babylonjs/Cameras/camera";
  32481. import { Engine } from "babylonjs/Engines/engine";
  32482. interface IColor4Like {
  32483. r: float;
  32484. g: float;
  32485. b: float;
  32486. a: float;
  32487. }
  32488. /**
  32489. * Class containing a set of static utilities functions
  32490. */
  32491. export class Tools {
  32492. /**
  32493. * Gets or sets the base URL to use to load assets
  32494. */
  32495. static BaseUrl: string;
  32496. /**
  32497. * Enable/Disable Custom HTTP Request Headers globally.
  32498. * default = false
  32499. * @see CustomRequestHeaders
  32500. */
  32501. static UseCustomRequestHeaders: boolean;
  32502. /**
  32503. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32504. * i.e. when loading files, where the server/service expects an Authorization header
  32505. */
  32506. static CustomRequestHeaders: {
  32507. [key: string]: string;
  32508. };
  32509. /**
  32510. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32511. */
  32512. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32513. /**
  32514. * Default behaviour for cors in the application.
  32515. * It can be a string if the expected behavior is identical in the entire app.
  32516. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32517. */
  32518. static CorsBehavior: string | ((url: string | string[]) => string);
  32519. /**
  32520. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32521. * @ignorenaming
  32522. */
  32523. static UseFallbackTexture: boolean;
  32524. /**
  32525. * Use this object to register external classes like custom textures or material
  32526. * to allow the laoders to instantiate them
  32527. */
  32528. static RegisteredExternalClasses: {
  32529. [key: string]: Object;
  32530. };
  32531. /**
  32532. * Texture content used if a texture cannot loaded
  32533. * @ignorenaming
  32534. */
  32535. static fallbackTexture: string;
  32536. /**
  32537. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32538. * @param u defines the coordinate on X axis
  32539. * @param v defines the coordinate on Y axis
  32540. * @param width defines the width of the source data
  32541. * @param height defines the height of the source data
  32542. * @param pixels defines the source byte array
  32543. * @param color defines the output color
  32544. */
  32545. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32546. /**
  32547. * Interpolates between a and b via alpha
  32548. * @param a The lower value (returned when alpha = 0)
  32549. * @param b The upper value (returned when alpha = 1)
  32550. * @param alpha The interpolation-factor
  32551. * @return The mixed value
  32552. */
  32553. static Mix(a: number, b: number, alpha: number): number;
  32554. /**
  32555. * Tries to instantiate a new object from a given class name
  32556. * @param className defines the class name to instantiate
  32557. * @returns the new object or null if the system was not able to do the instantiation
  32558. */
  32559. static Instantiate(className: string): any;
  32560. /**
  32561. * Provides a slice function that will work even on IE
  32562. * @param data defines the array to slice
  32563. * @param start defines the start of the data (optional)
  32564. * @param end defines the end of the data (optional)
  32565. * @returns the new sliced array
  32566. */
  32567. static Slice<T>(data: T, start?: number, end?: number): T;
  32568. /**
  32569. * Polyfill for setImmediate
  32570. * @param action defines the action to execute after the current execution block
  32571. */
  32572. static SetImmediate(action: () => void): void;
  32573. /**
  32574. * Function indicating if a number is an exponent of 2
  32575. * @param value defines the value to test
  32576. * @returns true if the value is an exponent of 2
  32577. */
  32578. static IsExponentOfTwo(value: number): boolean;
  32579. private static _tmpFloatArray;
  32580. /**
  32581. * Returns the nearest 32-bit single precision float representation of a Number
  32582. * @param value A Number. If the parameter is of a different type, it will get converted
  32583. * to a number or to NaN if it cannot be converted
  32584. * @returns number
  32585. */
  32586. static FloatRound(value: number): number;
  32587. /**
  32588. * Extracts the filename from a path
  32589. * @param path defines the path to use
  32590. * @returns the filename
  32591. */
  32592. static GetFilename(path: string): string;
  32593. /**
  32594. * Extracts the "folder" part of a path (everything before the filename).
  32595. * @param uri The URI to extract the info from
  32596. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32597. * @returns The "folder" part of the path
  32598. */
  32599. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32600. /**
  32601. * Extracts text content from a DOM element hierarchy
  32602. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32603. */
  32604. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32605. /**
  32606. * Convert an angle in radians to degrees
  32607. * @param angle defines the angle to convert
  32608. * @returns the angle in degrees
  32609. */
  32610. static ToDegrees(angle: number): number;
  32611. /**
  32612. * Convert an angle in degrees to radians
  32613. * @param angle defines the angle to convert
  32614. * @returns the angle in radians
  32615. */
  32616. static ToRadians(angle: number): number;
  32617. /**
  32618. * Encode a buffer to a base64 string
  32619. * @param buffer defines the buffer to encode
  32620. * @returns the encoded string
  32621. */
  32622. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32623. /**
  32624. * Returns an array if obj is not an array
  32625. * @param obj defines the object to evaluate as an array
  32626. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32627. * @returns either obj directly if obj is an array or a new array containing obj
  32628. */
  32629. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32630. /**
  32631. * Gets the pointer prefix to use
  32632. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32633. */
  32634. static GetPointerPrefix(): string;
  32635. /**
  32636. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32637. * @param url define the url we are trying
  32638. * @param element define the dom element where to configure the cors policy
  32639. */
  32640. static SetCorsBehavior(url: string | string[], element: {
  32641. crossOrigin: string | null;
  32642. }): void;
  32643. /**
  32644. * Removes unwanted characters from an url
  32645. * @param url defines the url to clean
  32646. * @returns the cleaned url
  32647. */
  32648. static CleanUrl(url: string): string;
  32649. /**
  32650. * Gets or sets a function used to pre-process url before using them to load assets
  32651. */
  32652. static PreprocessUrl: (url: string) => string;
  32653. /**
  32654. * Loads an image as an HTMLImageElement.
  32655. * @param input url string, ArrayBuffer, or Blob to load
  32656. * @param onLoad callback called when the image successfully loads
  32657. * @param onError callback called when the image fails to load
  32658. * @param offlineProvider offline provider for caching
  32659. * @returns the HTMLImageElement of the loaded image
  32660. */
  32661. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32662. /**
  32663. * Loads a file
  32664. * @param url url string, ArrayBuffer, or Blob to load
  32665. * @param onSuccess callback called when the file successfully loads
  32666. * @param onProgress callback called while file is loading (if the server supports this mode)
  32667. * @param offlineProvider defines the offline provider for caching
  32668. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32669. * @param onError callback called when the file fails to load
  32670. * @returns a file request object
  32671. */
  32672. 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;
  32673. /**
  32674. * Loads a file from a url
  32675. * @param url the file url to load
  32676. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32677. */
  32678. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32679. /**
  32680. * Load a script (identified by an url). When the url returns, the
  32681. * content of this file is added into a new script element, attached to the DOM (body element)
  32682. * @param scriptUrl defines the url of the script to laod
  32683. * @param onSuccess defines the callback called when the script is loaded
  32684. * @param onError defines the callback to call if an error occurs
  32685. * @param scriptId defines the id of the script element
  32686. */
  32687. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32688. /**
  32689. * Load an asynchronous script (identified by an url). When the url returns, the
  32690. * content of this file is added into a new script element, attached to the DOM (body element)
  32691. * @param scriptUrl defines the url of the script to laod
  32692. * @param scriptId defines the id of the script element
  32693. * @returns a promise request object
  32694. */
  32695. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32696. /**
  32697. * Loads a file from a blob
  32698. * @param fileToLoad defines the blob to use
  32699. * @param callback defines the callback to call when data is loaded
  32700. * @param progressCallback defines the callback to call during loading process
  32701. * @returns a file request object
  32702. */
  32703. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32704. /**
  32705. * Loads a file
  32706. * @param fileToLoad defines the file to load
  32707. * @param callback defines the callback to call when data is loaded
  32708. * @param progressCallBack defines the callback to call during loading process
  32709. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32710. * @returns a file request object
  32711. */
  32712. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32713. /**
  32714. * Creates a data url from a given string content
  32715. * @param content defines the content to convert
  32716. * @returns the new data url link
  32717. */
  32718. static FileAsURL(content: string): string;
  32719. /**
  32720. * Format the given number to a specific decimal format
  32721. * @param value defines the number to format
  32722. * @param decimals defines the number of decimals to use
  32723. * @returns the formatted string
  32724. */
  32725. static Format(value: number, decimals?: number): string;
  32726. /**
  32727. * Tries to copy an object by duplicating every property
  32728. * @param source defines the source object
  32729. * @param destination defines the target object
  32730. * @param doNotCopyList defines a list of properties to avoid
  32731. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32732. */
  32733. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32734. /**
  32735. * Gets a boolean indicating if the given object has no own property
  32736. * @param obj defines the object to test
  32737. * @returns true if object has no own property
  32738. */
  32739. static IsEmpty(obj: any): boolean;
  32740. /**
  32741. * Function used to register events at window level
  32742. * @param windowElement defines the Window object to use
  32743. * @param events defines the events to register
  32744. */
  32745. static RegisterTopRootEvents(windowElement: Window, events: {
  32746. name: string;
  32747. handler: Nullable<(e: FocusEvent) => any>;
  32748. }[]): void;
  32749. /**
  32750. * Function used to unregister events from window level
  32751. * @param windowElement defines the Window object to use
  32752. * @param events defines the events to unregister
  32753. */
  32754. static UnregisterTopRootEvents(windowElement: Window, events: {
  32755. name: string;
  32756. handler: Nullable<(e: FocusEvent) => any>;
  32757. }[]): void;
  32758. /**
  32759. * @ignore
  32760. */
  32761. static _ScreenshotCanvas: HTMLCanvasElement;
  32762. /**
  32763. * Dumps the current bound framebuffer
  32764. * @param width defines the rendering width
  32765. * @param height defines the rendering height
  32766. * @param engine defines the hosting engine
  32767. * @param successCallback defines the callback triggered once the data are available
  32768. * @param mimeType defines the mime type of the result
  32769. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32770. */
  32771. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32772. /**
  32773. * Converts the canvas data to blob.
  32774. * This acts as a polyfill for browsers not supporting the to blob function.
  32775. * @param canvas Defines the canvas to extract the data from
  32776. * @param successCallback Defines the callback triggered once the data are available
  32777. * @param mimeType Defines the mime type of the result
  32778. */
  32779. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32780. /**
  32781. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32782. * @param successCallback defines the callback triggered once the data are available
  32783. * @param mimeType defines the mime type of the result
  32784. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32785. */
  32786. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32787. /**
  32788. * Downloads a blob in the browser
  32789. * @param blob defines the blob to download
  32790. * @param fileName defines the name of the downloaded file
  32791. */
  32792. static Download(blob: Blob, fileName: string): void;
  32793. /**
  32794. * Captures a screenshot of the current rendering
  32795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32796. * @param engine defines the rendering engine
  32797. * @param camera defines the source camera
  32798. * @param size This parameter can be set to a single number or to an object with the
  32799. * following (optional) properties: precision, width, height. If a single number is passed,
  32800. * it will be used for both width and height. If an object is passed, the screenshot size
  32801. * will be derived from the parameters. The precision property is a multiplier allowing
  32802. * rendering at a higher or lower resolution
  32803. * @param successCallback defines the callback receives a single parameter which contains the
  32804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32805. * src parameter of an <img> to display it
  32806. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32807. * Check your browser for supported MIME types
  32808. */
  32809. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32810. /**
  32811. * Captures a screenshot of the current rendering
  32812. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32813. * @param engine defines the rendering engine
  32814. * @param camera defines the source camera
  32815. * @param size This parameter can be set to a single number or to an object with the
  32816. * following (optional) properties: precision, width, height. If a single number is passed,
  32817. * it will be used for both width and height. If an object is passed, the screenshot size
  32818. * will be derived from the parameters. The precision property is a multiplier allowing
  32819. * rendering at a higher or lower resolution
  32820. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32821. * Check your browser for supported MIME types
  32822. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32823. * to the src parameter of an <img> to display it
  32824. */
  32825. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32826. /**
  32827. * Generates an image screenshot from the specified camera.
  32828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32829. * @param engine The engine to use for rendering
  32830. * @param camera The camera to use for rendering
  32831. * @param size This parameter can be set to a single number or to an object with the
  32832. * following (optional) properties: precision, width, height. If a single number is passed,
  32833. * it will be used for both width and height. If an object is passed, the screenshot size
  32834. * will be derived from the parameters. The precision property is a multiplier allowing
  32835. * rendering at a higher or lower resolution
  32836. * @param successCallback The callback receives a single parameter which contains the
  32837. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32838. * src parameter of an <img> to display it
  32839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32840. * Check your browser for supported MIME types
  32841. * @param samples Texture samples (default: 1)
  32842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32843. * @param fileName A name for for the downloaded file.
  32844. */
  32845. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32846. /**
  32847. * Generates an image screenshot from the specified camera.
  32848. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32849. * @param engine The engine to use for rendering
  32850. * @param camera The camera to use for rendering
  32851. * @param size This parameter can be set to a single number or to an object with the
  32852. * following (optional) properties: precision, width, height. If a single number is passed,
  32853. * it will be used for both width and height. If an object is passed, the screenshot size
  32854. * will be derived from the parameters. The precision property is a multiplier allowing
  32855. * rendering at a higher or lower resolution
  32856. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32857. * Check your browser for supported MIME types
  32858. * @param samples Texture samples (default: 1)
  32859. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32860. * @param fileName A name for for the downloaded file.
  32861. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32862. * to the src parameter of an <img> to display it
  32863. */
  32864. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32865. /**
  32866. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32867. * Be aware Math.random() could cause collisions, but:
  32868. * "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"
  32869. * @returns a pseudo random id
  32870. */
  32871. static RandomId(): string;
  32872. /**
  32873. * Test if the given uri is a base64 string
  32874. * @param uri The uri to test
  32875. * @return True if the uri is a base64 string or false otherwise
  32876. */
  32877. static IsBase64(uri: string): boolean;
  32878. /**
  32879. * Decode the given base64 uri.
  32880. * @param uri The uri to decode
  32881. * @return The decoded base64 data.
  32882. */
  32883. static DecodeBase64(uri: string): ArrayBuffer;
  32884. /**
  32885. * Gets the absolute url.
  32886. * @param url the input url
  32887. * @return the absolute url
  32888. */
  32889. static GetAbsoluteUrl(url: string): string;
  32890. /**
  32891. * No log
  32892. */
  32893. static readonly NoneLogLevel: number;
  32894. /**
  32895. * Only message logs
  32896. */
  32897. static readonly MessageLogLevel: number;
  32898. /**
  32899. * Only warning logs
  32900. */
  32901. static readonly WarningLogLevel: number;
  32902. /**
  32903. * Only error logs
  32904. */
  32905. static readonly ErrorLogLevel: number;
  32906. /**
  32907. * All logs
  32908. */
  32909. static readonly AllLogLevel: number;
  32910. /**
  32911. * Gets a value indicating the number of loading errors
  32912. * @ignorenaming
  32913. */
  32914. static readonly errorsCount: number;
  32915. /**
  32916. * Callback called when a new log is added
  32917. */
  32918. static OnNewCacheEntry: (entry: string) => void;
  32919. /**
  32920. * Log a message to the console
  32921. * @param message defines the message to log
  32922. */
  32923. static Log(message: string): void;
  32924. /**
  32925. * Write a warning message to the console
  32926. * @param message defines the message to log
  32927. */
  32928. static Warn(message: string): void;
  32929. /**
  32930. * Write an error message to the console
  32931. * @param message defines the message to log
  32932. */
  32933. static Error(message: string): void;
  32934. /**
  32935. * Gets current log cache (list of logs)
  32936. */
  32937. static readonly LogCache: string;
  32938. /**
  32939. * Clears the log cache
  32940. */
  32941. static ClearLogCache(): void;
  32942. /**
  32943. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32944. */
  32945. static LogLevels: number;
  32946. /**
  32947. * Checks if the window object exists
  32948. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32949. */
  32950. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32951. /**
  32952. * No performance log
  32953. */
  32954. static readonly PerformanceNoneLogLevel: number;
  32955. /**
  32956. * Use user marks to log performance
  32957. */
  32958. static readonly PerformanceUserMarkLogLevel: number;
  32959. /**
  32960. * Log performance to the console
  32961. */
  32962. static readonly PerformanceConsoleLogLevel: number;
  32963. private static _performance;
  32964. /**
  32965. * Sets the current performance log level
  32966. */
  32967. static PerformanceLogLevel: number;
  32968. private static _StartPerformanceCounterDisabled;
  32969. private static _EndPerformanceCounterDisabled;
  32970. private static _StartUserMark;
  32971. private static _EndUserMark;
  32972. private static _StartPerformanceConsole;
  32973. private static _EndPerformanceConsole;
  32974. /**
  32975. * Starts a performance counter
  32976. */
  32977. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32978. /**
  32979. * Ends a specific performance coutner
  32980. */
  32981. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32982. /**
  32983. * Gets either window.performance.now() if supported or Date.now() else
  32984. */
  32985. static readonly Now: number;
  32986. /**
  32987. * This method will return the name of the class used to create the instance of the given object.
  32988. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32989. * @param object the object to get the class name from
  32990. * @param isType defines if the object is actually a type
  32991. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32992. */
  32993. static GetClassName(object: any, isType?: boolean): string;
  32994. /**
  32995. * Gets the first element of an array satisfying a given predicate
  32996. * @param array defines the array to browse
  32997. * @param predicate defines the predicate to use
  32998. * @returns null if not found or the element
  32999. */
  33000. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33001. /**
  33002. * This method will return the name of the full name of the class, including its owning module (if any).
  33003. * 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).
  33004. * @param object the object to get the class name from
  33005. * @param isType defines if the object is actually a type
  33006. * @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.
  33007. * @ignorenaming
  33008. */
  33009. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33010. /**
  33011. * Returns a promise that resolves after the given amount of time.
  33012. * @param delay Number of milliseconds to delay
  33013. * @returns Promise that resolves after the given amount of time
  33014. */
  33015. static DelayAsync(delay: number): Promise<void>;
  33016. }
  33017. /**
  33018. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33019. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33020. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33021. * @param name The name of the class, case should be preserved
  33022. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33023. */
  33024. export function className(name: string, module?: string): (target: Object) => void;
  33025. /**
  33026. * An implementation of a loop for asynchronous functions.
  33027. */
  33028. export class AsyncLoop {
  33029. /**
  33030. * Defines the number of iterations for the loop
  33031. */
  33032. iterations: number;
  33033. /**
  33034. * Defines the current index of the loop.
  33035. */
  33036. index: number;
  33037. private _done;
  33038. private _fn;
  33039. private _successCallback;
  33040. /**
  33041. * Constructor.
  33042. * @param iterations the number of iterations.
  33043. * @param func the function to run each iteration
  33044. * @param successCallback the callback that will be called upon succesful execution
  33045. * @param offset starting offset.
  33046. */
  33047. constructor(
  33048. /**
  33049. * Defines the number of iterations for the loop
  33050. */
  33051. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33052. /**
  33053. * Execute the next iteration. Must be called after the last iteration was finished.
  33054. */
  33055. executeNext(): void;
  33056. /**
  33057. * Break the loop and run the success callback.
  33058. */
  33059. breakLoop(): void;
  33060. /**
  33061. * Create and run an async loop.
  33062. * @param iterations the number of iterations.
  33063. * @param fn the function to run each iteration
  33064. * @param successCallback the callback that will be called upon succesful execution
  33065. * @param offset starting offset.
  33066. * @returns the created async loop object
  33067. */
  33068. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33069. /**
  33070. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33071. * @param iterations total number of iterations
  33072. * @param syncedIterations number of synchronous iterations in each async iteration.
  33073. * @param fn the function to call each iteration.
  33074. * @param callback a success call back that will be called when iterating stops.
  33075. * @param breakFunction a break condition (optional)
  33076. * @param timeout timeout settings for the setTimeout function. default - 0.
  33077. * @returns the created async loop object
  33078. */
  33079. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33080. }
  33081. }
  33082. declare module "babylonjs/Collisions/collisionCoordinator" {
  33083. import { Nullable } from "babylonjs/types";
  33084. import { Scene } from "babylonjs/scene";
  33085. import { Vector3 } from "babylonjs/Maths/math.vector";
  33086. import { Collider } from "babylonjs/Collisions/collider";
  33087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33088. /** @hidden */
  33089. export interface ICollisionCoordinator {
  33090. createCollider(): Collider;
  33091. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33092. init(scene: Scene): void;
  33093. }
  33094. /** @hidden */
  33095. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33096. private _scene;
  33097. private _scaledPosition;
  33098. private _scaledVelocity;
  33099. private _finalPosition;
  33100. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33101. createCollider(): Collider;
  33102. init(scene: Scene): void;
  33103. private _collideWithWorld;
  33104. }
  33105. }
  33106. declare module "babylonjs/Inputs/scene.inputManager" {
  33107. import { Nullable } from "babylonjs/types";
  33108. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33109. import { Vector2 } from "babylonjs/Maths/math.vector";
  33110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33111. import { Scene } from "babylonjs/scene";
  33112. /**
  33113. * Class used to manage all inputs for the scene.
  33114. */
  33115. export class InputManager {
  33116. /** The distance in pixel that you have to move to prevent some events */
  33117. static DragMovementThreshold: number;
  33118. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33119. static LongPressDelay: number;
  33120. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33121. static DoubleClickDelay: number;
  33122. /** If you need to check double click without raising a single click at first click, enable this flag */
  33123. static ExclusiveDoubleClickMode: boolean;
  33124. private _wheelEventName;
  33125. private _onPointerMove;
  33126. private _onPointerDown;
  33127. private _onPointerUp;
  33128. private _initClickEvent;
  33129. private _initActionManager;
  33130. private _delayedSimpleClick;
  33131. private _delayedSimpleClickTimeout;
  33132. private _previousDelayedSimpleClickTimeout;
  33133. private _meshPickProceed;
  33134. private _previousButtonPressed;
  33135. private _currentPickResult;
  33136. private _previousPickResult;
  33137. private _totalPointersPressed;
  33138. private _doubleClickOccured;
  33139. private _pointerOverMesh;
  33140. private _pickedDownMesh;
  33141. private _pickedUpMesh;
  33142. private _pointerX;
  33143. private _pointerY;
  33144. private _unTranslatedPointerX;
  33145. private _unTranslatedPointerY;
  33146. private _startingPointerPosition;
  33147. private _previousStartingPointerPosition;
  33148. private _startingPointerTime;
  33149. private _previousStartingPointerTime;
  33150. private _pointerCaptures;
  33151. private _onKeyDown;
  33152. private _onKeyUp;
  33153. private _onCanvasFocusObserver;
  33154. private _onCanvasBlurObserver;
  33155. private _scene;
  33156. /**
  33157. * Creates a new InputManager
  33158. * @param scene defines the hosting scene
  33159. */
  33160. constructor(scene: Scene);
  33161. /**
  33162. * Gets the mesh that is currently under the pointer
  33163. */
  33164. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33165. /**
  33166. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33167. */
  33168. readonly unTranslatedPointer: Vector2;
  33169. /**
  33170. * Gets or sets the current on-screen X position of the pointer
  33171. */
  33172. pointerX: number;
  33173. /**
  33174. * Gets or sets the current on-screen Y position of the pointer
  33175. */
  33176. pointerY: number;
  33177. private _updatePointerPosition;
  33178. private _processPointerMove;
  33179. private _setRayOnPointerInfo;
  33180. private _checkPrePointerObservable;
  33181. /**
  33182. * Use this method to simulate a pointer move on a mesh
  33183. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33184. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33185. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33186. */
  33187. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33188. /**
  33189. * Use this method to simulate a pointer down on a mesh
  33190. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33191. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33192. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33193. */
  33194. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33195. private _processPointerDown;
  33196. /** @hidden */
  33197. _isPointerSwiping(): boolean;
  33198. /**
  33199. * Use this method to simulate a pointer up on a mesh
  33200. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33201. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33202. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33203. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33204. */
  33205. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33206. private _processPointerUp;
  33207. /**
  33208. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33209. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33210. * @returns true if the pointer was captured
  33211. */
  33212. isPointerCaptured(pointerId?: number): boolean;
  33213. /**
  33214. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33215. * @param attachUp defines if you want to attach events to pointerup
  33216. * @param attachDown defines if you want to attach events to pointerdown
  33217. * @param attachMove defines if you want to attach events to pointermove
  33218. */
  33219. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33220. /**
  33221. * Detaches all event handlers
  33222. */
  33223. detachControl(): void;
  33224. /**
  33225. * Force the value of meshUnderPointer
  33226. * @param mesh defines the mesh to use
  33227. */
  33228. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33229. /**
  33230. * Gets the mesh under the pointer
  33231. * @returns a Mesh or null if no mesh is under the pointer
  33232. */
  33233. getPointerOverMesh(): Nullable<AbstractMesh>;
  33234. }
  33235. }
  33236. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33237. /**
  33238. * Helper class used to generate session unique ID
  33239. */
  33240. export class UniqueIdGenerator {
  33241. private static _UniqueIdCounter;
  33242. /**
  33243. * Gets an unique (relatively to the current scene) Id
  33244. */
  33245. static readonly UniqueId: number;
  33246. }
  33247. }
  33248. declare module "babylonjs/Animations/animationGroup" {
  33249. import { Animatable } from "babylonjs/Animations/animatable";
  33250. import { Animation } from "babylonjs/Animations/animation";
  33251. import { Scene, IDisposable } from "babylonjs/scene";
  33252. import { Observable } from "babylonjs/Misc/observable";
  33253. import { Nullable } from "babylonjs/types";
  33254. import "babylonjs/Animations/animatable";
  33255. /**
  33256. * This class defines the direct association between an animation and a target
  33257. */
  33258. export class TargetedAnimation {
  33259. /**
  33260. * Animation to perform
  33261. */
  33262. animation: Animation;
  33263. /**
  33264. * Target to animate
  33265. */
  33266. target: any;
  33267. /**
  33268. * Serialize the object
  33269. * @returns the JSON object representing the current entity
  33270. */
  33271. serialize(): any;
  33272. }
  33273. /**
  33274. * Use this class to create coordinated animations on multiple targets
  33275. */
  33276. export class AnimationGroup implements IDisposable {
  33277. /** The name of the animation group */
  33278. name: string;
  33279. private _scene;
  33280. private _targetedAnimations;
  33281. private _animatables;
  33282. private _from;
  33283. private _to;
  33284. private _isStarted;
  33285. private _isPaused;
  33286. private _speedRatio;
  33287. private _loopAnimation;
  33288. /**
  33289. * Gets or sets the unique id of the node
  33290. */
  33291. uniqueId: number;
  33292. /**
  33293. * This observable will notify when one animation have ended
  33294. */
  33295. onAnimationEndObservable: Observable<TargetedAnimation>;
  33296. /**
  33297. * Observer raised when one animation loops
  33298. */
  33299. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33300. /**
  33301. * This observable will notify when all animations have ended.
  33302. */
  33303. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33304. /**
  33305. * This observable will notify when all animations have paused.
  33306. */
  33307. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33308. /**
  33309. * This observable will notify when all animations are playing.
  33310. */
  33311. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33312. /**
  33313. * Gets the first frame
  33314. */
  33315. readonly from: number;
  33316. /**
  33317. * Gets the last frame
  33318. */
  33319. readonly to: number;
  33320. /**
  33321. * Define if the animations are started
  33322. */
  33323. readonly isStarted: boolean;
  33324. /**
  33325. * Gets a value indicating that the current group is playing
  33326. */
  33327. readonly isPlaying: boolean;
  33328. /**
  33329. * Gets or sets the speed ratio to use for all animations
  33330. */
  33331. /**
  33332. * Gets or sets the speed ratio to use for all animations
  33333. */
  33334. speedRatio: number;
  33335. /**
  33336. * Gets or sets if all animations should loop or not
  33337. */
  33338. loopAnimation: boolean;
  33339. /**
  33340. * Gets the targeted animations for this animation group
  33341. */
  33342. readonly targetedAnimations: Array<TargetedAnimation>;
  33343. /**
  33344. * returning the list of animatables controlled by this animation group.
  33345. */
  33346. readonly animatables: Array<Animatable>;
  33347. /**
  33348. * Instantiates a new Animation Group.
  33349. * This helps managing several animations at once.
  33350. * @see http://doc.babylonjs.com/how_to/group
  33351. * @param name Defines the name of the group
  33352. * @param scene Defines the scene the group belongs to
  33353. */
  33354. constructor(
  33355. /** The name of the animation group */
  33356. name: string, scene?: Nullable<Scene>);
  33357. /**
  33358. * Add an animation (with its target) in the group
  33359. * @param animation defines the animation we want to add
  33360. * @param target defines the target of the animation
  33361. * @returns the TargetedAnimation object
  33362. */
  33363. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33364. /**
  33365. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33366. * It can add constant keys at begin or end
  33367. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33368. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33369. * @returns the animation group
  33370. */
  33371. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33372. /**
  33373. * Start all animations on given targets
  33374. * @param loop defines if animations must loop
  33375. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33376. * @param from defines the from key (optional)
  33377. * @param to defines the to key (optional)
  33378. * @returns the current animation group
  33379. */
  33380. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33381. /**
  33382. * Pause all animations
  33383. * @returns the animation group
  33384. */
  33385. pause(): AnimationGroup;
  33386. /**
  33387. * Play all animations to initial state
  33388. * This function will start() the animations if they were not started or will restart() them if they were paused
  33389. * @param loop defines if animations must loop
  33390. * @returns the animation group
  33391. */
  33392. play(loop?: boolean): AnimationGroup;
  33393. /**
  33394. * Reset all animations to initial state
  33395. * @returns the animation group
  33396. */
  33397. reset(): AnimationGroup;
  33398. /**
  33399. * Restart animations from key 0
  33400. * @returns the animation group
  33401. */
  33402. restart(): AnimationGroup;
  33403. /**
  33404. * Stop all animations
  33405. * @returns the animation group
  33406. */
  33407. stop(): AnimationGroup;
  33408. /**
  33409. * Set animation weight for all animatables
  33410. * @param weight defines the weight to use
  33411. * @return the animationGroup
  33412. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33413. */
  33414. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33415. /**
  33416. * Synchronize and normalize all animatables with a source animatable
  33417. * @param root defines the root animatable to synchronize with
  33418. * @return the animationGroup
  33419. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33420. */
  33421. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33422. /**
  33423. * Goes to a specific frame in this animation group
  33424. * @param frame the frame number to go to
  33425. * @return the animationGroup
  33426. */
  33427. goToFrame(frame: number): AnimationGroup;
  33428. /**
  33429. * Dispose all associated resources
  33430. */
  33431. dispose(): void;
  33432. private _checkAnimationGroupEnded;
  33433. /**
  33434. * Clone the current animation group and returns a copy
  33435. * @param newName defines the name of the new group
  33436. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33437. * @returns the new aniamtion group
  33438. */
  33439. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33440. /**
  33441. * Serializes the animationGroup to an object
  33442. * @returns Serialized object
  33443. */
  33444. serialize(): any;
  33445. /**
  33446. * Returns a new AnimationGroup object parsed from the source provided.
  33447. * @param parsedAnimationGroup defines the source
  33448. * @param scene defines the scene that will receive the animationGroup
  33449. * @returns a new AnimationGroup
  33450. */
  33451. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33452. /**
  33453. * Returns the string "AnimationGroup"
  33454. * @returns "AnimationGroup"
  33455. */
  33456. getClassName(): string;
  33457. /**
  33458. * Creates a detailled string about the object
  33459. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33460. * @returns a string representing the object
  33461. */
  33462. toString(fullDetails?: boolean): string;
  33463. }
  33464. }
  33465. declare module "babylonjs/scene" {
  33466. import { Nullable } from "babylonjs/types";
  33467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33468. import { Observable } from "babylonjs/Misc/observable";
  33469. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33470. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33471. import { Geometry } from "babylonjs/Meshes/geometry";
  33472. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33473. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33475. import { Mesh } from "babylonjs/Meshes/mesh";
  33476. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33477. import { Bone } from "babylonjs/Bones/bone";
  33478. import { Skeleton } from "babylonjs/Bones/skeleton";
  33479. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33480. import { Camera } from "babylonjs/Cameras/camera";
  33481. import { AbstractScene } from "babylonjs/abstractScene";
  33482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33483. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33484. import { Material } from "babylonjs/Materials/material";
  33485. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33486. import { Effect } from "babylonjs/Materials/effect";
  33487. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33488. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33489. import { Light } from "babylonjs/Lights/light";
  33490. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33491. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33492. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33493. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33495. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33496. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33497. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33498. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33499. import { Engine } from "babylonjs/Engines/engine";
  33500. import { Node } from "babylonjs/node";
  33501. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33502. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33503. import { WebRequest } from "babylonjs/Misc/webRequest";
  33504. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33505. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33506. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33507. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33508. import { Plane } from "babylonjs/Maths/math.plane";
  33509. import { Ray } from "babylonjs/Culling/ray";
  33510. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33511. import { Animation } from "babylonjs/Animations/animation";
  33512. import { Animatable } from "babylonjs/Animations/animatable";
  33513. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33514. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33515. import { Collider } from "babylonjs/Collisions/collider";
  33516. /**
  33517. * Define an interface for all classes that will hold resources
  33518. */
  33519. export interface IDisposable {
  33520. /**
  33521. * Releases all held resources
  33522. */
  33523. dispose(): void;
  33524. }
  33525. /** Interface defining initialization parameters for Scene class */
  33526. export interface SceneOptions {
  33527. /**
  33528. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33529. * It will improve performance when the number of geometries becomes important.
  33530. */
  33531. useGeometryUniqueIdsMap?: boolean;
  33532. /**
  33533. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33534. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33535. */
  33536. useMaterialMeshMap?: boolean;
  33537. /**
  33538. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33539. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33540. */
  33541. useClonedMeshhMap?: boolean;
  33542. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33543. virtual?: boolean;
  33544. }
  33545. /**
  33546. * Represents a scene to be rendered by the engine.
  33547. * @see http://doc.babylonjs.com/features/scene
  33548. */
  33549. export class Scene extends AbstractScene implements IAnimatable {
  33550. /** The fog is deactivated */
  33551. static readonly FOGMODE_NONE: number;
  33552. /** The fog density is following an exponential function */
  33553. static readonly FOGMODE_EXP: number;
  33554. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33555. static readonly FOGMODE_EXP2: number;
  33556. /** The fog density is following a linear function. */
  33557. static readonly FOGMODE_LINEAR: number;
  33558. /**
  33559. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33561. */
  33562. static MinDeltaTime: number;
  33563. /**
  33564. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33566. */
  33567. static MaxDeltaTime: number;
  33568. /**
  33569. * Factory used to create the default material.
  33570. * @param name The name of the material to create
  33571. * @param scene The scene to create the material for
  33572. * @returns The default material
  33573. */
  33574. static DefaultMaterialFactory(scene: Scene): Material;
  33575. /**
  33576. * Factory used to create the a collision coordinator.
  33577. * @returns The collision coordinator
  33578. */
  33579. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33580. /** @hidden */
  33581. _inputManager: InputManager;
  33582. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33583. cameraToUseForPointers: Nullable<Camera>;
  33584. /** @hidden */
  33585. readonly _isScene: boolean;
  33586. /**
  33587. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33588. */
  33589. autoClear: boolean;
  33590. /**
  33591. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33592. */
  33593. autoClearDepthAndStencil: boolean;
  33594. /**
  33595. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33596. */
  33597. clearColor: Color4;
  33598. /**
  33599. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33600. */
  33601. ambientColor: Color3;
  33602. /**
  33603. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33604. * It should only be one of the following (if not the default embedded one):
  33605. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33606. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33607. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33608. * The material properties need to be setup according to the type of texture in use.
  33609. */
  33610. environmentBRDFTexture: BaseTexture;
  33611. /** @hidden */
  33612. protected _environmentTexture: Nullable<BaseTexture>;
  33613. /**
  33614. * Texture used in all pbr material as the reflection texture.
  33615. * As in the majority of the scene they are the same (exception for multi room and so on),
  33616. * this is easier to reference from here than from all the materials.
  33617. */
  33618. /**
  33619. * Texture used in all pbr material as the reflection texture.
  33620. * As in the majority of the scene they are the same (exception for multi room and so on),
  33621. * this is easier to set here than in all the materials.
  33622. */
  33623. environmentTexture: Nullable<BaseTexture>;
  33624. /** @hidden */
  33625. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33626. /**
  33627. * Default image processing configuration used either in the rendering
  33628. * Forward main pass or through the imageProcessingPostProcess if present.
  33629. * As in the majority of the scene they are the same (exception for multi camera),
  33630. * this is easier to reference from here than from all the materials and post process.
  33631. *
  33632. * No setter as we it is a shared configuration, you can set the values instead.
  33633. */
  33634. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33635. private _forceWireframe;
  33636. /**
  33637. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33638. */
  33639. forceWireframe: boolean;
  33640. private _forcePointsCloud;
  33641. /**
  33642. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33643. */
  33644. forcePointsCloud: boolean;
  33645. /**
  33646. * Gets or sets the active clipplane 1
  33647. */
  33648. clipPlane: Nullable<Plane>;
  33649. /**
  33650. * Gets or sets the active clipplane 2
  33651. */
  33652. clipPlane2: Nullable<Plane>;
  33653. /**
  33654. * Gets or sets the active clipplane 3
  33655. */
  33656. clipPlane3: Nullable<Plane>;
  33657. /**
  33658. * Gets or sets the active clipplane 4
  33659. */
  33660. clipPlane4: Nullable<Plane>;
  33661. /**
  33662. * Gets or sets a boolean indicating if animations are enabled
  33663. */
  33664. animationsEnabled: boolean;
  33665. private _animationPropertiesOverride;
  33666. /**
  33667. * Gets or sets the animation properties override
  33668. */
  33669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33670. /**
  33671. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33672. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33673. */
  33674. useConstantAnimationDeltaTime: boolean;
  33675. /**
  33676. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33677. * Please note that it requires to run a ray cast through the scene on every frame
  33678. */
  33679. constantlyUpdateMeshUnderPointer: boolean;
  33680. /**
  33681. * Defines the HTML cursor to use when hovering over interactive elements
  33682. */
  33683. hoverCursor: string;
  33684. /**
  33685. * Defines the HTML default cursor to use (empty by default)
  33686. */
  33687. defaultCursor: string;
  33688. /**
  33689. * This is used to call preventDefault() on pointer down
  33690. * in order to block unwanted artifacts like system double clicks
  33691. */
  33692. preventDefaultOnPointerDown: boolean;
  33693. /**
  33694. * This is used to call preventDefault() on pointer up
  33695. * in order to block unwanted artifacts like system double clicks
  33696. */
  33697. preventDefaultOnPointerUp: boolean;
  33698. /**
  33699. * Gets or sets user defined metadata
  33700. */
  33701. metadata: any;
  33702. /**
  33703. * For internal use only. Please do not use.
  33704. */
  33705. reservedDataStore: any;
  33706. /**
  33707. * Gets the name of the plugin used to load this scene (null by default)
  33708. */
  33709. loadingPluginName: string;
  33710. /**
  33711. * Use this array to add regular expressions used to disable offline support for specific urls
  33712. */
  33713. disableOfflineSupportExceptionRules: RegExp[];
  33714. /**
  33715. * An event triggered when the scene is disposed.
  33716. */
  33717. onDisposeObservable: Observable<Scene>;
  33718. private _onDisposeObserver;
  33719. /** Sets a function to be executed when this scene is disposed. */
  33720. onDispose: () => void;
  33721. /**
  33722. * An event triggered before rendering the scene (right after animations and physics)
  33723. */
  33724. onBeforeRenderObservable: Observable<Scene>;
  33725. private _onBeforeRenderObserver;
  33726. /** Sets a function to be executed before rendering this scene */
  33727. beforeRender: Nullable<() => void>;
  33728. /**
  33729. * An event triggered after rendering the scene
  33730. */
  33731. onAfterRenderObservable: Observable<Scene>;
  33732. /**
  33733. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33734. */
  33735. onAfterRenderCameraObservable: Observable<Camera>;
  33736. private _onAfterRenderObserver;
  33737. /** Sets a function to be executed after rendering this scene */
  33738. afterRender: Nullable<() => void>;
  33739. /**
  33740. * An event triggered before animating the scene
  33741. */
  33742. onBeforeAnimationsObservable: Observable<Scene>;
  33743. /**
  33744. * An event triggered after animations processing
  33745. */
  33746. onAfterAnimationsObservable: Observable<Scene>;
  33747. /**
  33748. * An event triggered before draw calls are ready to be sent
  33749. */
  33750. onBeforeDrawPhaseObservable: Observable<Scene>;
  33751. /**
  33752. * An event triggered after draw calls have been sent
  33753. */
  33754. onAfterDrawPhaseObservable: Observable<Scene>;
  33755. /**
  33756. * An event triggered when the scene is ready
  33757. */
  33758. onReadyObservable: Observable<Scene>;
  33759. /**
  33760. * An event triggered before rendering a camera
  33761. */
  33762. onBeforeCameraRenderObservable: Observable<Camera>;
  33763. private _onBeforeCameraRenderObserver;
  33764. /** Sets a function to be executed before rendering a camera*/
  33765. beforeCameraRender: () => void;
  33766. /**
  33767. * An event triggered after rendering a camera
  33768. */
  33769. onAfterCameraRenderObservable: Observable<Camera>;
  33770. private _onAfterCameraRenderObserver;
  33771. /** Sets a function to be executed after rendering a camera*/
  33772. afterCameraRender: () => void;
  33773. /**
  33774. * An event triggered when active meshes evaluation is about to start
  33775. */
  33776. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33777. /**
  33778. * An event triggered when active meshes evaluation is done
  33779. */
  33780. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33781. /**
  33782. * An event triggered when particles rendering is about to start
  33783. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33784. */
  33785. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33786. /**
  33787. * An event triggered when particles rendering is done
  33788. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33789. */
  33790. onAfterParticlesRenderingObservable: Observable<Scene>;
  33791. /**
  33792. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33793. */
  33794. onDataLoadedObservable: Observable<Scene>;
  33795. /**
  33796. * An event triggered when a camera is created
  33797. */
  33798. onNewCameraAddedObservable: Observable<Camera>;
  33799. /**
  33800. * An event triggered when a camera is removed
  33801. */
  33802. onCameraRemovedObservable: Observable<Camera>;
  33803. /**
  33804. * An event triggered when a light is created
  33805. */
  33806. onNewLightAddedObservable: Observable<Light>;
  33807. /**
  33808. * An event triggered when a light is removed
  33809. */
  33810. onLightRemovedObservable: Observable<Light>;
  33811. /**
  33812. * An event triggered when a geometry is created
  33813. */
  33814. onNewGeometryAddedObservable: Observable<Geometry>;
  33815. /**
  33816. * An event triggered when a geometry is removed
  33817. */
  33818. onGeometryRemovedObservable: Observable<Geometry>;
  33819. /**
  33820. * An event triggered when a transform node is created
  33821. */
  33822. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33823. /**
  33824. * An event triggered when a transform node is removed
  33825. */
  33826. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33827. /**
  33828. * An event triggered when a mesh is created
  33829. */
  33830. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33831. /**
  33832. * An event triggered when a mesh is removed
  33833. */
  33834. onMeshRemovedObservable: Observable<AbstractMesh>;
  33835. /**
  33836. * An event triggered when a skeleton is created
  33837. */
  33838. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33839. /**
  33840. * An event triggered when a skeleton is removed
  33841. */
  33842. onSkeletonRemovedObservable: Observable<Skeleton>;
  33843. /**
  33844. * An event triggered when a material is created
  33845. */
  33846. onNewMaterialAddedObservable: Observable<Material>;
  33847. /**
  33848. * An event triggered when a material is removed
  33849. */
  33850. onMaterialRemovedObservable: Observable<Material>;
  33851. /**
  33852. * An event triggered when a texture is created
  33853. */
  33854. onNewTextureAddedObservable: Observable<BaseTexture>;
  33855. /**
  33856. * An event triggered when a texture is removed
  33857. */
  33858. onTextureRemovedObservable: Observable<BaseTexture>;
  33859. /**
  33860. * An event triggered when render targets are about to be rendered
  33861. * Can happen multiple times per frame.
  33862. */
  33863. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33864. /**
  33865. * An event triggered when render targets were rendered.
  33866. * Can happen multiple times per frame.
  33867. */
  33868. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33869. /**
  33870. * An event triggered before calculating deterministic simulation step
  33871. */
  33872. onBeforeStepObservable: Observable<Scene>;
  33873. /**
  33874. * An event triggered after calculating deterministic simulation step
  33875. */
  33876. onAfterStepObservable: Observable<Scene>;
  33877. /**
  33878. * An event triggered when the activeCamera property is updated
  33879. */
  33880. onActiveCameraChanged: Observable<Scene>;
  33881. /**
  33882. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33883. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33884. * 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)
  33885. */
  33886. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33887. /**
  33888. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33889. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33890. * 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)
  33891. */
  33892. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33893. /**
  33894. * This Observable will when a mesh has been imported into the scene.
  33895. */
  33896. onMeshImportedObservable: Observable<AbstractMesh>;
  33897. /**
  33898. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33899. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33900. */
  33901. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33902. /** @hidden */
  33903. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33904. /**
  33905. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33906. */
  33907. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33908. /**
  33909. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33910. */
  33911. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33912. /**
  33913. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33914. */
  33915. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33916. /** Callback called when a pointer move is detected */
  33917. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33918. /** Callback called when a pointer down is detected */
  33919. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33920. /** Callback called when a pointer up is detected */
  33921. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33922. /** Callback called when a pointer pick is detected */
  33923. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33924. /**
  33925. * 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).
  33926. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33927. */
  33928. onPrePointerObservable: Observable<PointerInfoPre>;
  33929. /**
  33930. * Observable event triggered each time an input event is received from the rendering canvas
  33931. */
  33932. onPointerObservable: Observable<PointerInfo>;
  33933. /**
  33934. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33935. */
  33936. readonly unTranslatedPointer: Vector2;
  33937. /**
  33938. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33939. */
  33940. static DragMovementThreshold: number;
  33941. /**
  33942. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33943. */
  33944. static LongPressDelay: number;
  33945. /**
  33946. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33947. */
  33948. static DoubleClickDelay: number;
  33949. /** If you need to check double click without raising a single click at first click, enable this flag */
  33950. static ExclusiveDoubleClickMode: boolean;
  33951. /** @hidden */
  33952. _mirroredCameraPosition: Nullable<Vector3>;
  33953. /**
  33954. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33955. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33956. */
  33957. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33958. /**
  33959. * Observable event triggered each time an keyboard event is received from the hosting window
  33960. */
  33961. onKeyboardObservable: Observable<KeyboardInfo>;
  33962. private _useRightHandedSystem;
  33963. /**
  33964. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33965. */
  33966. useRightHandedSystem: boolean;
  33967. private _timeAccumulator;
  33968. private _currentStepId;
  33969. private _currentInternalStep;
  33970. /**
  33971. * Sets the step Id used by deterministic lock step
  33972. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33973. * @param newStepId defines the step Id
  33974. */
  33975. setStepId(newStepId: number): void;
  33976. /**
  33977. * Gets the step Id used by deterministic lock step
  33978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33979. * @returns the step Id
  33980. */
  33981. getStepId(): number;
  33982. /**
  33983. * Gets the internal step used by deterministic lock step
  33984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33985. * @returns the internal step
  33986. */
  33987. getInternalStep(): number;
  33988. private _fogEnabled;
  33989. /**
  33990. * Gets or sets a boolean indicating if fog is enabled on this scene
  33991. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33992. * (Default is true)
  33993. */
  33994. fogEnabled: boolean;
  33995. private _fogMode;
  33996. /**
  33997. * Gets or sets the fog mode to use
  33998. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33999. * | mode | value |
  34000. * | --- | --- |
  34001. * | FOGMODE_NONE | 0 |
  34002. * | FOGMODE_EXP | 1 |
  34003. * | FOGMODE_EXP2 | 2 |
  34004. * | FOGMODE_LINEAR | 3 |
  34005. */
  34006. fogMode: number;
  34007. /**
  34008. * Gets or sets the fog color to use
  34009. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34010. * (Default is Color3(0.2, 0.2, 0.3))
  34011. */
  34012. fogColor: Color3;
  34013. /**
  34014. * Gets or sets the fog density to use
  34015. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34016. * (Default is 0.1)
  34017. */
  34018. fogDensity: number;
  34019. /**
  34020. * Gets or sets the fog start distance to use
  34021. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34022. * (Default is 0)
  34023. */
  34024. fogStart: number;
  34025. /**
  34026. * Gets or sets the fog end distance to use
  34027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34028. * (Default is 1000)
  34029. */
  34030. fogEnd: number;
  34031. private _shadowsEnabled;
  34032. /**
  34033. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34034. */
  34035. shadowsEnabled: boolean;
  34036. private _lightsEnabled;
  34037. /**
  34038. * Gets or sets a boolean indicating if lights are enabled on this scene
  34039. */
  34040. lightsEnabled: boolean;
  34041. /** All of the active cameras added to this scene. */
  34042. activeCameras: Camera[];
  34043. /** @hidden */
  34044. _activeCamera: Nullable<Camera>;
  34045. /** Gets or sets the current active camera */
  34046. activeCamera: Nullable<Camera>;
  34047. private _defaultMaterial;
  34048. /** The default material used on meshes when no material is affected */
  34049. /** The default material used on meshes when no material is affected */
  34050. defaultMaterial: Material;
  34051. private _texturesEnabled;
  34052. /**
  34053. * Gets or sets a boolean indicating if textures are enabled on this scene
  34054. */
  34055. texturesEnabled: boolean;
  34056. /**
  34057. * Gets or sets a boolean indicating if particles are enabled on this scene
  34058. */
  34059. particlesEnabled: boolean;
  34060. /**
  34061. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34062. */
  34063. spritesEnabled: boolean;
  34064. private _skeletonsEnabled;
  34065. /**
  34066. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34067. */
  34068. skeletonsEnabled: boolean;
  34069. /**
  34070. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34071. */
  34072. lensFlaresEnabled: boolean;
  34073. /**
  34074. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34076. */
  34077. collisionsEnabled: boolean;
  34078. private _collisionCoordinator;
  34079. /** @hidden */
  34080. readonly collisionCoordinator: ICollisionCoordinator;
  34081. /**
  34082. * Defines the gravity applied to this scene (used only for collisions)
  34083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34084. */
  34085. gravity: Vector3;
  34086. /**
  34087. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34088. */
  34089. postProcessesEnabled: boolean;
  34090. /**
  34091. * The list of postprocesses added to the scene
  34092. */
  34093. postProcesses: PostProcess[];
  34094. /**
  34095. * Gets the current postprocess manager
  34096. */
  34097. postProcessManager: PostProcessManager;
  34098. /**
  34099. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34100. */
  34101. renderTargetsEnabled: boolean;
  34102. /**
  34103. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34104. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34105. */
  34106. dumpNextRenderTargets: boolean;
  34107. /**
  34108. * The list of user defined render targets added to the scene
  34109. */
  34110. customRenderTargets: RenderTargetTexture[];
  34111. /**
  34112. * Defines if texture loading must be delayed
  34113. * If true, textures will only be loaded when they need to be rendered
  34114. */
  34115. useDelayedTextureLoading: boolean;
  34116. /**
  34117. * Gets the list of meshes imported to the scene through SceneLoader
  34118. */
  34119. importedMeshesFiles: String[];
  34120. /**
  34121. * Gets or sets a boolean indicating if probes are enabled on this scene
  34122. */
  34123. probesEnabled: boolean;
  34124. /**
  34125. * Gets or sets the current offline provider to use to store scene data
  34126. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34127. */
  34128. offlineProvider: IOfflineProvider;
  34129. /**
  34130. * Gets or sets the action manager associated with the scene
  34131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34132. */
  34133. actionManager: AbstractActionManager;
  34134. private _meshesForIntersections;
  34135. /**
  34136. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34137. */
  34138. proceduralTexturesEnabled: boolean;
  34139. private _engine;
  34140. private _totalVertices;
  34141. /** @hidden */
  34142. _activeIndices: PerfCounter;
  34143. /** @hidden */
  34144. _activeParticles: PerfCounter;
  34145. /** @hidden */
  34146. _activeBones: PerfCounter;
  34147. private _animationRatio;
  34148. /** @hidden */
  34149. _animationTimeLast: number;
  34150. /** @hidden */
  34151. _animationTime: number;
  34152. /**
  34153. * Gets or sets a general scale for animation speed
  34154. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34155. */
  34156. animationTimeScale: number;
  34157. /** @hidden */
  34158. _cachedMaterial: Nullable<Material>;
  34159. /** @hidden */
  34160. _cachedEffect: Nullable<Effect>;
  34161. /** @hidden */
  34162. _cachedVisibility: Nullable<number>;
  34163. private _renderId;
  34164. private _frameId;
  34165. private _executeWhenReadyTimeoutId;
  34166. private _intermediateRendering;
  34167. private _viewUpdateFlag;
  34168. private _projectionUpdateFlag;
  34169. /** @hidden */
  34170. _toBeDisposed: Nullable<IDisposable>[];
  34171. private _activeRequests;
  34172. /** @hidden */
  34173. _pendingData: any[];
  34174. private _isDisposed;
  34175. /**
  34176. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34177. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34178. */
  34179. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34180. private _activeMeshes;
  34181. private _processedMaterials;
  34182. private _renderTargets;
  34183. /** @hidden */
  34184. _activeParticleSystems: SmartArray<IParticleSystem>;
  34185. private _activeSkeletons;
  34186. private _softwareSkinnedMeshes;
  34187. private _renderingManager;
  34188. /** @hidden */
  34189. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34190. private _transformMatrix;
  34191. private _sceneUbo;
  34192. /** @hidden */
  34193. _viewMatrix: Matrix;
  34194. private _projectionMatrix;
  34195. /** @hidden */
  34196. _forcedViewPosition: Nullable<Vector3>;
  34197. /** @hidden */
  34198. _frustumPlanes: Plane[];
  34199. /**
  34200. * Gets the list of frustum planes (built from the active camera)
  34201. */
  34202. readonly frustumPlanes: Plane[];
  34203. /**
  34204. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34205. * This is useful if there are more lights that the maximum simulteanous authorized
  34206. */
  34207. requireLightSorting: boolean;
  34208. /** @hidden */
  34209. readonly useMaterialMeshMap: boolean;
  34210. /** @hidden */
  34211. readonly useClonedMeshhMap: boolean;
  34212. private _externalData;
  34213. private _uid;
  34214. /**
  34215. * @hidden
  34216. * Backing store of defined scene components.
  34217. */
  34218. _components: ISceneComponent[];
  34219. /**
  34220. * @hidden
  34221. * Backing store of defined scene components.
  34222. */
  34223. _serializableComponents: ISceneSerializableComponent[];
  34224. /**
  34225. * List of components to register on the next registration step.
  34226. */
  34227. private _transientComponents;
  34228. /**
  34229. * Registers the transient components if needed.
  34230. */
  34231. private _registerTransientComponents;
  34232. /**
  34233. * @hidden
  34234. * Add a component to the scene.
  34235. * Note that the ccomponent could be registered on th next frame if this is called after
  34236. * the register component stage.
  34237. * @param component Defines the component to add to the scene
  34238. */
  34239. _addComponent(component: ISceneComponent): void;
  34240. /**
  34241. * @hidden
  34242. * Gets a component from the scene.
  34243. * @param name defines the name of the component to retrieve
  34244. * @returns the component or null if not present
  34245. */
  34246. _getComponent(name: string): Nullable<ISceneComponent>;
  34247. /**
  34248. * @hidden
  34249. * Defines the actions happening before camera updates.
  34250. */
  34251. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34252. /**
  34253. * @hidden
  34254. * Defines the actions happening before clear the canvas.
  34255. */
  34256. _beforeClearStage: Stage<SimpleStageAction>;
  34257. /**
  34258. * @hidden
  34259. * Defines the actions when collecting render targets for the frame.
  34260. */
  34261. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34262. /**
  34263. * @hidden
  34264. * Defines the actions happening for one camera in the frame.
  34265. */
  34266. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34267. /**
  34268. * @hidden
  34269. * Defines the actions happening during the per mesh ready checks.
  34270. */
  34271. _isReadyForMeshStage: Stage<MeshStageAction>;
  34272. /**
  34273. * @hidden
  34274. * Defines the actions happening before evaluate active mesh checks.
  34275. */
  34276. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34277. /**
  34278. * @hidden
  34279. * Defines the actions happening during the evaluate sub mesh checks.
  34280. */
  34281. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34282. /**
  34283. * @hidden
  34284. * Defines the actions happening during the active mesh stage.
  34285. */
  34286. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34287. /**
  34288. * @hidden
  34289. * Defines the actions happening during the per camera render target step.
  34290. */
  34291. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34292. /**
  34293. * @hidden
  34294. * Defines the actions happening just before the active camera is drawing.
  34295. */
  34296. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34297. /**
  34298. * @hidden
  34299. * Defines the actions happening just before a render target is drawing.
  34300. */
  34301. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34302. /**
  34303. * @hidden
  34304. * Defines the actions happening just before a rendering group is drawing.
  34305. */
  34306. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34307. /**
  34308. * @hidden
  34309. * Defines the actions happening just before a mesh is drawing.
  34310. */
  34311. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34312. /**
  34313. * @hidden
  34314. * Defines the actions happening just after a mesh has been drawn.
  34315. */
  34316. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34317. /**
  34318. * @hidden
  34319. * Defines the actions happening just after a rendering group has been drawn.
  34320. */
  34321. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34322. /**
  34323. * @hidden
  34324. * Defines the actions happening just after the active camera has been drawn.
  34325. */
  34326. _afterCameraDrawStage: Stage<CameraStageAction>;
  34327. /**
  34328. * @hidden
  34329. * Defines the actions happening just after a render target has been drawn.
  34330. */
  34331. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34332. /**
  34333. * @hidden
  34334. * Defines the actions happening just after rendering all cameras and computing intersections.
  34335. */
  34336. _afterRenderStage: Stage<SimpleStageAction>;
  34337. /**
  34338. * @hidden
  34339. * Defines the actions happening when a pointer move event happens.
  34340. */
  34341. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34342. /**
  34343. * @hidden
  34344. * Defines the actions happening when a pointer down event happens.
  34345. */
  34346. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34347. /**
  34348. * @hidden
  34349. * Defines the actions happening when a pointer up event happens.
  34350. */
  34351. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34352. /**
  34353. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34354. */
  34355. private geometriesByUniqueId;
  34356. /**
  34357. * Creates a new Scene
  34358. * @param engine defines the engine to use to render this scene
  34359. * @param options defines the scene options
  34360. */
  34361. constructor(engine: Engine, options?: SceneOptions);
  34362. /**
  34363. * Gets a string idenfifying the name of the class
  34364. * @returns "Scene" string
  34365. */
  34366. getClassName(): string;
  34367. private _defaultMeshCandidates;
  34368. /**
  34369. * @hidden
  34370. */
  34371. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34372. private _defaultSubMeshCandidates;
  34373. /**
  34374. * @hidden
  34375. */
  34376. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34377. /**
  34378. * Sets the default candidate providers for the scene.
  34379. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34380. * and getCollidingSubMeshCandidates to their default function
  34381. */
  34382. setDefaultCandidateProviders(): void;
  34383. /**
  34384. * Gets the mesh that is currently under the pointer
  34385. */
  34386. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34387. /**
  34388. * Gets or sets the current on-screen X position of the pointer
  34389. */
  34390. pointerX: number;
  34391. /**
  34392. * Gets or sets the current on-screen Y position of the pointer
  34393. */
  34394. pointerY: number;
  34395. /**
  34396. * Gets the cached material (ie. the latest rendered one)
  34397. * @returns the cached material
  34398. */
  34399. getCachedMaterial(): Nullable<Material>;
  34400. /**
  34401. * Gets the cached effect (ie. the latest rendered one)
  34402. * @returns the cached effect
  34403. */
  34404. getCachedEffect(): Nullable<Effect>;
  34405. /**
  34406. * Gets the cached visibility state (ie. the latest rendered one)
  34407. * @returns the cached visibility state
  34408. */
  34409. getCachedVisibility(): Nullable<number>;
  34410. /**
  34411. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34412. * @param material defines the current material
  34413. * @param effect defines the current effect
  34414. * @param visibility defines the current visibility state
  34415. * @returns true if one parameter is not cached
  34416. */
  34417. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34418. /**
  34419. * Gets the engine associated with the scene
  34420. * @returns an Engine
  34421. */
  34422. getEngine(): Engine;
  34423. /**
  34424. * Gets the total number of vertices rendered per frame
  34425. * @returns the total number of vertices rendered per frame
  34426. */
  34427. getTotalVertices(): number;
  34428. /**
  34429. * Gets the performance counter for total vertices
  34430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34431. */
  34432. readonly totalVerticesPerfCounter: PerfCounter;
  34433. /**
  34434. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34435. * @returns the total number of active indices rendered per frame
  34436. */
  34437. getActiveIndices(): number;
  34438. /**
  34439. * Gets the performance counter for active indices
  34440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34441. */
  34442. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34443. /**
  34444. * Gets the total number of active particles rendered per frame
  34445. * @returns the total number of active particles rendered per frame
  34446. */
  34447. getActiveParticles(): number;
  34448. /**
  34449. * Gets the performance counter for active particles
  34450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34451. */
  34452. readonly activeParticlesPerfCounter: PerfCounter;
  34453. /**
  34454. * Gets the total number of active bones rendered per frame
  34455. * @returns the total number of active bones rendered per frame
  34456. */
  34457. getActiveBones(): number;
  34458. /**
  34459. * Gets the performance counter for active bones
  34460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34461. */
  34462. readonly activeBonesPerfCounter: PerfCounter;
  34463. /**
  34464. * Gets the array of active meshes
  34465. * @returns an array of AbstractMesh
  34466. */
  34467. getActiveMeshes(): SmartArray<AbstractMesh>;
  34468. /**
  34469. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34470. * @returns a number
  34471. */
  34472. getAnimationRatio(): number;
  34473. /**
  34474. * Gets an unique Id for the current render phase
  34475. * @returns a number
  34476. */
  34477. getRenderId(): number;
  34478. /**
  34479. * Gets an unique Id for the current frame
  34480. * @returns a number
  34481. */
  34482. getFrameId(): number;
  34483. /** Call this function if you want to manually increment the render Id*/
  34484. incrementRenderId(): void;
  34485. private _createUbo;
  34486. /**
  34487. * Use this method to simulate a pointer move on a mesh
  34488. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34489. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34490. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34491. * @returns the current scene
  34492. */
  34493. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34494. /**
  34495. * Use this method to simulate a pointer down on a mesh
  34496. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34497. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34498. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34499. * @returns the current scene
  34500. */
  34501. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34502. /**
  34503. * Use this method to simulate a pointer up on a mesh
  34504. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34505. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34506. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34507. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34508. * @returns the current scene
  34509. */
  34510. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34511. /**
  34512. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34513. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34514. * @returns true if the pointer was captured
  34515. */
  34516. isPointerCaptured(pointerId?: number): boolean;
  34517. /**
  34518. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34519. * @param attachUp defines if you want to attach events to pointerup
  34520. * @param attachDown defines if you want to attach events to pointerdown
  34521. * @param attachMove defines if you want to attach events to pointermove
  34522. */
  34523. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34524. /** Detaches all event handlers*/
  34525. detachControl(): void;
  34526. /**
  34527. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34528. * Delay loaded resources are not taking in account
  34529. * @return true if all required resources are ready
  34530. */
  34531. isReady(): boolean;
  34532. /** Resets all cached information relative to material (including effect and visibility) */
  34533. resetCachedMaterial(): void;
  34534. /**
  34535. * Registers a function to be called before every frame render
  34536. * @param func defines the function to register
  34537. */
  34538. registerBeforeRender(func: () => void): void;
  34539. /**
  34540. * Unregisters a function called before every frame render
  34541. * @param func defines the function to unregister
  34542. */
  34543. unregisterBeforeRender(func: () => void): void;
  34544. /**
  34545. * Registers a function to be called after every frame render
  34546. * @param func defines the function to register
  34547. */
  34548. registerAfterRender(func: () => void): void;
  34549. /**
  34550. * Unregisters a function called after every frame render
  34551. * @param func defines the function to unregister
  34552. */
  34553. unregisterAfterRender(func: () => void): void;
  34554. private _executeOnceBeforeRender;
  34555. /**
  34556. * The provided function will run before render once and will be disposed afterwards.
  34557. * A timeout delay can be provided so that the function will be executed in N ms.
  34558. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34559. * @param func The function to be executed.
  34560. * @param timeout optional delay in ms
  34561. */
  34562. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34563. /** @hidden */
  34564. _addPendingData(data: any): void;
  34565. /** @hidden */
  34566. _removePendingData(data: any): void;
  34567. /**
  34568. * Returns the number of items waiting to be loaded
  34569. * @returns the number of items waiting to be loaded
  34570. */
  34571. getWaitingItemsCount(): number;
  34572. /**
  34573. * Returns a boolean indicating if the scene is still loading data
  34574. */
  34575. readonly isLoading: boolean;
  34576. /**
  34577. * Registers a function to be executed when the scene is ready
  34578. * @param {Function} func - the function to be executed
  34579. */
  34580. executeWhenReady(func: () => void): void;
  34581. /**
  34582. * Returns a promise that resolves when the scene is ready
  34583. * @returns A promise that resolves when the scene is ready
  34584. */
  34585. whenReadyAsync(): Promise<void>;
  34586. /** @hidden */
  34587. _checkIsReady(): void;
  34588. /**
  34589. * Gets all animatable attached to the scene
  34590. */
  34591. readonly animatables: Animatable[];
  34592. /**
  34593. * Resets the last animation time frame.
  34594. * Useful to override when animations start running when loading a scene for the first time.
  34595. */
  34596. resetLastAnimationTimeFrame(): void;
  34597. /**
  34598. * Gets the current view matrix
  34599. * @returns a Matrix
  34600. */
  34601. getViewMatrix(): Matrix;
  34602. /**
  34603. * Gets the current projection matrix
  34604. * @returns a Matrix
  34605. */
  34606. getProjectionMatrix(): Matrix;
  34607. /**
  34608. * Gets the current transform matrix
  34609. * @returns a Matrix made of View * Projection
  34610. */
  34611. getTransformMatrix(): Matrix;
  34612. /**
  34613. * Sets the current transform matrix
  34614. * @param viewL defines the View matrix to use
  34615. * @param projectionL defines the Projection matrix to use
  34616. * @param viewR defines the right View matrix to use (if provided)
  34617. * @param projectionR defines the right Projection matrix to use (if provided)
  34618. */
  34619. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34620. /**
  34621. * Gets the uniform buffer used to store scene data
  34622. * @returns a UniformBuffer
  34623. */
  34624. getSceneUniformBuffer(): UniformBuffer;
  34625. /**
  34626. * Gets an unique (relatively to the current scene) Id
  34627. * @returns an unique number for the scene
  34628. */
  34629. getUniqueId(): number;
  34630. /**
  34631. * Add a mesh to the list of scene's meshes
  34632. * @param newMesh defines the mesh to add
  34633. * @param recursive if all child meshes should also be added to the scene
  34634. */
  34635. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34636. /**
  34637. * Remove a mesh for the list of scene's meshes
  34638. * @param toRemove defines the mesh to remove
  34639. * @param recursive if all child meshes should also be removed from the scene
  34640. * @returns the index where the mesh was in the mesh list
  34641. */
  34642. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34643. /**
  34644. * Add a transform node to the list of scene's transform nodes
  34645. * @param newTransformNode defines the transform node to add
  34646. */
  34647. addTransformNode(newTransformNode: TransformNode): void;
  34648. /**
  34649. * Remove a transform node for the list of scene's transform nodes
  34650. * @param toRemove defines the transform node to remove
  34651. * @returns the index where the transform node was in the transform node list
  34652. */
  34653. removeTransformNode(toRemove: TransformNode): number;
  34654. /**
  34655. * Remove a skeleton for the list of scene's skeletons
  34656. * @param toRemove defines the skeleton to remove
  34657. * @returns the index where the skeleton was in the skeleton list
  34658. */
  34659. removeSkeleton(toRemove: Skeleton): number;
  34660. /**
  34661. * Remove a morph target for the list of scene's morph targets
  34662. * @param toRemove defines the morph target to remove
  34663. * @returns the index where the morph target was in the morph target list
  34664. */
  34665. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34666. /**
  34667. * Remove a light for the list of scene's lights
  34668. * @param toRemove defines the light to remove
  34669. * @returns the index where the light was in the light list
  34670. */
  34671. removeLight(toRemove: Light): number;
  34672. /**
  34673. * Remove a camera for the list of scene's cameras
  34674. * @param toRemove defines the camera to remove
  34675. * @returns the index where the camera was in the camera list
  34676. */
  34677. removeCamera(toRemove: Camera): number;
  34678. /**
  34679. * Remove a particle system for the list of scene's particle systems
  34680. * @param toRemove defines the particle system to remove
  34681. * @returns the index where the particle system was in the particle system list
  34682. */
  34683. removeParticleSystem(toRemove: IParticleSystem): number;
  34684. /**
  34685. * Remove a animation for the list of scene's animations
  34686. * @param toRemove defines the animation to remove
  34687. * @returns the index where the animation was in the animation list
  34688. */
  34689. removeAnimation(toRemove: Animation): number;
  34690. /**
  34691. * Will stop the animation of the given target
  34692. * @param target - the target
  34693. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34694. * @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)
  34695. */
  34696. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34697. /**
  34698. * Removes the given animation group from this scene.
  34699. * @param toRemove The animation group to remove
  34700. * @returns The index of the removed animation group
  34701. */
  34702. removeAnimationGroup(toRemove: AnimationGroup): number;
  34703. /**
  34704. * Removes the given multi-material from this scene.
  34705. * @param toRemove The multi-material to remove
  34706. * @returns The index of the removed multi-material
  34707. */
  34708. removeMultiMaterial(toRemove: MultiMaterial): number;
  34709. /**
  34710. * Removes the given material from this scene.
  34711. * @param toRemove The material to remove
  34712. * @returns The index of the removed material
  34713. */
  34714. removeMaterial(toRemove: Material): number;
  34715. /**
  34716. * Removes the given action manager from this scene.
  34717. * @param toRemove The action manager to remove
  34718. * @returns The index of the removed action manager
  34719. */
  34720. removeActionManager(toRemove: AbstractActionManager): number;
  34721. /**
  34722. * Removes the given texture from this scene.
  34723. * @param toRemove The texture to remove
  34724. * @returns The index of the removed texture
  34725. */
  34726. removeTexture(toRemove: BaseTexture): number;
  34727. /**
  34728. * Adds the given light to this scene
  34729. * @param newLight The light to add
  34730. */
  34731. addLight(newLight: Light): void;
  34732. /**
  34733. * Sorts the list list based on light priorities
  34734. */
  34735. sortLightsByPriority(): void;
  34736. /**
  34737. * Adds the given camera to this scene
  34738. * @param newCamera The camera to add
  34739. */
  34740. addCamera(newCamera: Camera): void;
  34741. /**
  34742. * Adds the given skeleton to this scene
  34743. * @param newSkeleton The skeleton to add
  34744. */
  34745. addSkeleton(newSkeleton: Skeleton): void;
  34746. /**
  34747. * Adds the given particle system to this scene
  34748. * @param newParticleSystem The particle system to add
  34749. */
  34750. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34751. /**
  34752. * Adds the given animation to this scene
  34753. * @param newAnimation The animation to add
  34754. */
  34755. addAnimation(newAnimation: Animation): void;
  34756. /**
  34757. * Adds the given animation group to this scene.
  34758. * @param newAnimationGroup The animation group to add
  34759. */
  34760. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34761. /**
  34762. * Adds the given multi-material to this scene
  34763. * @param newMultiMaterial The multi-material to add
  34764. */
  34765. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34766. /**
  34767. * Adds the given material to this scene
  34768. * @param newMaterial The material to add
  34769. */
  34770. addMaterial(newMaterial: Material): void;
  34771. /**
  34772. * Adds the given morph target to this scene
  34773. * @param newMorphTargetManager The morph target to add
  34774. */
  34775. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34776. /**
  34777. * Adds the given geometry to this scene
  34778. * @param newGeometry The geometry to add
  34779. */
  34780. addGeometry(newGeometry: Geometry): void;
  34781. /**
  34782. * Adds the given action manager to this scene
  34783. * @param newActionManager The action manager to add
  34784. */
  34785. addActionManager(newActionManager: AbstractActionManager): void;
  34786. /**
  34787. * Adds the given texture to this scene.
  34788. * @param newTexture The texture to add
  34789. */
  34790. addTexture(newTexture: BaseTexture): void;
  34791. /**
  34792. * Switch active camera
  34793. * @param newCamera defines the new active camera
  34794. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34795. */
  34796. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34797. /**
  34798. * sets the active camera of the scene using its ID
  34799. * @param id defines the camera's ID
  34800. * @return the new active camera or null if none found.
  34801. */
  34802. setActiveCameraByID(id: string): Nullable<Camera>;
  34803. /**
  34804. * sets the active camera of the scene using its name
  34805. * @param name defines the camera's name
  34806. * @returns the new active camera or null if none found.
  34807. */
  34808. setActiveCameraByName(name: string): Nullable<Camera>;
  34809. /**
  34810. * get an animation group using its name
  34811. * @param name defines the material's name
  34812. * @return the animation group or null if none found.
  34813. */
  34814. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34815. /**
  34816. * Get a material using its unique id
  34817. * @param uniqueId defines the material's unique id
  34818. * @return the material or null if none found.
  34819. */
  34820. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34821. /**
  34822. * get a material using its id
  34823. * @param id defines the material's ID
  34824. * @return the material or null if none found.
  34825. */
  34826. getMaterialByID(id: string): Nullable<Material>;
  34827. /**
  34828. * Gets a the last added material using a given id
  34829. * @param id defines the material's ID
  34830. * @return the last material with the given id or null if none found.
  34831. */
  34832. getLastMaterialByID(id: string): Nullable<Material>;
  34833. /**
  34834. * Gets a material using its name
  34835. * @param name defines the material's name
  34836. * @return the material or null if none found.
  34837. */
  34838. getMaterialByName(name: string): Nullable<Material>;
  34839. /**
  34840. * Get a texture using its unique id
  34841. * @param uniqueId defines the texture's unique id
  34842. * @return the texture or null if none found.
  34843. */
  34844. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34845. /**
  34846. * Gets a camera using its id
  34847. * @param id defines the id to look for
  34848. * @returns the camera or null if not found
  34849. */
  34850. getCameraByID(id: string): Nullable<Camera>;
  34851. /**
  34852. * Gets a camera using its unique id
  34853. * @param uniqueId defines the unique id to look for
  34854. * @returns the camera or null if not found
  34855. */
  34856. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34857. /**
  34858. * Gets a camera using its name
  34859. * @param name defines the camera's name
  34860. * @return the camera or null if none found.
  34861. */
  34862. getCameraByName(name: string): Nullable<Camera>;
  34863. /**
  34864. * Gets a bone using its id
  34865. * @param id defines the bone's id
  34866. * @return the bone or null if not found
  34867. */
  34868. getBoneByID(id: string): Nullable<Bone>;
  34869. /**
  34870. * Gets a bone using its id
  34871. * @param name defines the bone's name
  34872. * @return the bone or null if not found
  34873. */
  34874. getBoneByName(name: string): Nullable<Bone>;
  34875. /**
  34876. * Gets a light node using its name
  34877. * @param name defines the the light's name
  34878. * @return the light or null if none found.
  34879. */
  34880. getLightByName(name: string): Nullable<Light>;
  34881. /**
  34882. * Gets a light node using its id
  34883. * @param id defines the light's id
  34884. * @return the light or null if none found.
  34885. */
  34886. getLightByID(id: string): Nullable<Light>;
  34887. /**
  34888. * Gets a light node using its scene-generated unique ID
  34889. * @param uniqueId defines the light's unique id
  34890. * @return the light or null if none found.
  34891. */
  34892. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34893. /**
  34894. * Gets a particle system by id
  34895. * @param id defines the particle system id
  34896. * @return the corresponding system or null if none found
  34897. */
  34898. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34899. /**
  34900. * Gets a geometry using its ID
  34901. * @param id defines the geometry's id
  34902. * @return the geometry or null if none found.
  34903. */
  34904. getGeometryByID(id: string): Nullable<Geometry>;
  34905. private _getGeometryByUniqueID;
  34906. /**
  34907. * Add a new geometry to this scene
  34908. * @param geometry defines the geometry to be added to the scene.
  34909. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34910. * @return a boolean defining if the geometry was added or not
  34911. */
  34912. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34913. /**
  34914. * Removes an existing geometry
  34915. * @param geometry defines the geometry to be removed from the scene
  34916. * @return a boolean defining if the geometry was removed or not
  34917. */
  34918. removeGeometry(geometry: Geometry): boolean;
  34919. /**
  34920. * Gets the list of geometries attached to the scene
  34921. * @returns an array of Geometry
  34922. */
  34923. getGeometries(): Geometry[];
  34924. /**
  34925. * Gets the first added mesh found of a given ID
  34926. * @param id defines the id to search for
  34927. * @return the mesh found or null if not found at all
  34928. */
  34929. getMeshByID(id: string): Nullable<AbstractMesh>;
  34930. /**
  34931. * Gets a list of meshes using their id
  34932. * @param id defines the id to search for
  34933. * @returns a list of meshes
  34934. */
  34935. getMeshesByID(id: string): Array<AbstractMesh>;
  34936. /**
  34937. * Gets the first added transform node found of a given ID
  34938. * @param id defines the id to search for
  34939. * @return the found transform node or null if not found at all.
  34940. */
  34941. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34942. /**
  34943. * Gets a transform node with its auto-generated unique id
  34944. * @param uniqueId efines the unique id to search for
  34945. * @return the found transform node or null if not found at all.
  34946. */
  34947. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34948. /**
  34949. * Gets a list of transform nodes using their id
  34950. * @param id defines the id to search for
  34951. * @returns a list of transform nodes
  34952. */
  34953. getTransformNodesByID(id: string): Array<TransformNode>;
  34954. /**
  34955. * Gets a mesh with its auto-generated unique id
  34956. * @param uniqueId defines the unique id to search for
  34957. * @return the found mesh or null if not found at all.
  34958. */
  34959. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34960. /**
  34961. * Gets a the last added mesh using a given id
  34962. * @param id defines the id to search for
  34963. * @return the found mesh or null if not found at all.
  34964. */
  34965. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34966. /**
  34967. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34968. * @param id defines the id to search for
  34969. * @return the found node or null if not found at all
  34970. */
  34971. getLastEntryByID(id: string): Nullable<Node>;
  34972. /**
  34973. * Gets a node (Mesh, Camera, Light) using a given id
  34974. * @param id defines the id to search for
  34975. * @return the found node or null if not found at all
  34976. */
  34977. getNodeByID(id: string): Nullable<Node>;
  34978. /**
  34979. * Gets a node (Mesh, Camera, Light) using a given name
  34980. * @param name defines the name to search for
  34981. * @return the found node or null if not found at all.
  34982. */
  34983. getNodeByName(name: string): Nullable<Node>;
  34984. /**
  34985. * Gets a mesh using a given name
  34986. * @param name defines the name to search for
  34987. * @return the found mesh or null if not found at all.
  34988. */
  34989. getMeshByName(name: string): Nullable<AbstractMesh>;
  34990. /**
  34991. * Gets a transform node using a given name
  34992. * @param name defines the name to search for
  34993. * @return the found transform node or null if not found at all.
  34994. */
  34995. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34996. /**
  34997. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34998. * @param id defines the id to search for
  34999. * @return the found skeleton or null if not found at all.
  35000. */
  35001. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35002. /**
  35003. * Gets a skeleton using a given auto generated unique id
  35004. * @param uniqueId defines the unique id to search for
  35005. * @return the found skeleton or null if not found at all.
  35006. */
  35007. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35008. /**
  35009. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35010. * @param id defines the id to search for
  35011. * @return the found skeleton or null if not found at all.
  35012. */
  35013. getSkeletonById(id: string): Nullable<Skeleton>;
  35014. /**
  35015. * Gets a skeleton using a given name
  35016. * @param name defines the name to search for
  35017. * @return the found skeleton or null if not found at all.
  35018. */
  35019. getSkeletonByName(name: string): Nullable<Skeleton>;
  35020. /**
  35021. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35022. * @param id defines the id to search for
  35023. * @return the found morph target manager or null if not found at all.
  35024. */
  35025. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35026. /**
  35027. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35028. * @param id defines the id to search for
  35029. * @return the found morph target or null if not found at all.
  35030. */
  35031. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35032. /**
  35033. * Gets a boolean indicating if the given mesh is active
  35034. * @param mesh defines the mesh to look for
  35035. * @returns true if the mesh is in the active list
  35036. */
  35037. isActiveMesh(mesh: AbstractMesh): boolean;
  35038. /**
  35039. * Return a unique id as a string which can serve as an identifier for the scene
  35040. */
  35041. readonly uid: string;
  35042. /**
  35043. * Add an externaly attached data from its key.
  35044. * This method call will fail and return false, if such key already exists.
  35045. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35046. * @param key the unique key that identifies the data
  35047. * @param data the data object to associate to the key for this Engine instance
  35048. * @return true if no such key were already present and the data was added successfully, false otherwise
  35049. */
  35050. addExternalData<T>(key: string, data: T): boolean;
  35051. /**
  35052. * Get an externaly attached data from its key
  35053. * @param key the unique key that identifies the data
  35054. * @return the associated data, if present (can be null), or undefined if not present
  35055. */
  35056. getExternalData<T>(key: string): Nullable<T>;
  35057. /**
  35058. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35059. * @param key the unique key that identifies the data
  35060. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35061. * @return the associated data, can be null if the factory returned null.
  35062. */
  35063. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35064. /**
  35065. * Remove an externaly attached data from the Engine instance
  35066. * @param key the unique key that identifies the data
  35067. * @return true if the data was successfully removed, false if it doesn't exist
  35068. */
  35069. removeExternalData(key: string): boolean;
  35070. private _evaluateSubMesh;
  35071. /**
  35072. * Clear the processed materials smart array preventing retention point in material dispose.
  35073. */
  35074. freeProcessedMaterials(): void;
  35075. private _preventFreeActiveMeshesAndRenderingGroups;
  35076. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35077. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35078. * when disposing several meshes in a row or a hierarchy of meshes.
  35079. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35080. */
  35081. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35082. /**
  35083. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35084. */
  35085. freeActiveMeshes(): void;
  35086. /**
  35087. * Clear the info related to rendering groups preventing retention points during dispose.
  35088. */
  35089. freeRenderingGroups(): void;
  35090. /** @hidden */
  35091. _isInIntermediateRendering(): boolean;
  35092. /**
  35093. * Lambda returning the list of potentially active meshes.
  35094. */
  35095. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35096. /**
  35097. * Lambda returning the list of potentially active sub meshes.
  35098. */
  35099. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35100. /**
  35101. * Lambda returning the list of potentially intersecting sub meshes.
  35102. */
  35103. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35104. /**
  35105. * Lambda returning the list of potentially colliding sub meshes.
  35106. */
  35107. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35108. private _activeMeshesFrozen;
  35109. /**
  35110. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35111. * @returns the current scene
  35112. */
  35113. freezeActiveMeshes(): Scene;
  35114. /**
  35115. * Use this function to restart evaluating active meshes on every frame
  35116. * @returns the current scene
  35117. */
  35118. unfreezeActiveMeshes(): Scene;
  35119. private _evaluateActiveMeshes;
  35120. private _activeMesh;
  35121. /**
  35122. * Update the transform matrix to update from the current active camera
  35123. * @param force defines a boolean used to force the update even if cache is up to date
  35124. */
  35125. updateTransformMatrix(force?: boolean): void;
  35126. private _bindFrameBuffer;
  35127. /** @hidden */
  35128. _allowPostProcessClearColor: boolean;
  35129. /** @hidden */
  35130. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35131. private _processSubCameras;
  35132. private _checkIntersections;
  35133. /** @hidden */
  35134. _advancePhysicsEngineStep(step: number): void;
  35135. /**
  35136. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35137. */
  35138. getDeterministicFrameTime: () => number;
  35139. /** @hidden */
  35140. _animate(): void;
  35141. /** Execute all animations (for a frame) */
  35142. animate(): void;
  35143. /**
  35144. * Render the scene
  35145. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35146. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35147. */
  35148. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35149. /**
  35150. * Freeze all materials
  35151. * A frozen material will not be updatable but should be faster to render
  35152. */
  35153. freezeMaterials(): void;
  35154. /**
  35155. * Unfreeze all materials
  35156. * A frozen material will not be updatable but should be faster to render
  35157. */
  35158. unfreezeMaterials(): void;
  35159. /**
  35160. * Releases all held ressources
  35161. */
  35162. dispose(): void;
  35163. /**
  35164. * Gets if the scene is already disposed
  35165. */
  35166. readonly isDisposed: boolean;
  35167. /**
  35168. * Call this function to reduce memory footprint of the scene.
  35169. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35170. */
  35171. clearCachedVertexData(): void;
  35172. /**
  35173. * This function will remove the local cached buffer data from texture.
  35174. * It will save memory but will prevent the texture from being rebuilt
  35175. */
  35176. cleanCachedTextureBuffer(): void;
  35177. /**
  35178. * Get the world extend vectors with an optional filter
  35179. *
  35180. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35181. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35182. */
  35183. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35184. min: Vector3;
  35185. max: Vector3;
  35186. };
  35187. /**
  35188. * Creates a ray that can be used to pick in the scene
  35189. * @param x defines the x coordinate of the origin (on-screen)
  35190. * @param y defines the y coordinate of the origin (on-screen)
  35191. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35192. * @param camera defines the camera to use for the picking
  35193. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35194. * @returns a Ray
  35195. */
  35196. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35197. /**
  35198. * Creates a ray that can be used to pick in the scene
  35199. * @param x defines the x coordinate of the origin (on-screen)
  35200. * @param y defines the y coordinate of the origin (on-screen)
  35201. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35202. * @param result defines the ray where to store the picking ray
  35203. * @param camera defines the camera to use for the picking
  35204. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35205. * @returns the current scene
  35206. */
  35207. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35208. /**
  35209. * Creates a ray that can be used to pick in the scene
  35210. * @param x defines the x coordinate of the origin (on-screen)
  35211. * @param y defines the y coordinate of the origin (on-screen)
  35212. * @param camera defines the camera to use for the picking
  35213. * @returns a Ray
  35214. */
  35215. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35216. /**
  35217. * Creates a ray that can be used to pick in the scene
  35218. * @param x defines the x coordinate of the origin (on-screen)
  35219. * @param y defines the y coordinate of the origin (on-screen)
  35220. * @param result defines the ray where to store the picking ray
  35221. * @param camera defines the camera to use for the picking
  35222. * @returns the current scene
  35223. */
  35224. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35225. /** Launch a ray to try to pick a mesh in the scene
  35226. * @param x position on screen
  35227. * @param y position on screen
  35228. * @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
  35229. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35230. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35232. * @returns a PickingInfo
  35233. */
  35234. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35235. /** Use the given ray to pick a mesh in the scene
  35236. * @param ray The ray to use to pick meshes
  35237. * @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
  35238. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35240. * @returns a PickingInfo
  35241. */
  35242. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35243. /**
  35244. * Launch a ray to try to pick a mesh in the scene
  35245. * @param x X position on screen
  35246. * @param y Y position on screen
  35247. * @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
  35248. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35249. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35250. * @returns an array of PickingInfo
  35251. */
  35252. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35253. /**
  35254. * Launch a ray to try to pick a mesh in the scene
  35255. * @param ray Ray to use
  35256. * @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
  35257. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35258. * @returns an array of PickingInfo
  35259. */
  35260. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35261. /**
  35262. * Force the value of meshUnderPointer
  35263. * @param mesh defines the mesh to use
  35264. */
  35265. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35266. /**
  35267. * Gets the mesh under the pointer
  35268. * @returns a Mesh or null if no mesh is under the pointer
  35269. */
  35270. getPointerOverMesh(): Nullable<AbstractMesh>;
  35271. /** @hidden */
  35272. _rebuildGeometries(): void;
  35273. /** @hidden */
  35274. _rebuildTextures(): void;
  35275. private _getByTags;
  35276. /**
  35277. * Get a list of meshes by tags
  35278. * @param tagsQuery defines the tags query to use
  35279. * @param forEach defines a predicate used to filter results
  35280. * @returns an array of Mesh
  35281. */
  35282. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35283. /**
  35284. * Get a list of cameras by tags
  35285. * @param tagsQuery defines the tags query to use
  35286. * @param forEach defines a predicate used to filter results
  35287. * @returns an array of Camera
  35288. */
  35289. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35290. /**
  35291. * Get a list of lights by tags
  35292. * @param tagsQuery defines the tags query to use
  35293. * @param forEach defines a predicate used to filter results
  35294. * @returns an array of Light
  35295. */
  35296. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35297. /**
  35298. * Get a list of materials by tags
  35299. * @param tagsQuery defines the tags query to use
  35300. * @param forEach defines a predicate used to filter results
  35301. * @returns an array of Material
  35302. */
  35303. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35304. /**
  35305. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35306. * This allowed control for front to back rendering or reversly depending of the special needs.
  35307. *
  35308. * @param renderingGroupId The rendering group id corresponding to its index
  35309. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35310. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35311. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35312. */
  35313. 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;
  35314. /**
  35315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35316. *
  35317. * @param renderingGroupId The rendering group id corresponding to its index
  35318. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35319. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35320. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35321. */
  35322. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35323. /**
  35324. * Gets the current auto clear configuration for one rendering group of the rendering
  35325. * manager.
  35326. * @param index the rendering group index to get the information for
  35327. * @returns The auto clear setup for the requested rendering group
  35328. */
  35329. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35330. private _blockMaterialDirtyMechanism;
  35331. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35332. blockMaterialDirtyMechanism: boolean;
  35333. /**
  35334. * Will flag all materials as dirty to trigger new shader compilation
  35335. * @param flag defines the flag used to specify which material part must be marked as dirty
  35336. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35337. */
  35338. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35339. /** @hidden */
  35340. _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;
  35341. /** @hidden */
  35342. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35343. }
  35344. }
  35345. declare module "babylonjs/assetContainer" {
  35346. import { AbstractScene } from "babylonjs/abstractScene";
  35347. import { Scene } from "babylonjs/scene";
  35348. import { Mesh } from "babylonjs/Meshes/mesh";
  35349. /**
  35350. * Set of assets to keep when moving a scene into an asset container.
  35351. */
  35352. export class KeepAssets extends AbstractScene {
  35353. }
  35354. /**
  35355. * Container with a set of assets that can be added or removed from a scene.
  35356. */
  35357. export class AssetContainer extends AbstractScene {
  35358. /**
  35359. * The scene the AssetContainer belongs to.
  35360. */
  35361. scene: Scene;
  35362. /**
  35363. * Instantiates an AssetContainer.
  35364. * @param scene The scene the AssetContainer belongs to.
  35365. */
  35366. constructor(scene: Scene);
  35367. /**
  35368. * Adds all the assets from the container to the scene.
  35369. */
  35370. addAllToScene(): void;
  35371. /**
  35372. * Removes all the assets in the container from the scene
  35373. */
  35374. removeAllFromScene(): void;
  35375. /**
  35376. * Disposes all the assets in the container
  35377. */
  35378. dispose(): void;
  35379. private _moveAssets;
  35380. /**
  35381. * Removes all the assets contained in the scene and adds them to the container.
  35382. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35383. */
  35384. moveAllFromScene(keepAssets?: KeepAssets): void;
  35385. /**
  35386. * 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.
  35387. * @returns the root mesh
  35388. */
  35389. createRootMesh(): Mesh;
  35390. }
  35391. }
  35392. declare module "babylonjs/abstractScene" {
  35393. import { Scene } from "babylonjs/scene";
  35394. import { Nullable } from "babylonjs/types";
  35395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35396. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35397. import { Geometry } from "babylonjs/Meshes/geometry";
  35398. import { Skeleton } from "babylonjs/Bones/skeleton";
  35399. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35400. import { AssetContainer } from "babylonjs/assetContainer";
  35401. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35402. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35404. import { Material } from "babylonjs/Materials/material";
  35405. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35406. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35407. import { Camera } from "babylonjs/Cameras/camera";
  35408. import { Light } from "babylonjs/Lights/light";
  35409. import { Node } from "babylonjs/node";
  35410. import { Animation } from "babylonjs/Animations/animation";
  35411. /**
  35412. * Defines how the parser contract is defined.
  35413. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35414. */
  35415. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35416. /**
  35417. * Defines how the individual parser contract is defined.
  35418. * These parser can parse an individual asset
  35419. */
  35420. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35421. /**
  35422. * Base class of the scene acting as a container for the different elements composing a scene.
  35423. * This class is dynamically extended by the different components of the scene increasing
  35424. * flexibility and reducing coupling
  35425. */
  35426. export abstract class AbstractScene {
  35427. /**
  35428. * Stores the list of available parsers in the application.
  35429. */
  35430. private static _BabylonFileParsers;
  35431. /**
  35432. * Stores the list of available individual parsers in the application.
  35433. */
  35434. private static _IndividualBabylonFileParsers;
  35435. /**
  35436. * Adds a parser in the list of available ones
  35437. * @param name Defines the name of the parser
  35438. * @param parser Defines the parser to add
  35439. */
  35440. static AddParser(name: string, parser: BabylonFileParser): void;
  35441. /**
  35442. * Gets a general parser from the list of avaialble ones
  35443. * @param name Defines the name of the parser
  35444. * @returns the requested parser or null
  35445. */
  35446. static GetParser(name: string): Nullable<BabylonFileParser>;
  35447. /**
  35448. * Adds n individual parser in the list of available ones
  35449. * @param name Defines the name of the parser
  35450. * @param parser Defines the parser to add
  35451. */
  35452. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35453. /**
  35454. * Gets an individual parser from the list of avaialble ones
  35455. * @param name Defines the name of the parser
  35456. * @returns the requested parser or null
  35457. */
  35458. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35459. /**
  35460. * Parser json data and populate both a scene and its associated container object
  35461. * @param jsonData Defines the data to parse
  35462. * @param scene Defines the scene to parse the data for
  35463. * @param container Defines the container attached to the parsing sequence
  35464. * @param rootUrl Defines the root url of the data
  35465. */
  35466. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35467. /**
  35468. * Gets the list of root nodes (ie. nodes with no parent)
  35469. */
  35470. rootNodes: Node[];
  35471. /** All of the cameras added to this scene
  35472. * @see http://doc.babylonjs.com/babylon101/cameras
  35473. */
  35474. cameras: Camera[];
  35475. /**
  35476. * All of the lights added to this scene
  35477. * @see http://doc.babylonjs.com/babylon101/lights
  35478. */
  35479. lights: Light[];
  35480. /**
  35481. * All of the (abstract) meshes added to this scene
  35482. */
  35483. meshes: AbstractMesh[];
  35484. /**
  35485. * The list of skeletons added to the scene
  35486. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35487. */
  35488. skeletons: Skeleton[];
  35489. /**
  35490. * All of the particle systems added to this scene
  35491. * @see http://doc.babylonjs.com/babylon101/particles
  35492. */
  35493. particleSystems: IParticleSystem[];
  35494. /**
  35495. * Gets a list of Animations associated with the scene
  35496. */
  35497. animations: Animation[];
  35498. /**
  35499. * All of the animation groups added to this scene
  35500. * @see http://doc.babylonjs.com/how_to/group
  35501. */
  35502. animationGroups: AnimationGroup[];
  35503. /**
  35504. * All of the multi-materials added to this scene
  35505. * @see http://doc.babylonjs.com/how_to/multi_materials
  35506. */
  35507. multiMaterials: MultiMaterial[];
  35508. /**
  35509. * All of the materials added to this scene
  35510. * In the context of a Scene, it is not supposed to be modified manually.
  35511. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35512. * Note also that the order of the Material wihin the array is not significant and might change.
  35513. * @see http://doc.babylonjs.com/babylon101/materials
  35514. */
  35515. materials: Material[];
  35516. /**
  35517. * The list of morph target managers added to the scene
  35518. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35519. */
  35520. morphTargetManagers: MorphTargetManager[];
  35521. /**
  35522. * The list of geometries used in the scene.
  35523. */
  35524. geometries: Geometry[];
  35525. /**
  35526. * All of the tranform nodes added to this scene
  35527. * In the context of a Scene, it is not supposed to be modified manually.
  35528. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35529. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35530. * @see http://doc.babylonjs.com/how_to/transformnode
  35531. */
  35532. transformNodes: TransformNode[];
  35533. /**
  35534. * ActionManagers available on the scene.
  35535. */
  35536. actionManagers: AbstractActionManager[];
  35537. /**
  35538. * Textures to keep.
  35539. */
  35540. textures: BaseTexture[];
  35541. /**
  35542. * Environment texture for the scene
  35543. */
  35544. environmentTexture: Nullable<BaseTexture>;
  35545. }
  35546. }
  35547. declare module "babylonjs/Audio/sound" {
  35548. import { Observable } from "babylonjs/Misc/observable";
  35549. import { Vector3 } from "babylonjs/Maths/math.vector";
  35550. import { Nullable } from "babylonjs/types";
  35551. import { Scene } from "babylonjs/scene";
  35552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35553. /**
  35554. * Interface used to define options for Sound class
  35555. */
  35556. export interface ISoundOptions {
  35557. /**
  35558. * Does the sound autoplay once loaded.
  35559. */
  35560. autoplay?: boolean;
  35561. /**
  35562. * Does the sound loop after it finishes playing once.
  35563. */
  35564. loop?: boolean;
  35565. /**
  35566. * Sound's volume
  35567. */
  35568. volume?: number;
  35569. /**
  35570. * Is it a spatial sound?
  35571. */
  35572. spatialSound?: boolean;
  35573. /**
  35574. * Maximum distance to hear that sound
  35575. */
  35576. maxDistance?: number;
  35577. /**
  35578. * Uses user defined attenuation function
  35579. */
  35580. useCustomAttenuation?: boolean;
  35581. /**
  35582. * Define the roll off factor of spatial sounds.
  35583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35584. */
  35585. rolloffFactor?: number;
  35586. /**
  35587. * Define the reference distance the sound should be heard perfectly.
  35588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35589. */
  35590. refDistance?: number;
  35591. /**
  35592. * Define the distance attenuation model the sound will follow.
  35593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35594. */
  35595. distanceModel?: string;
  35596. /**
  35597. * Defines the playback speed (1 by default)
  35598. */
  35599. playbackRate?: number;
  35600. /**
  35601. * Defines if the sound is from a streaming source
  35602. */
  35603. streaming?: boolean;
  35604. /**
  35605. * Defines an optional length (in seconds) inside the sound file
  35606. */
  35607. length?: number;
  35608. /**
  35609. * Defines an optional offset (in seconds) inside the sound file
  35610. */
  35611. offset?: number;
  35612. /**
  35613. * If true, URLs will not be required to state the audio file codec to use.
  35614. */
  35615. skipCodecCheck?: boolean;
  35616. }
  35617. /**
  35618. * Defines a sound that can be played in the application.
  35619. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35621. */
  35622. export class Sound {
  35623. /**
  35624. * The name of the sound in the scene.
  35625. */
  35626. name: string;
  35627. /**
  35628. * Does the sound autoplay once loaded.
  35629. */
  35630. autoplay: boolean;
  35631. /**
  35632. * Does the sound loop after it finishes playing once.
  35633. */
  35634. loop: boolean;
  35635. /**
  35636. * Does the sound use a custom attenuation curve to simulate the falloff
  35637. * happening when the source gets further away from the camera.
  35638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35639. */
  35640. useCustomAttenuation: boolean;
  35641. /**
  35642. * The sound track id this sound belongs to.
  35643. */
  35644. soundTrackId: number;
  35645. /**
  35646. * Is this sound currently played.
  35647. */
  35648. isPlaying: boolean;
  35649. /**
  35650. * Is this sound currently paused.
  35651. */
  35652. isPaused: boolean;
  35653. /**
  35654. * Does this sound enables spatial sound.
  35655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35656. */
  35657. spatialSound: boolean;
  35658. /**
  35659. * Define the reference distance the sound should be heard perfectly.
  35660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35661. */
  35662. refDistance: number;
  35663. /**
  35664. * Define the roll off factor of spatial sounds.
  35665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35666. */
  35667. rolloffFactor: number;
  35668. /**
  35669. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35671. */
  35672. maxDistance: number;
  35673. /**
  35674. * Define the distance attenuation model the sound will follow.
  35675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35676. */
  35677. distanceModel: string;
  35678. /**
  35679. * @hidden
  35680. * Back Compat
  35681. **/
  35682. onended: () => any;
  35683. /**
  35684. * Observable event when the current playing sound finishes.
  35685. */
  35686. onEndedObservable: Observable<Sound>;
  35687. private _panningModel;
  35688. private _playbackRate;
  35689. private _streaming;
  35690. private _startTime;
  35691. private _startOffset;
  35692. private _position;
  35693. /** @hidden */
  35694. _positionInEmitterSpace: boolean;
  35695. private _localDirection;
  35696. private _volume;
  35697. private _isReadyToPlay;
  35698. private _isDirectional;
  35699. private _readyToPlayCallback;
  35700. private _audioBuffer;
  35701. private _soundSource;
  35702. private _streamingSource;
  35703. private _soundPanner;
  35704. private _soundGain;
  35705. private _inputAudioNode;
  35706. private _outputAudioNode;
  35707. private _coneInnerAngle;
  35708. private _coneOuterAngle;
  35709. private _coneOuterGain;
  35710. private _scene;
  35711. private _connectedTransformNode;
  35712. private _customAttenuationFunction;
  35713. private _registerFunc;
  35714. private _isOutputConnected;
  35715. private _htmlAudioElement;
  35716. private _urlType;
  35717. private _length?;
  35718. private _offset?;
  35719. /** @hidden */
  35720. static _SceneComponentInitialization: (scene: Scene) => void;
  35721. /**
  35722. * Create a sound and attach it to a scene
  35723. * @param name Name of your sound
  35724. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35725. * @param scene defines the scene the sound belongs to
  35726. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35727. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35728. */
  35729. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35730. /**
  35731. * Release the sound and its associated resources
  35732. */
  35733. dispose(): void;
  35734. /**
  35735. * Gets if the sounds is ready to be played or not.
  35736. * @returns true if ready, otherwise false
  35737. */
  35738. isReady(): boolean;
  35739. private _soundLoaded;
  35740. /**
  35741. * Sets the data of the sound from an audiobuffer
  35742. * @param audioBuffer The audioBuffer containing the data
  35743. */
  35744. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35745. /**
  35746. * Updates the current sounds options such as maxdistance, loop...
  35747. * @param options A JSON object containing values named as the object properties
  35748. */
  35749. updateOptions(options: ISoundOptions): void;
  35750. private _createSpatialParameters;
  35751. private _updateSpatialParameters;
  35752. /**
  35753. * Switch the panning model to HRTF:
  35754. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35756. */
  35757. switchPanningModelToHRTF(): void;
  35758. /**
  35759. * Switch the panning model to Equal Power:
  35760. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35762. */
  35763. switchPanningModelToEqualPower(): void;
  35764. private _switchPanningModel;
  35765. /**
  35766. * Connect this sound to a sound track audio node like gain...
  35767. * @param soundTrackAudioNode the sound track audio node to connect to
  35768. */
  35769. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35770. /**
  35771. * Transform this sound into a directional source
  35772. * @param coneInnerAngle Size of the inner cone in degree
  35773. * @param coneOuterAngle Size of the outer cone in degree
  35774. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35775. */
  35776. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35777. /**
  35778. * Gets or sets the inner angle for the directional cone.
  35779. */
  35780. /**
  35781. * Gets or sets the inner angle for the directional cone.
  35782. */
  35783. directionalConeInnerAngle: number;
  35784. /**
  35785. * Gets or sets the outer angle for the directional cone.
  35786. */
  35787. /**
  35788. * Gets or sets the outer angle for the directional cone.
  35789. */
  35790. directionalConeOuterAngle: number;
  35791. /**
  35792. * Sets the position of the emitter if spatial sound is enabled
  35793. * @param newPosition Defines the new posisiton
  35794. */
  35795. setPosition(newPosition: Vector3): void;
  35796. /**
  35797. * Sets the local direction of the emitter if spatial sound is enabled
  35798. * @param newLocalDirection Defines the new local direction
  35799. */
  35800. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35801. private _updateDirection;
  35802. /** @hidden */
  35803. updateDistanceFromListener(): void;
  35804. /**
  35805. * Sets a new custom attenuation function for the sound.
  35806. * @param callback Defines the function used for the attenuation
  35807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35808. */
  35809. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35810. /**
  35811. * Play the sound
  35812. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35813. * @param offset (optional) Start the sound at a specific time in seconds
  35814. * @param length (optional) Sound duration (in seconds)
  35815. */
  35816. play(time?: number, offset?: number, length?: number): void;
  35817. private _onended;
  35818. /**
  35819. * Stop the sound
  35820. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35821. */
  35822. stop(time?: number): void;
  35823. /**
  35824. * Put the sound in pause
  35825. */
  35826. pause(): void;
  35827. /**
  35828. * Sets a dedicated volume for this sounds
  35829. * @param newVolume Define the new volume of the sound
  35830. * @param time Define time for gradual change to new volume
  35831. */
  35832. setVolume(newVolume: number, time?: number): void;
  35833. /**
  35834. * Set the sound play back rate
  35835. * @param newPlaybackRate Define the playback rate the sound should be played at
  35836. */
  35837. setPlaybackRate(newPlaybackRate: number): void;
  35838. /**
  35839. * Gets the volume of the sound.
  35840. * @returns the volume of the sound
  35841. */
  35842. getVolume(): number;
  35843. /**
  35844. * Attach the sound to a dedicated mesh
  35845. * @param transformNode The transform node to connect the sound with
  35846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35847. */
  35848. attachToMesh(transformNode: TransformNode): void;
  35849. /**
  35850. * Detach the sound from the previously attached mesh
  35851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35852. */
  35853. detachFromMesh(): void;
  35854. private _onRegisterAfterWorldMatrixUpdate;
  35855. /**
  35856. * Clone the current sound in the scene.
  35857. * @returns the new sound clone
  35858. */
  35859. clone(): Nullable<Sound>;
  35860. /**
  35861. * Gets the current underlying audio buffer containing the data
  35862. * @returns the audio buffer
  35863. */
  35864. getAudioBuffer(): Nullable<AudioBuffer>;
  35865. /**
  35866. * Serializes the Sound in a JSON representation
  35867. * @returns the JSON representation of the sound
  35868. */
  35869. serialize(): any;
  35870. /**
  35871. * Parse a JSON representation of a sound to innstantiate in a given scene
  35872. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35873. * @param scene Define the scene the new parsed sound should be created in
  35874. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35875. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35876. * @returns the newly parsed sound
  35877. */
  35878. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35879. }
  35880. }
  35881. declare module "babylonjs/Actions/directAudioActions" {
  35882. import { Action } from "babylonjs/Actions/action";
  35883. import { Condition } from "babylonjs/Actions/condition";
  35884. import { Sound } from "babylonjs/Audio/sound";
  35885. /**
  35886. * This defines an action helpful to play a defined sound on a triggered action.
  35887. */
  35888. export class PlaySoundAction extends Action {
  35889. private _sound;
  35890. /**
  35891. * Instantiate the action
  35892. * @param triggerOptions defines the trigger options
  35893. * @param sound defines the sound to play
  35894. * @param condition defines the trigger related conditions
  35895. */
  35896. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35897. /** @hidden */
  35898. _prepare(): void;
  35899. /**
  35900. * Execute the action and play the sound.
  35901. */
  35902. execute(): void;
  35903. /**
  35904. * Serializes the actions and its related information.
  35905. * @param parent defines the object to serialize in
  35906. * @returns the serialized object
  35907. */
  35908. serialize(parent: any): any;
  35909. }
  35910. /**
  35911. * This defines an action helpful to stop a defined sound on a triggered action.
  35912. */
  35913. export class StopSoundAction extends Action {
  35914. private _sound;
  35915. /**
  35916. * Instantiate the action
  35917. * @param triggerOptions defines the trigger options
  35918. * @param sound defines the sound to stop
  35919. * @param condition defines the trigger related conditions
  35920. */
  35921. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35922. /** @hidden */
  35923. _prepare(): void;
  35924. /**
  35925. * Execute the action and stop the sound.
  35926. */
  35927. execute(): void;
  35928. /**
  35929. * Serializes the actions and its related information.
  35930. * @param parent defines the object to serialize in
  35931. * @returns the serialized object
  35932. */
  35933. serialize(parent: any): any;
  35934. }
  35935. }
  35936. declare module "babylonjs/Actions/interpolateValueAction" {
  35937. import { Action } from "babylonjs/Actions/action";
  35938. import { Condition } from "babylonjs/Actions/condition";
  35939. import { Observable } from "babylonjs/Misc/observable";
  35940. /**
  35941. * This defines an action responsible to change the value of a property
  35942. * by interpolating between its current value and the newly set one once triggered.
  35943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35944. */
  35945. export class InterpolateValueAction extends Action {
  35946. /**
  35947. * Defines the path of the property where the value should be interpolated
  35948. */
  35949. propertyPath: string;
  35950. /**
  35951. * Defines the target value at the end of the interpolation.
  35952. */
  35953. value: any;
  35954. /**
  35955. * Defines the time it will take for the property to interpolate to the value.
  35956. */
  35957. duration: number;
  35958. /**
  35959. * Defines if the other scene animations should be stopped when the action has been triggered
  35960. */
  35961. stopOtherAnimations?: boolean;
  35962. /**
  35963. * Defines a callback raised once the interpolation animation has been done.
  35964. */
  35965. onInterpolationDone?: () => void;
  35966. /**
  35967. * Observable triggered once the interpolation animation has been done.
  35968. */
  35969. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35970. private _target;
  35971. private _effectiveTarget;
  35972. private _property;
  35973. /**
  35974. * Instantiate the action
  35975. * @param triggerOptions defines the trigger options
  35976. * @param target defines the object containing the value to interpolate
  35977. * @param propertyPath defines the path to the property in the target object
  35978. * @param value defines the target value at the end of the interpolation
  35979. * @param duration deines the time it will take for the property to interpolate to the value.
  35980. * @param condition defines the trigger related conditions
  35981. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35982. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35983. */
  35984. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35985. /** @hidden */
  35986. _prepare(): void;
  35987. /**
  35988. * Execute the action starts the value interpolation.
  35989. */
  35990. execute(): void;
  35991. /**
  35992. * Serializes the actions and its related information.
  35993. * @param parent defines the object to serialize in
  35994. * @returns the serialized object
  35995. */
  35996. serialize(parent: any): any;
  35997. }
  35998. }
  35999. declare module "babylonjs/Actions/index" {
  36000. export * from "babylonjs/Actions/action";
  36001. export * from "babylonjs/Actions/actionEvent";
  36002. export * from "babylonjs/Actions/actionManager";
  36003. export * from "babylonjs/Actions/condition";
  36004. export * from "babylonjs/Actions/directActions";
  36005. export * from "babylonjs/Actions/directAudioActions";
  36006. export * from "babylonjs/Actions/interpolateValueAction";
  36007. }
  36008. declare module "babylonjs/Animations/index" {
  36009. export * from "babylonjs/Animations/animatable";
  36010. export * from "babylonjs/Animations/animation";
  36011. export * from "babylonjs/Animations/animationGroup";
  36012. export * from "babylonjs/Animations/animationPropertiesOverride";
  36013. export * from "babylonjs/Animations/easing";
  36014. export * from "babylonjs/Animations/runtimeAnimation";
  36015. export * from "babylonjs/Animations/animationEvent";
  36016. export * from "babylonjs/Animations/animationGroup";
  36017. export * from "babylonjs/Animations/animationKey";
  36018. export * from "babylonjs/Animations/animationRange";
  36019. export * from "babylonjs/Animations/animatable.interface";
  36020. }
  36021. declare module "babylonjs/Audio/soundTrack" {
  36022. import { Sound } from "babylonjs/Audio/sound";
  36023. import { Analyser } from "babylonjs/Audio/analyser";
  36024. import { Scene } from "babylonjs/scene";
  36025. /**
  36026. * Options allowed during the creation of a sound track.
  36027. */
  36028. export interface ISoundTrackOptions {
  36029. /**
  36030. * The volume the sound track should take during creation
  36031. */
  36032. volume?: number;
  36033. /**
  36034. * Define if the sound track is the main sound track of the scene
  36035. */
  36036. mainTrack?: boolean;
  36037. }
  36038. /**
  36039. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36040. * It will be also used in a future release to apply effects on a specific track.
  36041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36042. */
  36043. export class SoundTrack {
  36044. /**
  36045. * The unique identifier of the sound track in the scene.
  36046. */
  36047. id: number;
  36048. /**
  36049. * The list of sounds included in the sound track.
  36050. */
  36051. soundCollection: Array<Sound>;
  36052. private _outputAudioNode;
  36053. private _scene;
  36054. private _isMainTrack;
  36055. private _connectedAnalyser;
  36056. private _options;
  36057. private _isInitialized;
  36058. /**
  36059. * Creates a new sound track.
  36060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36061. * @param scene Define the scene the sound track belongs to
  36062. * @param options
  36063. */
  36064. constructor(scene: Scene, options?: ISoundTrackOptions);
  36065. private _initializeSoundTrackAudioGraph;
  36066. /**
  36067. * Release the sound track and its associated resources
  36068. */
  36069. dispose(): void;
  36070. /**
  36071. * Adds a sound to this sound track
  36072. * @param sound define the cound to add
  36073. * @ignoreNaming
  36074. */
  36075. AddSound(sound: Sound): void;
  36076. /**
  36077. * Removes a sound to this sound track
  36078. * @param sound define the cound to remove
  36079. * @ignoreNaming
  36080. */
  36081. RemoveSound(sound: Sound): void;
  36082. /**
  36083. * Set a global volume for the full sound track.
  36084. * @param newVolume Define the new volume of the sound track
  36085. */
  36086. setVolume(newVolume: number): void;
  36087. /**
  36088. * Switch the panning model to HRTF:
  36089. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36091. */
  36092. switchPanningModelToHRTF(): void;
  36093. /**
  36094. * Switch the panning model to Equal Power:
  36095. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36097. */
  36098. switchPanningModelToEqualPower(): void;
  36099. /**
  36100. * Connect the sound track to an audio analyser allowing some amazing
  36101. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36103. * @param analyser The analyser to connect to the engine
  36104. */
  36105. connectToAnalyser(analyser: Analyser): void;
  36106. }
  36107. }
  36108. declare module "babylonjs/Audio/audioSceneComponent" {
  36109. import { Sound } from "babylonjs/Audio/sound";
  36110. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36111. import { Nullable } from "babylonjs/types";
  36112. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36113. import { Scene } from "babylonjs/scene";
  36114. import { AbstractScene } from "babylonjs/abstractScene";
  36115. import "babylonjs/Audio/audioEngine";
  36116. module "babylonjs/abstractScene" {
  36117. interface AbstractScene {
  36118. /**
  36119. * The list of sounds used in the scene.
  36120. */
  36121. sounds: Nullable<Array<Sound>>;
  36122. }
  36123. }
  36124. module "babylonjs/scene" {
  36125. interface Scene {
  36126. /**
  36127. * @hidden
  36128. * Backing field
  36129. */
  36130. _mainSoundTrack: SoundTrack;
  36131. /**
  36132. * The main sound track played by the scene.
  36133. * It cotains your primary collection of sounds.
  36134. */
  36135. mainSoundTrack: SoundTrack;
  36136. /**
  36137. * The list of sound tracks added to the scene
  36138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36139. */
  36140. soundTracks: Nullable<Array<SoundTrack>>;
  36141. /**
  36142. * Gets a sound using a given name
  36143. * @param name defines the name to search for
  36144. * @return the found sound or null if not found at all.
  36145. */
  36146. getSoundByName(name: string): Nullable<Sound>;
  36147. /**
  36148. * Gets or sets if audio support is enabled
  36149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36150. */
  36151. audioEnabled: boolean;
  36152. /**
  36153. * Gets or sets if audio will be output to headphones
  36154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36155. */
  36156. headphone: boolean;
  36157. }
  36158. }
  36159. /**
  36160. * Defines the sound scene component responsible to manage any sounds
  36161. * in a given scene.
  36162. */
  36163. export class AudioSceneComponent implements ISceneSerializableComponent {
  36164. /**
  36165. * The component name helpfull to identify the component in the list of scene components.
  36166. */
  36167. readonly name: string;
  36168. /**
  36169. * The scene the component belongs to.
  36170. */
  36171. scene: Scene;
  36172. private _audioEnabled;
  36173. /**
  36174. * Gets whether audio is enabled or not.
  36175. * Please use related enable/disable method to switch state.
  36176. */
  36177. readonly audioEnabled: boolean;
  36178. private _headphone;
  36179. /**
  36180. * Gets whether audio is outputing to headphone or not.
  36181. * Please use the according Switch methods to change output.
  36182. */
  36183. readonly headphone: boolean;
  36184. /**
  36185. * Creates a new instance of the component for the given scene
  36186. * @param scene Defines the scene to register the component in
  36187. */
  36188. constructor(scene: Scene);
  36189. /**
  36190. * Registers the component in a given scene
  36191. */
  36192. register(): void;
  36193. /**
  36194. * Rebuilds the elements related to this component in case of
  36195. * context lost for instance.
  36196. */
  36197. rebuild(): void;
  36198. /**
  36199. * Serializes the component data to the specified json object
  36200. * @param serializationObject The object to serialize to
  36201. */
  36202. serialize(serializationObject: any): void;
  36203. /**
  36204. * Adds all the elements from the container to the scene
  36205. * @param container the container holding the elements
  36206. */
  36207. addFromContainer(container: AbstractScene): void;
  36208. /**
  36209. * Removes all the elements in the container from the scene
  36210. * @param container contains the elements to remove
  36211. * @param dispose if the removed element should be disposed (default: false)
  36212. */
  36213. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36214. /**
  36215. * Disposes the component and the associated ressources.
  36216. */
  36217. dispose(): void;
  36218. /**
  36219. * Disables audio in the associated scene.
  36220. */
  36221. disableAudio(): void;
  36222. /**
  36223. * Enables audio in the associated scene.
  36224. */
  36225. enableAudio(): void;
  36226. /**
  36227. * Switch audio to headphone output.
  36228. */
  36229. switchAudioModeForHeadphones(): void;
  36230. /**
  36231. * Switch audio to normal speakers.
  36232. */
  36233. switchAudioModeForNormalSpeakers(): void;
  36234. private _afterRender;
  36235. }
  36236. }
  36237. declare module "babylonjs/Audio/weightedsound" {
  36238. import { Sound } from "babylonjs/Audio/sound";
  36239. /**
  36240. * Wraps one or more Sound objects and selects one with random weight for playback.
  36241. */
  36242. export class WeightedSound {
  36243. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36244. loop: boolean;
  36245. private _coneInnerAngle;
  36246. private _coneOuterAngle;
  36247. private _volume;
  36248. /** A Sound is currently playing. */
  36249. isPlaying: boolean;
  36250. /** A Sound is currently paused. */
  36251. isPaused: boolean;
  36252. private _sounds;
  36253. private _weights;
  36254. private _currentIndex?;
  36255. /**
  36256. * Creates a new WeightedSound from the list of sounds given.
  36257. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36258. * @param sounds Array of Sounds that will be selected from.
  36259. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36260. */
  36261. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36262. /**
  36263. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36264. */
  36265. /**
  36266. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36267. */
  36268. directionalConeInnerAngle: number;
  36269. /**
  36270. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36271. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36272. */
  36273. /**
  36274. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36275. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36276. */
  36277. directionalConeOuterAngle: number;
  36278. /**
  36279. * Playback volume.
  36280. */
  36281. /**
  36282. * Playback volume.
  36283. */
  36284. volume: number;
  36285. private _onended;
  36286. /**
  36287. * Suspend playback
  36288. */
  36289. pause(): void;
  36290. /**
  36291. * Stop playback
  36292. */
  36293. stop(): void;
  36294. /**
  36295. * Start playback.
  36296. * @param startOffset Position the clip head at a specific time in seconds.
  36297. */
  36298. play(startOffset?: number): void;
  36299. }
  36300. }
  36301. declare module "babylonjs/Audio/index" {
  36302. export * from "babylonjs/Audio/analyser";
  36303. export * from "babylonjs/Audio/audioEngine";
  36304. export * from "babylonjs/Audio/audioSceneComponent";
  36305. export * from "babylonjs/Audio/sound";
  36306. export * from "babylonjs/Audio/soundTrack";
  36307. export * from "babylonjs/Audio/weightedsound";
  36308. }
  36309. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36310. import { Behavior } from "babylonjs/Behaviors/behavior";
  36311. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36312. import { BackEase } from "babylonjs/Animations/easing";
  36313. /**
  36314. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36315. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36316. */
  36317. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36318. /**
  36319. * Gets the name of the behavior.
  36320. */
  36321. readonly name: string;
  36322. /**
  36323. * The easing function used by animations
  36324. */
  36325. static EasingFunction: BackEase;
  36326. /**
  36327. * The easing mode used by animations
  36328. */
  36329. static EasingMode: number;
  36330. /**
  36331. * The duration of the animation, in milliseconds
  36332. */
  36333. transitionDuration: number;
  36334. /**
  36335. * Length of the distance animated by the transition when lower radius is reached
  36336. */
  36337. lowerRadiusTransitionRange: number;
  36338. /**
  36339. * Length of the distance animated by the transition when upper radius is reached
  36340. */
  36341. upperRadiusTransitionRange: number;
  36342. private _autoTransitionRange;
  36343. /**
  36344. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36345. */
  36346. /**
  36347. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36348. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36349. */
  36350. autoTransitionRange: boolean;
  36351. private _attachedCamera;
  36352. private _onAfterCheckInputsObserver;
  36353. private _onMeshTargetChangedObserver;
  36354. /**
  36355. * Initializes the behavior.
  36356. */
  36357. init(): void;
  36358. /**
  36359. * Attaches the behavior to its arc rotate camera.
  36360. * @param camera Defines the camera to attach the behavior to
  36361. */
  36362. attach(camera: ArcRotateCamera): void;
  36363. /**
  36364. * Detaches the behavior from its current arc rotate camera.
  36365. */
  36366. detach(): void;
  36367. private _radiusIsAnimating;
  36368. private _radiusBounceTransition;
  36369. private _animatables;
  36370. private _cachedWheelPrecision;
  36371. /**
  36372. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36373. * @param radiusLimit The limit to check against.
  36374. * @return Bool to indicate if at limit.
  36375. */
  36376. private _isRadiusAtLimit;
  36377. /**
  36378. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36379. * @param radiusDelta The delta by which to animate to. Can be negative.
  36380. */
  36381. private _applyBoundRadiusAnimation;
  36382. /**
  36383. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36384. */
  36385. protected _clearAnimationLocks(): void;
  36386. /**
  36387. * Stops and removes all animations that have been applied to the camera
  36388. */
  36389. stopAllAnimations(): void;
  36390. }
  36391. }
  36392. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36393. import { Behavior } from "babylonjs/Behaviors/behavior";
  36394. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36395. import { ExponentialEase } from "babylonjs/Animations/easing";
  36396. import { Nullable } from "babylonjs/types";
  36397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36398. import { Vector3 } from "babylonjs/Maths/math.vector";
  36399. /**
  36400. * 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.
  36401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36402. */
  36403. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36404. /**
  36405. * Gets the name of the behavior.
  36406. */
  36407. readonly name: string;
  36408. private _mode;
  36409. private _radiusScale;
  36410. private _positionScale;
  36411. private _defaultElevation;
  36412. private _elevationReturnTime;
  36413. private _elevationReturnWaitTime;
  36414. private _zoomStopsAnimation;
  36415. private _framingTime;
  36416. /**
  36417. * The easing function used by animations
  36418. */
  36419. static EasingFunction: ExponentialEase;
  36420. /**
  36421. * The easing mode used by animations
  36422. */
  36423. static EasingMode: number;
  36424. /**
  36425. * Sets the current mode used by the behavior
  36426. */
  36427. /**
  36428. * Gets current mode used by the behavior.
  36429. */
  36430. mode: number;
  36431. /**
  36432. * Sets the scale applied to the radius (1 by default)
  36433. */
  36434. /**
  36435. * Gets the scale applied to the radius
  36436. */
  36437. radiusScale: number;
  36438. /**
  36439. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36440. */
  36441. /**
  36442. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36443. */
  36444. positionScale: number;
  36445. /**
  36446. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36447. * behaviour is triggered, in radians.
  36448. */
  36449. /**
  36450. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36451. * behaviour is triggered, in radians.
  36452. */
  36453. defaultElevation: number;
  36454. /**
  36455. * Sets the time (in milliseconds) taken to return to the default beta position.
  36456. * Negative value indicates camera should not return to default.
  36457. */
  36458. /**
  36459. * Gets the time (in milliseconds) taken to return to the default beta position.
  36460. * Negative value indicates camera should not return to default.
  36461. */
  36462. elevationReturnTime: number;
  36463. /**
  36464. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36465. */
  36466. /**
  36467. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36468. */
  36469. elevationReturnWaitTime: number;
  36470. /**
  36471. * Sets the flag that indicates if user zooming should stop animation.
  36472. */
  36473. /**
  36474. * Gets the flag that indicates if user zooming should stop animation.
  36475. */
  36476. zoomStopsAnimation: boolean;
  36477. /**
  36478. * Sets the transition time when framing the mesh, in milliseconds
  36479. */
  36480. /**
  36481. * Gets the transition time when framing the mesh, in milliseconds
  36482. */
  36483. framingTime: number;
  36484. /**
  36485. * Define if the behavior should automatically change the configured
  36486. * camera limits and sensibilities.
  36487. */
  36488. autoCorrectCameraLimitsAndSensibility: boolean;
  36489. private _onPrePointerObservableObserver;
  36490. private _onAfterCheckInputsObserver;
  36491. private _onMeshTargetChangedObserver;
  36492. private _attachedCamera;
  36493. private _isPointerDown;
  36494. private _lastInteractionTime;
  36495. /**
  36496. * Initializes the behavior.
  36497. */
  36498. init(): void;
  36499. /**
  36500. * Attaches the behavior to its arc rotate camera.
  36501. * @param camera Defines the camera to attach the behavior to
  36502. */
  36503. attach(camera: ArcRotateCamera): void;
  36504. /**
  36505. * Detaches the behavior from its current arc rotate camera.
  36506. */
  36507. detach(): void;
  36508. private _animatables;
  36509. private _betaIsAnimating;
  36510. private _betaTransition;
  36511. private _radiusTransition;
  36512. private _vectorTransition;
  36513. /**
  36514. * Targets the given mesh and updates zoom level accordingly.
  36515. * @param mesh The mesh to target.
  36516. * @param radius Optional. If a cached radius position already exists, overrides default.
  36517. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36518. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36519. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36520. */
  36521. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36522. /**
  36523. * Targets the given mesh with its children and updates zoom level accordingly.
  36524. * @param mesh The mesh to target.
  36525. * @param radius Optional. If a cached radius position already exists, overrides default.
  36526. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36527. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36528. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36529. */
  36530. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36531. /**
  36532. * Targets the given meshes with their children and updates zoom level accordingly.
  36533. * @param meshes The mesh to target.
  36534. * @param radius Optional. If a cached radius position already exists, overrides default.
  36535. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36538. */
  36539. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36540. /**
  36541. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36542. * @param minimumWorld Determines the smaller position of the bounding box extend
  36543. * @param maximumWorld Determines the bigger position of the bounding box extend
  36544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36546. */
  36547. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36548. /**
  36549. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36550. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36551. * frustum width.
  36552. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36553. * to fully enclose the mesh in the viewing frustum.
  36554. */
  36555. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36556. /**
  36557. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36558. * is automatically returned to its default position (expected to be above ground plane).
  36559. */
  36560. private _maintainCameraAboveGround;
  36561. /**
  36562. * Returns the frustum slope based on the canvas ratio and camera FOV
  36563. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36564. */
  36565. private _getFrustumSlope;
  36566. /**
  36567. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36568. */
  36569. private _clearAnimationLocks;
  36570. /**
  36571. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36572. */
  36573. private _applyUserInteraction;
  36574. /**
  36575. * Stops and removes all animations that have been applied to the camera
  36576. */
  36577. stopAllAnimations(): void;
  36578. /**
  36579. * Gets a value indicating if the user is moving the camera
  36580. */
  36581. readonly isUserIsMoving: boolean;
  36582. /**
  36583. * The camera can move all the way towards the mesh.
  36584. */
  36585. static IgnoreBoundsSizeMode: number;
  36586. /**
  36587. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36588. */
  36589. static FitFrustumSidesMode: number;
  36590. }
  36591. }
  36592. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36593. import { Nullable } from "babylonjs/types";
  36594. import { Camera } from "babylonjs/Cameras/camera";
  36595. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36596. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36597. /**
  36598. * Base class for Camera Pointer Inputs.
  36599. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36600. * for example usage.
  36601. */
  36602. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36603. /**
  36604. * Defines the camera the input is attached to.
  36605. */
  36606. abstract camera: Camera;
  36607. /**
  36608. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36609. */
  36610. protected _altKey: boolean;
  36611. protected _ctrlKey: boolean;
  36612. protected _metaKey: boolean;
  36613. protected _shiftKey: boolean;
  36614. /**
  36615. * Which mouse buttons were pressed at time of last mouse event.
  36616. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36617. */
  36618. protected _buttonsPressed: number;
  36619. /**
  36620. * Defines the buttons associated with the input to handle camera move.
  36621. */
  36622. buttons: number[];
  36623. /**
  36624. * Attach the input controls to a specific dom element to get the input from.
  36625. * @param element Defines the element the controls should be listened from
  36626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36627. */
  36628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36629. /**
  36630. * Detach the current controls from the specified dom element.
  36631. * @param element Defines the element to stop listening the inputs from
  36632. */
  36633. detachControl(element: Nullable<HTMLElement>): void;
  36634. /**
  36635. * Gets the class name of the current input.
  36636. * @returns the class name
  36637. */
  36638. getClassName(): string;
  36639. /**
  36640. * Get the friendly name associated with the input class.
  36641. * @returns the input friendly name
  36642. */
  36643. getSimpleName(): string;
  36644. /**
  36645. * Called on pointer POINTERDOUBLETAP event.
  36646. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36647. */
  36648. protected onDoubleTap(type: string): void;
  36649. /**
  36650. * Called on pointer POINTERMOVE event if only a single touch is active.
  36651. * Override this method to provide functionality.
  36652. */
  36653. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36654. /**
  36655. * Called on pointer POINTERMOVE event if multiple touches are active.
  36656. * Override this method to provide functionality.
  36657. */
  36658. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36659. /**
  36660. * Called on JS contextmenu event.
  36661. * Override this method to provide functionality.
  36662. */
  36663. protected onContextMenu(evt: PointerEvent): void;
  36664. /**
  36665. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36666. * press.
  36667. * Override this method to provide functionality.
  36668. */
  36669. protected onButtonDown(evt: PointerEvent): void;
  36670. /**
  36671. * Called each time a new POINTERUP event occurs. Ie, for each button
  36672. * release.
  36673. * Override this method to provide functionality.
  36674. */
  36675. protected onButtonUp(evt: PointerEvent): void;
  36676. /**
  36677. * Called when window becomes inactive.
  36678. * Override this method to provide functionality.
  36679. */
  36680. protected onLostFocus(): void;
  36681. private _pointerInput;
  36682. private _observer;
  36683. private _onLostFocus;
  36684. private pointA;
  36685. private pointB;
  36686. }
  36687. }
  36688. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36689. import { Nullable } from "babylonjs/types";
  36690. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36691. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36692. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36693. /**
  36694. * Manage the pointers inputs to control an arc rotate camera.
  36695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36696. */
  36697. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36698. /**
  36699. * Defines the camera the input is attached to.
  36700. */
  36701. camera: ArcRotateCamera;
  36702. /**
  36703. * Gets the class name of the current input.
  36704. * @returns the class name
  36705. */
  36706. getClassName(): string;
  36707. /**
  36708. * Defines the buttons associated with the input to handle camera move.
  36709. */
  36710. buttons: number[];
  36711. /**
  36712. * Defines the pointer angular sensibility along the X axis or how fast is
  36713. * the camera rotating.
  36714. */
  36715. angularSensibilityX: number;
  36716. /**
  36717. * Defines the pointer angular sensibility along the Y axis or how fast is
  36718. * the camera rotating.
  36719. */
  36720. angularSensibilityY: number;
  36721. /**
  36722. * Defines the pointer pinch precision or how fast is the camera zooming.
  36723. */
  36724. pinchPrecision: number;
  36725. /**
  36726. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36727. * from 0.
  36728. * It defines the percentage of current camera.radius to use as delta when
  36729. * pinch zoom is used.
  36730. */
  36731. pinchDeltaPercentage: number;
  36732. /**
  36733. * Defines the pointer panning sensibility or how fast is the camera moving.
  36734. */
  36735. panningSensibility: number;
  36736. /**
  36737. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36738. */
  36739. multiTouchPanning: boolean;
  36740. /**
  36741. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36742. * zoom (pinch) through multitouch.
  36743. */
  36744. multiTouchPanAndZoom: boolean;
  36745. /**
  36746. * Revers pinch action direction.
  36747. */
  36748. pinchInwards: boolean;
  36749. private _isPanClick;
  36750. private _twoFingerActivityCount;
  36751. private _isPinching;
  36752. /**
  36753. * Called on pointer POINTERMOVE event if only a single touch is active.
  36754. */
  36755. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36756. /**
  36757. * Called on pointer POINTERDOUBLETAP event.
  36758. */
  36759. protected onDoubleTap(type: string): void;
  36760. /**
  36761. * Called on pointer POINTERMOVE event if multiple touches are active.
  36762. */
  36763. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36764. /**
  36765. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36766. * press.
  36767. */
  36768. protected onButtonDown(evt: PointerEvent): void;
  36769. /**
  36770. * Called each time a new POINTERUP event occurs. Ie, for each button
  36771. * release.
  36772. */
  36773. protected onButtonUp(evt: PointerEvent): void;
  36774. /**
  36775. * Called when window becomes inactive.
  36776. */
  36777. protected onLostFocus(): void;
  36778. }
  36779. }
  36780. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36781. import { Nullable } from "babylonjs/types";
  36782. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36783. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36784. /**
  36785. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36787. */
  36788. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36789. /**
  36790. * Defines the camera the input is attached to.
  36791. */
  36792. camera: ArcRotateCamera;
  36793. /**
  36794. * Defines the list of key codes associated with the up action (increase alpha)
  36795. */
  36796. keysUp: number[];
  36797. /**
  36798. * Defines the list of key codes associated with the down action (decrease alpha)
  36799. */
  36800. keysDown: number[];
  36801. /**
  36802. * Defines the list of key codes associated with the left action (increase beta)
  36803. */
  36804. keysLeft: number[];
  36805. /**
  36806. * Defines the list of key codes associated with the right action (decrease beta)
  36807. */
  36808. keysRight: number[];
  36809. /**
  36810. * Defines the list of key codes associated with the reset action.
  36811. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36812. */
  36813. keysReset: number[];
  36814. /**
  36815. * Defines the panning sensibility of the inputs.
  36816. * (How fast is the camera paning)
  36817. */
  36818. panningSensibility: number;
  36819. /**
  36820. * Defines the zooming sensibility of the inputs.
  36821. * (How fast is the camera zooming)
  36822. */
  36823. zoomingSensibility: number;
  36824. /**
  36825. * Defines wether maintaining the alt key down switch the movement mode from
  36826. * orientation to zoom.
  36827. */
  36828. useAltToZoom: boolean;
  36829. /**
  36830. * Rotation speed of the camera
  36831. */
  36832. angularSpeed: number;
  36833. private _keys;
  36834. private _ctrlPressed;
  36835. private _altPressed;
  36836. private _onCanvasBlurObserver;
  36837. private _onKeyboardObserver;
  36838. private _engine;
  36839. private _scene;
  36840. /**
  36841. * Attach the input controls to a specific dom element to get the input from.
  36842. * @param element Defines the element the controls should be listened from
  36843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36844. */
  36845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36846. /**
  36847. * Detach the current controls from the specified dom element.
  36848. * @param element Defines the element to stop listening the inputs from
  36849. */
  36850. detachControl(element: Nullable<HTMLElement>): void;
  36851. /**
  36852. * Update the current camera state depending on the inputs that have been used this frame.
  36853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36854. */
  36855. checkInputs(): void;
  36856. /**
  36857. * Gets the class name of the current intput.
  36858. * @returns the class name
  36859. */
  36860. getClassName(): string;
  36861. /**
  36862. * Get the friendly name associated with the input class.
  36863. * @returns the input friendly name
  36864. */
  36865. getSimpleName(): string;
  36866. }
  36867. }
  36868. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36869. import { Nullable } from "babylonjs/types";
  36870. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36871. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36872. /**
  36873. * Manage the mouse wheel inputs to control an arc rotate camera.
  36874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36875. */
  36876. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36877. /**
  36878. * Defines the camera the input is attached to.
  36879. */
  36880. camera: ArcRotateCamera;
  36881. /**
  36882. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36883. */
  36884. wheelPrecision: number;
  36885. /**
  36886. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36887. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36888. */
  36889. wheelDeltaPercentage: number;
  36890. private _wheel;
  36891. private _observer;
  36892. private computeDeltaFromMouseWheelLegacyEvent;
  36893. /**
  36894. * Attach the input controls to a specific dom element to get the input from.
  36895. * @param element Defines the element the controls should be listened from
  36896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36897. */
  36898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36899. /**
  36900. * Detach the current controls from the specified dom element.
  36901. * @param element Defines the element to stop listening the inputs from
  36902. */
  36903. detachControl(element: Nullable<HTMLElement>): void;
  36904. /**
  36905. * Gets the class name of the current intput.
  36906. * @returns the class name
  36907. */
  36908. getClassName(): string;
  36909. /**
  36910. * Get the friendly name associated with the input class.
  36911. * @returns the input friendly name
  36912. */
  36913. getSimpleName(): string;
  36914. }
  36915. }
  36916. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36918. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36919. /**
  36920. * Default Inputs manager for the ArcRotateCamera.
  36921. * It groups all the default supported inputs for ease of use.
  36922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36923. */
  36924. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36925. /**
  36926. * Instantiates a new ArcRotateCameraInputsManager.
  36927. * @param camera Defines the camera the inputs belong to
  36928. */
  36929. constructor(camera: ArcRotateCamera);
  36930. /**
  36931. * Add mouse wheel input support to the input manager.
  36932. * @returns the current input manager
  36933. */
  36934. addMouseWheel(): ArcRotateCameraInputsManager;
  36935. /**
  36936. * Add pointers input support to the input manager.
  36937. * @returns the current input manager
  36938. */
  36939. addPointers(): ArcRotateCameraInputsManager;
  36940. /**
  36941. * Add keyboard input support to the input manager.
  36942. * @returns the current input manager
  36943. */
  36944. addKeyboard(): ArcRotateCameraInputsManager;
  36945. }
  36946. }
  36947. declare module "babylonjs/Cameras/arcRotateCamera" {
  36948. import { Observable } from "babylonjs/Misc/observable";
  36949. import { Nullable } from "babylonjs/types";
  36950. import { Scene } from "babylonjs/scene";
  36951. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36953. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36954. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36955. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36956. import { Camera } from "babylonjs/Cameras/camera";
  36957. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36958. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36959. import { Collider } from "babylonjs/Collisions/collider";
  36960. /**
  36961. * This represents an orbital type of camera.
  36962. *
  36963. * 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.
  36964. * 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.
  36965. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36966. */
  36967. export class ArcRotateCamera extends TargetCamera {
  36968. /**
  36969. * Defines the rotation angle of the camera along the longitudinal axis.
  36970. */
  36971. alpha: number;
  36972. /**
  36973. * Defines the rotation angle of the camera along the latitudinal axis.
  36974. */
  36975. beta: number;
  36976. /**
  36977. * Defines the radius of the camera from it s target point.
  36978. */
  36979. radius: number;
  36980. protected _target: Vector3;
  36981. protected _targetHost: Nullable<AbstractMesh>;
  36982. /**
  36983. * Defines the target point of the camera.
  36984. * The camera looks towards it form the radius distance.
  36985. */
  36986. target: Vector3;
  36987. /**
  36988. * Define the current local position of the camera in the scene
  36989. */
  36990. position: Vector3;
  36991. protected _upVector: Vector3;
  36992. protected _upToYMatrix: Matrix;
  36993. protected _YToUpMatrix: Matrix;
  36994. /**
  36995. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36996. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36997. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36998. */
  36999. upVector: Vector3;
  37000. /**
  37001. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37002. */
  37003. setMatUp(): void;
  37004. /**
  37005. * Current inertia value on the longitudinal axis.
  37006. * The bigger this number the longer it will take for the camera to stop.
  37007. */
  37008. inertialAlphaOffset: number;
  37009. /**
  37010. * Current inertia value on the latitudinal axis.
  37011. * The bigger this number the longer it will take for the camera to stop.
  37012. */
  37013. inertialBetaOffset: number;
  37014. /**
  37015. * Current inertia value on the radius axis.
  37016. * The bigger this number the longer it will take for the camera to stop.
  37017. */
  37018. inertialRadiusOffset: number;
  37019. /**
  37020. * Minimum allowed angle on the longitudinal axis.
  37021. * This can help limiting how the Camera is able to move in the scene.
  37022. */
  37023. lowerAlphaLimit: Nullable<number>;
  37024. /**
  37025. * Maximum allowed angle on the longitudinal axis.
  37026. * This can help limiting how the Camera is able to move in the scene.
  37027. */
  37028. upperAlphaLimit: Nullable<number>;
  37029. /**
  37030. * Minimum allowed angle on the latitudinal axis.
  37031. * This can help limiting how the Camera is able to move in the scene.
  37032. */
  37033. lowerBetaLimit: number;
  37034. /**
  37035. * Maximum allowed angle on the latitudinal axis.
  37036. * This can help limiting how the Camera is able to move in the scene.
  37037. */
  37038. upperBetaLimit: number;
  37039. /**
  37040. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37041. * This can help limiting how the Camera is able to move in the scene.
  37042. */
  37043. lowerRadiusLimit: Nullable<number>;
  37044. /**
  37045. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37046. * This can help limiting how the Camera is able to move in the scene.
  37047. */
  37048. upperRadiusLimit: Nullable<number>;
  37049. /**
  37050. * Defines the current inertia value used during panning of the camera along the X axis.
  37051. */
  37052. inertialPanningX: number;
  37053. /**
  37054. * Defines the current inertia value used during panning of the camera along the Y axis.
  37055. */
  37056. inertialPanningY: number;
  37057. /**
  37058. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37059. * Basically if your fingers moves away from more than this distance you will be considered
  37060. * in pinch mode.
  37061. */
  37062. pinchToPanMaxDistance: number;
  37063. /**
  37064. * Defines the maximum distance the camera can pan.
  37065. * This could help keeping the cammera always in your scene.
  37066. */
  37067. panningDistanceLimit: Nullable<number>;
  37068. /**
  37069. * Defines the target of the camera before paning.
  37070. */
  37071. panningOriginTarget: Vector3;
  37072. /**
  37073. * Defines the value of the inertia used during panning.
  37074. * 0 would mean stop inertia and one would mean no decelleration at all.
  37075. */
  37076. panningInertia: number;
  37077. /**
  37078. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37079. */
  37080. angularSensibilityX: number;
  37081. /**
  37082. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37083. */
  37084. angularSensibilityY: number;
  37085. /**
  37086. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37087. */
  37088. pinchPrecision: number;
  37089. /**
  37090. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37091. * It will be used instead of pinchDeltaPrecision if different from 0.
  37092. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37093. */
  37094. pinchDeltaPercentage: number;
  37095. /**
  37096. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37097. */
  37098. panningSensibility: number;
  37099. /**
  37100. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37101. */
  37102. keysUp: number[];
  37103. /**
  37104. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37105. */
  37106. keysDown: number[];
  37107. /**
  37108. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37109. */
  37110. keysLeft: number[];
  37111. /**
  37112. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37113. */
  37114. keysRight: number[];
  37115. /**
  37116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37121. * It will be used instead of pinchDeltaPrecision if different from 0.
  37122. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37123. */
  37124. wheelDeltaPercentage: number;
  37125. /**
  37126. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37127. */
  37128. zoomOnFactor: number;
  37129. /**
  37130. * Defines a screen offset for the camera position.
  37131. */
  37132. targetScreenOffset: Vector2;
  37133. /**
  37134. * Allows the camera to be completely reversed.
  37135. * If false the camera can not arrive upside down.
  37136. */
  37137. allowUpsideDown: boolean;
  37138. /**
  37139. * Define if double tap/click is used to restore the previously saved state of the camera.
  37140. */
  37141. useInputToRestoreState: boolean;
  37142. /** @hidden */
  37143. _viewMatrix: Matrix;
  37144. /** @hidden */
  37145. _useCtrlForPanning: boolean;
  37146. /** @hidden */
  37147. _panningMouseButton: number;
  37148. /**
  37149. * Defines the input associated to the camera.
  37150. */
  37151. inputs: ArcRotateCameraInputsManager;
  37152. /** @hidden */
  37153. _reset: () => void;
  37154. /**
  37155. * Defines the allowed panning axis.
  37156. */
  37157. panningAxis: Vector3;
  37158. protected _localDirection: Vector3;
  37159. protected _transformedDirection: Vector3;
  37160. private _bouncingBehavior;
  37161. /**
  37162. * Gets the bouncing behavior of the camera if it has been enabled.
  37163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37164. */
  37165. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37166. /**
  37167. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37168. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37169. */
  37170. useBouncingBehavior: boolean;
  37171. private _framingBehavior;
  37172. /**
  37173. * Gets the framing behavior of the camera if it has been enabled.
  37174. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37175. */
  37176. readonly framingBehavior: Nullable<FramingBehavior>;
  37177. /**
  37178. * Defines if the framing behavior of the camera is enabled on the camera.
  37179. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37180. */
  37181. useFramingBehavior: boolean;
  37182. private _autoRotationBehavior;
  37183. /**
  37184. * Gets the auto rotation behavior of the camera if it has been enabled.
  37185. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37186. */
  37187. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37188. /**
  37189. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37190. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37191. */
  37192. useAutoRotationBehavior: boolean;
  37193. /**
  37194. * Observable triggered when the mesh target has been changed on the camera.
  37195. */
  37196. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37197. /**
  37198. * Event raised when the camera is colliding with a mesh.
  37199. */
  37200. onCollide: (collidedMesh: AbstractMesh) => void;
  37201. /**
  37202. * Defines whether the camera should check collision with the objects oh the scene.
  37203. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37204. */
  37205. checkCollisions: boolean;
  37206. /**
  37207. * Defines the collision radius of the camera.
  37208. * This simulates a sphere around the camera.
  37209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37210. */
  37211. collisionRadius: Vector3;
  37212. protected _collider: Collider;
  37213. protected _previousPosition: Vector3;
  37214. protected _collisionVelocity: Vector3;
  37215. protected _newPosition: Vector3;
  37216. protected _previousAlpha: number;
  37217. protected _previousBeta: number;
  37218. protected _previousRadius: number;
  37219. protected _collisionTriggered: boolean;
  37220. protected _targetBoundingCenter: Nullable<Vector3>;
  37221. private _computationVector;
  37222. /**
  37223. * Instantiates a new ArcRotateCamera in a given scene
  37224. * @param name Defines the name of the camera
  37225. * @param alpha Defines the camera rotation along the logitudinal axis
  37226. * @param beta Defines the camera rotation along the latitudinal axis
  37227. * @param radius Defines the camera distance from its target
  37228. * @param target Defines the camera target
  37229. * @param scene Defines the scene the camera belongs to
  37230. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37231. */
  37232. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37233. /** @hidden */
  37234. _initCache(): void;
  37235. /** @hidden */
  37236. _updateCache(ignoreParentClass?: boolean): void;
  37237. protected _getTargetPosition(): Vector3;
  37238. private _storedAlpha;
  37239. private _storedBeta;
  37240. private _storedRadius;
  37241. private _storedTarget;
  37242. /**
  37243. * Stores the current state of the camera (alpha, beta, radius and target)
  37244. * @returns the camera itself
  37245. */
  37246. storeState(): Camera;
  37247. /**
  37248. * @hidden
  37249. * Restored camera state. You must call storeState() first
  37250. */
  37251. _restoreStateValues(): boolean;
  37252. /** @hidden */
  37253. _isSynchronizedViewMatrix(): boolean;
  37254. /**
  37255. * Attached controls to the current camera.
  37256. * @param element Defines the element the controls should be listened from
  37257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37258. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37259. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37260. */
  37261. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37262. /**
  37263. * Detach the current controls from the camera.
  37264. * The camera will stop reacting to inputs.
  37265. * @param element Defines the element to stop listening the inputs from
  37266. */
  37267. detachControl(element: HTMLElement): void;
  37268. /** @hidden */
  37269. _checkInputs(): void;
  37270. protected _checkLimits(): void;
  37271. /**
  37272. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37273. */
  37274. rebuildAnglesAndRadius(): void;
  37275. /**
  37276. * Use a position to define the current camera related information like aplha, beta and radius
  37277. * @param position Defines the position to set the camera at
  37278. */
  37279. setPosition(position: Vector3): void;
  37280. /**
  37281. * Defines the target the camera should look at.
  37282. * This will automatically adapt alpha beta and radius to fit within the new target.
  37283. * @param target Defines the new target as a Vector or a mesh
  37284. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37285. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37286. */
  37287. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37288. /** @hidden */
  37289. _getViewMatrix(): Matrix;
  37290. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37291. /**
  37292. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37293. * @param meshes Defines the mesh to zoom on
  37294. * @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)
  37295. */
  37296. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37297. /**
  37298. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37299. * The target will be changed but the radius
  37300. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37301. * @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)
  37302. */
  37303. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37304. min: Vector3;
  37305. max: Vector3;
  37306. distance: number;
  37307. }, doNotUpdateMaxZ?: boolean): void;
  37308. /**
  37309. * @override
  37310. * Override Camera.createRigCamera
  37311. */
  37312. createRigCamera(name: string, cameraIndex: number): Camera;
  37313. /**
  37314. * @hidden
  37315. * @override
  37316. * Override Camera._updateRigCameras
  37317. */
  37318. _updateRigCameras(): void;
  37319. /**
  37320. * Destroy the camera and release the current resources hold by it.
  37321. */
  37322. dispose(): void;
  37323. /**
  37324. * Gets the current object class name.
  37325. * @return the class name
  37326. */
  37327. getClassName(): string;
  37328. }
  37329. }
  37330. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37331. import { Behavior } from "babylonjs/Behaviors/behavior";
  37332. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37333. /**
  37334. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37336. */
  37337. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37338. /**
  37339. * Gets the name of the behavior.
  37340. */
  37341. readonly name: string;
  37342. private _zoomStopsAnimation;
  37343. private _idleRotationSpeed;
  37344. private _idleRotationWaitTime;
  37345. private _idleRotationSpinupTime;
  37346. /**
  37347. * Sets the flag that indicates if user zooming should stop animation.
  37348. */
  37349. /**
  37350. * Gets the flag that indicates if user zooming should stop animation.
  37351. */
  37352. zoomStopsAnimation: boolean;
  37353. /**
  37354. * Sets the default speed at which the camera rotates around the model.
  37355. */
  37356. /**
  37357. * Gets the default speed at which the camera rotates around the model.
  37358. */
  37359. idleRotationSpeed: number;
  37360. /**
  37361. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37362. */
  37363. /**
  37364. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37365. */
  37366. idleRotationWaitTime: number;
  37367. /**
  37368. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37369. */
  37370. /**
  37371. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37372. */
  37373. idleRotationSpinupTime: number;
  37374. /**
  37375. * Gets a value indicating if the camera is currently rotating because of this behavior
  37376. */
  37377. readonly rotationInProgress: boolean;
  37378. private _onPrePointerObservableObserver;
  37379. private _onAfterCheckInputsObserver;
  37380. private _attachedCamera;
  37381. private _isPointerDown;
  37382. private _lastFrameTime;
  37383. private _lastInteractionTime;
  37384. private _cameraRotationSpeed;
  37385. /**
  37386. * Initializes the behavior.
  37387. */
  37388. init(): void;
  37389. /**
  37390. * Attaches the behavior to its arc rotate camera.
  37391. * @param camera Defines the camera to attach the behavior to
  37392. */
  37393. attach(camera: ArcRotateCamera): void;
  37394. /**
  37395. * Detaches the behavior from its current arc rotate camera.
  37396. */
  37397. detach(): void;
  37398. /**
  37399. * Returns true if user is scrolling.
  37400. * @return true if user is scrolling.
  37401. */
  37402. private _userIsZooming;
  37403. private _lastFrameRadius;
  37404. private _shouldAnimationStopForInteraction;
  37405. /**
  37406. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37407. */
  37408. private _applyUserInteraction;
  37409. private _userIsMoving;
  37410. }
  37411. }
  37412. declare module "babylonjs/Behaviors/Cameras/index" {
  37413. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37414. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37415. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37416. }
  37417. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37418. import { Mesh } from "babylonjs/Meshes/mesh";
  37419. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37420. import { Behavior } from "babylonjs/Behaviors/behavior";
  37421. /**
  37422. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37423. */
  37424. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37425. private ui;
  37426. /**
  37427. * The name of the behavior
  37428. */
  37429. name: string;
  37430. /**
  37431. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37432. */
  37433. distanceAwayFromFace: number;
  37434. /**
  37435. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37436. */
  37437. distanceAwayFromBottomOfFace: number;
  37438. private _faceVectors;
  37439. private _target;
  37440. private _scene;
  37441. private _onRenderObserver;
  37442. private _tmpMatrix;
  37443. private _tmpVector;
  37444. /**
  37445. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37446. * @param ui The transform node that should be attched to the mesh
  37447. */
  37448. constructor(ui: TransformNode);
  37449. /**
  37450. * Initializes the behavior
  37451. */
  37452. init(): void;
  37453. private _closestFace;
  37454. private _zeroVector;
  37455. private _lookAtTmpMatrix;
  37456. private _lookAtToRef;
  37457. /**
  37458. * Attaches the AttachToBoxBehavior to the passed in mesh
  37459. * @param target The mesh that the specified node will be attached to
  37460. */
  37461. attach(target: Mesh): void;
  37462. /**
  37463. * Detaches the behavior from the mesh
  37464. */
  37465. detach(): void;
  37466. }
  37467. }
  37468. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37469. import { Behavior } from "babylonjs/Behaviors/behavior";
  37470. import { Mesh } from "babylonjs/Meshes/mesh";
  37471. /**
  37472. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37473. */
  37474. export class FadeInOutBehavior implements Behavior<Mesh> {
  37475. /**
  37476. * Time in milliseconds to delay before fading in (Default: 0)
  37477. */
  37478. delay: number;
  37479. /**
  37480. * Time in milliseconds for the mesh to fade in (Default: 300)
  37481. */
  37482. fadeInTime: number;
  37483. private _millisecondsPerFrame;
  37484. private _hovered;
  37485. private _hoverValue;
  37486. private _ownerNode;
  37487. /**
  37488. * Instatiates the FadeInOutBehavior
  37489. */
  37490. constructor();
  37491. /**
  37492. * The name of the behavior
  37493. */
  37494. readonly name: string;
  37495. /**
  37496. * Initializes the behavior
  37497. */
  37498. init(): void;
  37499. /**
  37500. * Attaches the fade behavior on the passed in mesh
  37501. * @param ownerNode The mesh that will be faded in/out once attached
  37502. */
  37503. attach(ownerNode: Mesh): void;
  37504. /**
  37505. * Detaches the behavior from the mesh
  37506. */
  37507. detach(): void;
  37508. /**
  37509. * Triggers the mesh to begin fading in or out
  37510. * @param value if the object should fade in or out (true to fade in)
  37511. */
  37512. fadeIn(value: boolean): void;
  37513. private _update;
  37514. private _setAllVisibility;
  37515. }
  37516. }
  37517. declare module "babylonjs/Misc/pivotTools" {
  37518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37519. /**
  37520. * Class containing a set of static utilities functions for managing Pivots
  37521. * @hidden
  37522. */
  37523. export class PivotTools {
  37524. private static _PivotCached;
  37525. private static _OldPivotPoint;
  37526. private static _PivotTranslation;
  37527. private static _PivotTmpVector;
  37528. /** @hidden */
  37529. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37530. /** @hidden */
  37531. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37532. }
  37533. }
  37534. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37535. import { Scene } from "babylonjs/scene";
  37536. import { Vector4 } from "babylonjs/Maths/math.vector";
  37537. import { Mesh } from "babylonjs/Meshes/mesh";
  37538. import { Nullable } from "babylonjs/types";
  37539. import { Plane } from "babylonjs/Maths/math.plane";
  37540. /**
  37541. * Class containing static functions to help procedurally build meshes
  37542. */
  37543. export class PlaneBuilder {
  37544. /**
  37545. * Creates a plane mesh
  37546. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37547. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37548. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37552. * @param name defines the name of the mesh
  37553. * @param options defines the options used to create the mesh
  37554. * @param scene defines the hosting scene
  37555. * @returns the plane mesh
  37556. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37557. */
  37558. static CreatePlane(name: string, options: {
  37559. size?: number;
  37560. width?: number;
  37561. height?: number;
  37562. sideOrientation?: number;
  37563. frontUVs?: Vector4;
  37564. backUVs?: Vector4;
  37565. updatable?: boolean;
  37566. sourcePlane?: Plane;
  37567. }, scene?: Nullable<Scene>): Mesh;
  37568. }
  37569. }
  37570. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37571. import { Behavior } from "babylonjs/Behaviors/behavior";
  37572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37573. import { Observable } from "babylonjs/Misc/observable";
  37574. import { Vector3 } from "babylonjs/Maths/math.vector";
  37575. import { Ray } from "babylonjs/Culling/ray";
  37576. import "babylonjs/Meshes/Builders/planeBuilder";
  37577. /**
  37578. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37579. */
  37580. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37581. private static _AnyMouseID;
  37582. /**
  37583. * Abstract mesh the behavior is set on
  37584. */
  37585. attachedNode: AbstractMesh;
  37586. private _dragPlane;
  37587. private _scene;
  37588. private _pointerObserver;
  37589. private _beforeRenderObserver;
  37590. private static _planeScene;
  37591. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37592. /**
  37593. * 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)
  37594. */
  37595. maxDragAngle: number;
  37596. /**
  37597. * @hidden
  37598. */
  37599. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37600. /**
  37601. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37602. */
  37603. currentDraggingPointerID: number;
  37604. /**
  37605. * The last position where the pointer hit the drag plane in world space
  37606. */
  37607. lastDragPosition: Vector3;
  37608. /**
  37609. * If the behavior is currently in a dragging state
  37610. */
  37611. dragging: boolean;
  37612. /**
  37613. * 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)
  37614. */
  37615. dragDeltaRatio: number;
  37616. /**
  37617. * If the drag plane orientation should be updated during the dragging (Default: true)
  37618. */
  37619. updateDragPlane: boolean;
  37620. private _debugMode;
  37621. private _moving;
  37622. /**
  37623. * Fires each time the attached mesh is dragged with the pointer
  37624. * * delta between last drag position and current drag position in world space
  37625. * * dragDistance along the drag axis
  37626. * * dragPlaneNormal normal of the current drag plane used during the drag
  37627. * * dragPlanePoint in world space where the drag intersects the drag plane
  37628. */
  37629. onDragObservable: Observable<{
  37630. delta: Vector3;
  37631. dragPlanePoint: Vector3;
  37632. dragPlaneNormal: Vector3;
  37633. dragDistance: number;
  37634. pointerId: number;
  37635. }>;
  37636. /**
  37637. * Fires each time a drag begins (eg. mouse down on mesh)
  37638. */
  37639. onDragStartObservable: Observable<{
  37640. dragPlanePoint: Vector3;
  37641. pointerId: number;
  37642. }>;
  37643. /**
  37644. * Fires each time a drag ends (eg. mouse release after drag)
  37645. */
  37646. onDragEndObservable: Observable<{
  37647. dragPlanePoint: Vector3;
  37648. pointerId: number;
  37649. }>;
  37650. /**
  37651. * If the attached mesh should be moved when dragged
  37652. */
  37653. moveAttached: boolean;
  37654. /**
  37655. * If the drag behavior will react to drag events (Default: true)
  37656. */
  37657. enabled: boolean;
  37658. /**
  37659. * If pointer events should start and release the drag (Default: true)
  37660. */
  37661. startAndReleaseDragOnPointerEvents: boolean;
  37662. /**
  37663. * If camera controls should be detached during the drag
  37664. */
  37665. detachCameraControls: boolean;
  37666. /**
  37667. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37668. */
  37669. useObjectOrienationForDragging: boolean;
  37670. private _options;
  37671. /**
  37672. * Creates a pointer drag behavior that can be attached to a mesh
  37673. * @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)
  37674. */
  37675. constructor(options?: {
  37676. dragAxis?: Vector3;
  37677. dragPlaneNormal?: Vector3;
  37678. });
  37679. /**
  37680. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37681. */
  37682. validateDrag: (targetPosition: Vector3) => boolean;
  37683. /**
  37684. * The name of the behavior
  37685. */
  37686. readonly name: string;
  37687. /**
  37688. * Initializes the behavior
  37689. */
  37690. init(): void;
  37691. private _tmpVector;
  37692. private _alternatePickedPoint;
  37693. private _worldDragAxis;
  37694. private _targetPosition;
  37695. private _attachedElement;
  37696. /**
  37697. * Attaches the drag behavior the passed in mesh
  37698. * @param ownerNode The mesh that will be dragged around once attached
  37699. */
  37700. attach(ownerNode: AbstractMesh): void;
  37701. /**
  37702. * Force relase the drag action by code.
  37703. */
  37704. releaseDrag(): void;
  37705. private _startDragRay;
  37706. private _lastPointerRay;
  37707. /**
  37708. * Simulates the start of a pointer drag event on the behavior
  37709. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37710. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37711. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37712. */
  37713. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37714. private _startDrag;
  37715. private _dragDelta;
  37716. private _moveDrag;
  37717. private _pickWithRayOnDragPlane;
  37718. private _pointA;
  37719. private _pointB;
  37720. private _pointC;
  37721. private _lineA;
  37722. private _lineB;
  37723. private _localAxis;
  37724. private _lookAt;
  37725. private _updateDragPlanePosition;
  37726. /**
  37727. * Detaches the behavior from the mesh
  37728. */
  37729. detach(): void;
  37730. }
  37731. }
  37732. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37733. import { Mesh } from "babylonjs/Meshes/mesh";
  37734. import { Behavior } from "babylonjs/Behaviors/behavior";
  37735. /**
  37736. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37737. */
  37738. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37739. private _dragBehaviorA;
  37740. private _dragBehaviorB;
  37741. private _startDistance;
  37742. private _initialScale;
  37743. private _targetScale;
  37744. private _ownerNode;
  37745. private _sceneRenderObserver;
  37746. /**
  37747. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37748. */
  37749. constructor();
  37750. /**
  37751. * The name of the behavior
  37752. */
  37753. readonly name: string;
  37754. /**
  37755. * Initializes the behavior
  37756. */
  37757. init(): void;
  37758. private _getCurrentDistance;
  37759. /**
  37760. * Attaches the scale behavior the passed in mesh
  37761. * @param ownerNode The mesh that will be scaled around once attached
  37762. */
  37763. attach(ownerNode: Mesh): void;
  37764. /**
  37765. * Detaches the behavior from the mesh
  37766. */
  37767. detach(): void;
  37768. }
  37769. }
  37770. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37771. import { Behavior } from "babylonjs/Behaviors/behavior";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { Observable } from "babylonjs/Misc/observable";
  37774. /**
  37775. * 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
  37776. */
  37777. export class SixDofDragBehavior implements Behavior<Mesh> {
  37778. private static _virtualScene;
  37779. private _ownerNode;
  37780. private _sceneRenderObserver;
  37781. private _scene;
  37782. private _targetPosition;
  37783. private _virtualOriginMesh;
  37784. private _virtualDragMesh;
  37785. private _pointerObserver;
  37786. private _moving;
  37787. private _startingOrientation;
  37788. /**
  37789. * 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)
  37790. */
  37791. private zDragFactor;
  37792. /**
  37793. * If the object should rotate to face the drag origin
  37794. */
  37795. rotateDraggedObject: boolean;
  37796. /**
  37797. * If the behavior is currently in a dragging state
  37798. */
  37799. dragging: boolean;
  37800. /**
  37801. * 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)
  37802. */
  37803. dragDeltaRatio: number;
  37804. /**
  37805. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37806. */
  37807. currentDraggingPointerID: number;
  37808. /**
  37809. * If camera controls should be detached during the drag
  37810. */
  37811. detachCameraControls: boolean;
  37812. /**
  37813. * Fires each time a drag starts
  37814. */
  37815. onDragStartObservable: Observable<{}>;
  37816. /**
  37817. * Fires each time a drag ends (eg. mouse release after drag)
  37818. */
  37819. onDragEndObservable: Observable<{}>;
  37820. /**
  37821. * 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
  37822. */
  37823. constructor();
  37824. /**
  37825. * The name of the behavior
  37826. */
  37827. readonly name: string;
  37828. /**
  37829. * Initializes the behavior
  37830. */
  37831. init(): void;
  37832. /**
  37833. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37834. */
  37835. private readonly _pointerCamera;
  37836. /**
  37837. * Attaches the scale behavior the passed in mesh
  37838. * @param ownerNode The mesh that will be scaled around once attached
  37839. */
  37840. attach(ownerNode: Mesh): void;
  37841. /**
  37842. * Detaches the behavior from the mesh
  37843. */
  37844. detach(): void;
  37845. }
  37846. }
  37847. declare module "babylonjs/Behaviors/Meshes/index" {
  37848. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37849. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37850. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37851. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37852. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37853. }
  37854. declare module "babylonjs/Behaviors/index" {
  37855. export * from "babylonjs/Behaviors/behavior";
  37856. export * from "babylonjs/Behaviors/Cameras/index";
  37857. export * from "babylonjs/Behaviors/Meshes/index";
  37858. }
  37859. declare module "babylonjs/Bones/boneIKController" {
  37860. import { Bone } from "babylonjs/Bones/bone";
  37861. import { Vector3 } from "babylonjs/Maths/math.vector";
  37862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37863. import { Nullable } from "babylonjs/types";
  37864. /**
  37865. * Class used to apply inverse kinematics to bones
  37866. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37867. */
  37868. export class BoneIKController {
  37869. private static _tmpVecs;
  37870. private static _tmpQuat;
  37871. private static _tmpMats;
  37872. /**
  37873. * Gets or sets the target mesh
  37874. */
  37875. targetMesh: AbstractMesh;
  37876. /** Gets or sets the mesh used as pole */
  37877. poleTargetMesh: AbstractMesh;
  37878. /**
  37879. * Gets or sets the bone used as pole
  37880. */
  37881. poleTargetBone: Nullable<Bone>;
  37882. /**
  37883. * Gets or sets the target position
  37884. */
  37885. targetPosition: Vector3;
  37886. /**
  37887. * Gets or sets the pole target position
  37888. */
  37889. poleTargetPosition: Vector3;
  37890. /**
  37891. * Gets or sets the pole target local offset
  37892. */
  37893. poleTargetLocalOffset: Vector3;
  37894. /**
  37895. * Gets or sets the pole angle
  37896. */
  37897. poleAngle: number;
  37898. /**
  37899. * Gets or sets the mesh associated with the controller
  37900. */
  37901. mesh: AbstractMesh;
  37902. /**
  37903. * 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)
  37904. */
  37905. slerpAmount: number;
  37906. private _bone1Quat;
  37907. private _bone1Mat;
  37908. private _bone2Ang;
  37909. private _bone1;
  37910. private _bone2;
  37911. private _bone1Length;
  37912. private _bone2Length;
  37913. private _maxAngle;
  37914. private _maxReach;
  37915. private _rightHandedSystem;
  37916. private _bendAxis;
  37917. private _slerping;
  37918. private _adjustRoll;
  37919. /**
  37920. * Gets or sets maximum allowed angle
  37921. */
  37922. maxAngle: number;
  37923. /**
  37924. * Creates a new BoneIKController
  37925. * @param mesh defines the mesh to control
  37926. * @param bone defines the bone to control
  37927. * @param options defines options to set up the controller
  37928. */
  37929. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37930. targetMesh?: AbstractMesh;
  37931. poleTargetMesh?: AbstractMesh;
  37932. poleTargetBone?: Bone;
  37933. poleTargetLocalOffset?: Vector3;
  37934. poleAngle?: number;
  37935. bendAxis?: Vector3;
  37936. maxAngle?: number;
  37937. slerpAmount?: number;
  37938. });
  37939. private _setMaxAngle;
  37940. /**
  37941. * Force the controller to update the bones
  37942. */
  37943. update(): void;
  37944. }
  37945. }
  37946. declare module "babylonjs/Bones/boneLookController" {
  37947. import { Vector3 } from "babylonjs/Maths/math.vector";
  37948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37949. import { Bone } from "babylonjs/Bones/bone";
  37950. import { Space } from "babylonjs/Maths/math.axis";
  37951. /**
  37952. * Class used to make a bone look toward a point in space
  37953. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37954. */
  37955. export class BoneLookController {
  37956. private static _tmpVecs;
  37957. private static _tmpQuat;
  37958. private static _tmpMats;
  37959. /**
  37960. * The target Vector3 that the bone will look at
  37961. */
  37962. target: Vector3;
  37963. /**
  37964. * The mesh that the bone is attached to
  37965. */
  37966. mesh: AbstractMesh;
  37967. /**
  37968. * The bone that will be looking to the target
  37969. */
  37970. bone: Bone;
  37971. /**
  37972. * The up axis of the coordinate system that is used when the bone is rotated
  37973. */
  37974. upAxis: Vector3;
  37975. /**
  37976. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37977. */
  37978. upAxisSpace: Space;
  37979. /**
  37980. * Used to make an adjustment to the yaw of the bone
  37981. */
  37982. adjustYaw: number;
  37983. /**
  37984. * Used to make an adjustment to the pitch of the bone
  37985. */
  37986. adjustPitch: number;
  37987. /**
  37988. * Used to make an adjustment to the roll of the bone
  37989. */
  37990. adjustRoll: number;
  37991. /**
  37992. * 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)
  37993. */
  37994. slerpAmount: number;
  37995. private _minYaw;
  37996. private _maxYaw;
  37997. private _minPitch;
  37998. private _maxPitch;
  37999. private _minYawSin;
  38000. private _minYawCos;
  38001. private _maxYawSin;
  38002. private _maxYawCos;
  38003. private _midYawConstraint;
  38004. private _minPitchTan;
  38005. private _maxPitchTan;
  38006. private _boneQuat;
  38007. private _slerping;
  38008. private _transformYawPitch;
  38009. private _transformYawPitchInv;
  38010. private _firstFrameSkipped;
  38011. private _yawRange;
  38012. private _fowardAxis;
  38013. /**
  38014. * Gets or sets the minimum yaw angle that the bone can look to
  38015. */
  38016. minYaw: number;
  38017. /**
  38018. * Gets or sets the maximum yaw angle that the bone can look to
  38019. */
  38020. maxYaw: number;
  38021. /**
  38022. * Gets or sets the minimum pitch angle that the bone can look to
  38023. */
  38024. minPitch: number;
  38025. /**
  38026. * Gets or sets the maximum pitch angle that the bone can look to
  38027. */
  38028. maxPitch: number;
  38029. /**
  38030. * Create a BoneLookController
  38031. * @param mesh the mesh that the bone belongs to
  38032. * @param bone the bone that will be looking to the target
  38033. * @param target the target Vector3 to look at
  38034. * @param options optional settings:
  38035. * * maxYaw: the maximum angle the bone will yaw to
  38036. * * minYaw: the minimum angle the bone will yaw to
  38037. * * maxPitch: the maximum angle the bone will pitch to
  38038. * * minPitch: the minimum angle the bone will yaw to
  38039. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38040. * * upAxis: the up axis of the coordinate system
  38041. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38042. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38043. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38044. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38045. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38046. * * adjustRoll: used to make an adjustment to the roll of the bone
  38047. **/
  38048. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38049. maxYaw?: number;
  38050. minYaw?: number;
  38051. maxPitch?: number;
  38052. minPitch?: number;
  38053. slerpAmount?: number;
  38054. upAxis?: Vector3;
  38055. upAxisSpace?: Space;
  38056. yawAxis?: Vector3;
  38057. pitchAxis?: Vector3;
  38058. adjustYaw?: number;
  38059. adjustPitch?: number;
  38060. adjustRoll?: number;
  38061. });
  38062. /**
  38063. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38064. */
  38065. update(): void;
  38066. private _getAngleDiff;
  38067. private _getAngleBetween;
  38068. private _isAngleBetween;
  38069. }
  38070. }
  38071. declare module "babylonjs/Bones/index" {
  38072. export * from "babylonjs/Bones/bone";
  38073. export * from "babylonjs/Bones/boneIKController";
  38074. export * from "babylonjs/Bones/boneLookController";
  38075. export * from "babylonjs/Bones/skeleton";
  38076. }
  38077. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38078. import { Nullable } from "babylonjs/types";
  38079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38080. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38081. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38082. /**
  38083. * Manage the gamepad inputs to control an arc rotate camera.
  38084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38085. */
  38086. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38087. /**
  38088. * Defines the camera the input is attached to.
  38089. */
  38090. camera: ArcRotateCamera;
  38091. /**
  38092. * Defines the gamepad the input is gathering event from.
  38093. */
  38094. gamepad: Nullable<Gamepad>;
  38095. /**
  38096. * Defines the gamepad rotation sensiblity.
  38097. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38098. */
  38099. gamepadRotationSensibility: number;
  38100. /**
  38101. * Defines the gamepad move sensiblity.
  38102. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38103. */
  38104. gamepadMoveSensibility: number;
  38105. private _onGamepadConnectedObserver;
  38106. private _onGamepadDisconnectedObserver;
  38107. /**
  38108. * Attach the input controls to a specific dom element to get the input from.
  38109. * @param element Defines the element the controls should be listened from
  38110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38111. */
  38112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38113. /**
  38114. * Detach the current controls from the specified dom element.
  38115. * @param element Defines the element to stop listening the inputs from
  38116. */
  38117. detachControl(element: Nullable<HTMLElement>): void;
  38118. /**
  38119. * Update the current camera state depending on the inputs that have been used this frame.
  38120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38121. */
  38122. checkInputs(): void;
  38123. /**
  38124. * Gets the class name of the current intput.
  38125. * @returns the class name
  38126. */
  38127. getClassName(): string;
  38128. /**
  38129. * Get the friendly name associated with the input class.
  38130. * @returns the input friendly name
  38131. */
  38132. getSimpleName(): string;
  38133. }
  38134. }
  38135. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38136. import { Nullable } from "babylonjs/types";
  38137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38139. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38140. interface ArcRotateCameraInputsManager {
  38141. /**
  38142. * Add orientation input support to the input manager.
  38143. * @returns the current input manager
  38144. */
  38145. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38146. }
  38147. }
  38148. /**
  38149. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38151. */
  38152. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38153. /**
  38154. * Defines the camera the input is attached to.
  38155. */
  38156. camera: ArcRotateCamera;
  38157. /**
  38158. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38159. */
  38160. alphaCorrection: number;
  38161. /**
  38162. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38163. */
  38164. gammaCorrection: number;
  38165. private _alpha;
  38166. private _gamma;
  38167. private _dirty;
  38168. private _deviceOrientationHandler;
  38169. /**
  38170. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38171. */
  38172. constructor();
  38173. /**
  38174. * Attach the input controls to a specific dom element to get the input from.
  38175. * @param element Defines the element the controls should be listened from
  38176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38177. */
  38178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38179. /** @hidden */
  38180. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38181. /**
  38182. * Update the current camera state depending on the inputs that have been used this frame.
  38183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38184. */
  38185. checkInputs(): void;
  38186. /**
  38187. * Detach the current controls from the specified dom element.
  38188. * @param element Defines the element to stop listening the inputs from
  38189. */
  38190. detachControl(element: Nullable<HTMLElement>): void;
  38191. /**
  38192. * Gets the class name of the current intput.
  38193. * @returns the class name
  38194. */
  38195. getClassName(): string;
  38196. /**
  38197. * Get the friendly name associated with the input class.
  38198. * @returns the input friendly name
  38199. */
  38200. getSimpleName(): string;
  38201. }
  38202. }
  38203. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38204. import { Nullable } from "babylonjs/types";
  38205. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38206. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38207. /**
  38208. * Listen to mouse events to control the camera.
  38209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38210. */
  38211. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38212. /**
  38213. * Defines the camera the input is attached to.
  38214. */
  38215. camera: FlyCamera;
  38216. /**
  38217. * Defines if touch is enabled. (Default is true.)
  38218. */
  38219. touchEnabled: boolean;
  38220. /**
  38221. * Defines the buttons associated with the input to handle camera rotation.
  38222. */
  38223. buttons: number[];
  38224. /**
  38225. * Assign buttons for Yaw control.
  38226. */
  38227. buttonsYaw: number[];
  38228. /**
  38229. * Assign buttons for Pitch control.
  38230. */
  38231. buttonsPitch: number[];
  38232. /**
  38233. * Assign buttons for Roll control.
  38234. */
  38235. buttonsRoll: number[];
  38236. /**
  38237. * Detect if any button is being pressed while mouse is moved.
  38238. * -1 = Mouse locked.
  38239. * 0 = Left button.
  38240. * 1 = Middle Button.
  38241. * 2 = Right Button.
  38242. */
  38243. activeButton: number;
  38244. /**
  38245. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38246. * Higher values reduce its sensitivity.
  38247. */
  38248. angularSensibility: number;
  38249. private _mousemoveCallback;
  38250. private _observer;
  38251. private _rollObserver;
  38252. private previousPosition;
  38253. private noPreventDefault;
  38254. private element;
  38255. /**
  38256. * Listen to mouse events to control the camera.
  38257. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38259. */
  38260. constructor(touchEnabled?: boolean);
  38261. /**
  38262. * Attach the mouse control to the HTML DOM element.
  38263. * @param element Defines the element that listens to the input events.
  38264. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38265. */
  38266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38267. /**
  38268. * Detach the current controls from the specified dom element.
  38269. * @param element Defines the element to stop listening the inputs from
  38270. */
  38271. detachControl(element: Nullable<HTMLElement>): void;
  38272. /**
  38273. * Gets the class name of the current input.
  38274. * @returns the class name.
  38275. */
  38276. getClassName(): string;
  38277. /**
  38278. * Get the friendly name associated with the input class.
  38279. * @returns the input's friendly name.
  38280. */
  38281. getSimpleName(): string;
  38282. private _pointerInput;
  38283. private _onMouseMove;
  38284. /**
  38285. * Rotate camera by mouse offset.
  38286. */
  38287. private rotateCamera;
  38288. }
  38289. }
  38290. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38291. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38292. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38293. /**
  38294. * Default Inputs manager for the FlyCamera.
  38295. * It groups all the default supported inputs for ease of use.
  38296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38297. */
  38298. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38299. /**
  38300. * Instantiates a new FlyCameraInputsManager.
  38301. * @param camera Defines the camera the inputs belong to.
  38302. */
  38303. constructor(camera: FlyCamera);
  38304. /**
  38305. * Add keyboard input support to the input manager.
  38306. * @returns the new FlyCameraKeyboardMoveInput().
  38307. */
  38308. addKeyboard(): FlyCameraInputsManager;
  38309. /**
  38310. * Add mouse input support to the input manager.
  38311. * @param touchEnabled Enable touch screen support.
  38312. * @returns the new FlyCameraMouseInput().
  38313. */
  38314. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38315. }
  38316. }
  38317. declare module "babylonjs/Cameras/flyCamera" {
  38318. import { Scene } from "babylonjs/scene";
  38319. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38321. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38322. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38323. /**
  38324. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38325. * such as in a 3D Space Shooter or a Flight Simulator.
  38326. */
  38327. export class FlyCamera extends TargetCamera {
  38328. /**
  38329. * Define the collision ellipsoid of the camera.
  38330. * This is helpful for simulating a camera body, like a player's body.
  38331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38332. */
  38333. ellipsoid: Vector3;
  38334. /**
  38335. * Define an offset for the position of the ellipsoid around the camera.
  38336. * This can be helpful if the camera is attached away from the player's body center,
  38337. * such as at its head.
  38338. */
  38339. ellipsoidOffset: Vector3;
  38340. /**
  38341. * Enable or disable collisions of the camera with the rest of the scene objects.
  38342. */
  38343. checkCollisions: boolean;
  38344. /**
  38345. * Enable or disable gravity on the camera.
  38346. */
  38347. applyGravity: boolean;
  38348. /**
  38349. * Define the current direction the camera is moving to.
  38350. */
  38351. cameraDirection: Vector3;
  38352. /**
  38353. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38354. * This overrides and empties cameraRotation.
  38355. */
  38356. rotationQuaternion: Quaternion;
  38357. /**
  38358. * Track Roll to maintain the wanted Rolling when looking around.
  38359. */
  38360. _trackRoll: number;
  38361. /**
  38362. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38363. */
  38364. rollCorrect: number;
  38365. /**
  38366. * Mimic a banked turn, Rolling the camera when Yawing.
  38367. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38368. */
  38369. bankedTurn: boolean;
  38370. /**
  38371. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38372. */
  38373. bankedTurnLimit: number;
  38374. /**
  38375. * Value of 0 disables the banked Roll.
  38376. * Value of 1 is equal to the Yaw angle in radians.
  38377. */
  38378. bankedTurnMultiplier: number;
  38379. /**
  38380. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38381. */
  38382. inputs: FlyCameraInputsManager;
  38383. /**
  38384. * Gets the input sensibility for mouse input.
  38385. * Higher values reduce sensitivity.
  38386. */
  38387. /**
  38388. * Sets the input sensibility for a mouse input.
  38389. * Higher values reduce sensitivity.
  38390. */
  38391. angularSensibility: number;
  38392. /**
  38393. * Get the keys for camera movement forward.
  38394. */
  38395. /**
  38396. * Set the keys for camera movement forward.
  38397. */
  38398. keysForward: number[];
  38399. /**
  38400. * Get the keys for camera movement backward.
  38401. */
  38402. keysBackward: number[];
  38403. /**
  38404. * Get the keys for camera movement up.
  38405. */
  38406. /**
  38407. * Set the keys for camera movement up.
  38408. */
  38409. keysUp: number[];
  38410. /**
  38411. * Get the keys for camera movement down.
  38412. */
  38413. /**
  38414. * Set the keys for camera movement down.
  38415. */
  38416. keysDown: number[];
  38417. /**
  38418. * Get the keys for camera movement left.
  38419. */
  38420. /**
  38421. * Set the keys for camera movement left.
  38422. */
  38423. keysLeft: number[];
  38424. /**
  38425. * Set the keys for camera movement right.
  38426. */
  38427. /**
  38428. * Set the keys for camera movement right.
  38429. */
  38430. keysRight: number[];
  38431. /**
  38432. * Event raised when the camera collides with a mesh in the scene.
  38433. */
  38434. onCollide: (collidedMesh: AbstractMesh) => void;
  38435. private _collider;
  38436. private _needMoveForGravity;
  38437. private _oldPosition;
  38438. private _diffPosition;
  38439. private _newPosition;
  38440. /** @hidden */
  38441. _localDirection: Vector3;
  38442. /** @hidden */
  38443. _transformedDirection: Vector3;
  38444. /**
  38445. * Instantiates a FlyCamera.
  38446. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38447. * such as in a 3D Space Shooter or a Flight Simulator.
  38448. * @param name Define the name of the camera in the scene.
  38449. * @param position Define the starting position of the camera in the scene.
  38450. * @param scene Define the scene the camera belongs to.
  38451. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38452. */
  38453. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38454. /**
  38455. * Attach a control to the HTML DOM element.
  38456. * @param element Defines the element that listens to the input events.
  38457. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38458. */
  38459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38460. /**
  38461. * Detach a control from the HTML DOM element.
  38462. * The camera will stop reacting to that input.
  38463. * @param element Defines the element that listens to the input events.
  38464. */
  38465. detachControl(element: HTMLElement): void;
  38466. private _collisionMask;
  38467. /**
  38468. * Get the mask that the camera ignores in collision events.
  38469. */
  38470. /**
  38471. * Set the mask that the camera ignores in collision events.
  38472. */
  38473. collisionMask: number;
  38474. /** @hidden */
  38475. _collideWithWorld(displacement: Vector3): void;
  38476. /** @hidden */
  38477. private _onCollisionPositionChange;
  38478. /** @hidden */
  38479. _checkInputs(): void;
  38480. /** @hidden */
  38481. _decideIfNeedsToMove(): boolean;
  38482. /** @hidden */
  38483. _updatePosition(): void;
  38484. /**
  38485. * Restore the Roll to its target value at the rate specified.
  38486. * @param rate - Higher means slower restoring.
  38487. * @hidden
  38488. */
  38489. restoreRoll(rate: number): void;
  38490. /**
  38491. * Destroy the camera and release the current resources held by it.
  38492. */
  38493. dispose(): void;
  38494. /**
  38495. * Get the current object class name.
  38496. * @returns the class name.
  38497. */
  38498. getClassName(): string;
  38499. }
  38500. }
  38501. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38502. import { Nullable } from "babylonjs/types";
  38503. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38504. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38505. /**
  38506. * Listen to keyboard events to control the camera.
  38507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38508. */
  38509. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38510. /**
  38511. * Defines the camera the input is attached to.
  38512. */
  38513. camera: FlyCamera;
  38514. /**
  38515. * The list of keyboard keys used to control the forward move of the camera.
  38516. */
  38517. keysForward: number[];
  38518. /**
  38519. * The list of keyboard keys used to control the backward move of the camera.
  38520. */
  38521. keysBackward: number[];
  38522. /**
  38523. * The list of keyboard keys used to control the forward move of the camera.
  38524. */
  38525. keysUp: number[];
  38526. /**
  38527. * The list of keyboard keys used to control the backward move of the camera.
  38528. */
  38529. keysDown: number[];
  38530. /**
  38531. * The list of keyboard keys used to control the right strafe move of the camera.
  38532. */
  38533. keysRight: number[];
  38534. /**
  38535. * The list of keyboard keys used to control the left strafe move of the camera.
  38536. */
  38537. keysLeft: number[];
  38538. private _keys;
  38539. private _onCanvasBlurObserver;
  38540. private _onKeyboardObserver;
  38541. private _engine;
  38542. private _scene;
  38543. /**
  38544. * Attach the input controls to a specific dom element to get the input from.
  38545. * @param element Defines the element the controls should be listened from
  38546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38547. */
  38548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38549. /**
  38550. * Detach the current controls from the specified dom element.
  38551. * @param element Defines the element to stop listening the inputs from
  38552. */
  38553. detachControl(element: Nullable<HTMLElement>): void;
  38554. /**
  38555. * Gets the class name of the current intput.
  38556. * @returns the class name
  38557. */
  38558. getClassName(): string;
  38559. /** @hidden */
  38560. _onLostFocus(e: FocusEvent): void;
  38561. /**
  38562. * Get the friendly name associated with the input class.
  38563. * @returns the input friendly name
  38564. */
  38565. getSimpleName(): string;
  38566. /**
  38567. * Update the current camera state depending on the inputs that have been used this frame.
  38568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38569. */
  38570. checkInputs(): void;
  38571. }
  38572. }
  38573. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38574. import { Nullable } from "babylonjs/types";
  38575. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38576. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38577. /**
  38578. * Manage the mouse wheel inputs to control a follow camera.
  38579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38580. */
  38581. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38582. /**
  38583. * Defines the camera the input is attached to.
  38584. */
  38585. camera: FollowCamera;
  38586. /**
  38587. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38588. */
  38589. axisControlRadius: boolean;
  38590. /**
  38591. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38592. */
  38593. axisControlHeight: boolean;
  38594. /**
  38595. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38596. */
  38597. axisControlRotation: boolean;
  38598. /**
  38599. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38600. * relation to mouseWheel events.
  38601. */
  38602. wheelPrecision: number;
  38603. /**
  38604. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38605. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38606. */
  38607. wheelDeltaPercentage: number;
  38608. private _wheel;
  38609. private _observer;
  38610. /**
  38611. * Attach the input controls to a specific dom element to get the input from.
  38612. * @param element Defines the element the controls should be listened from
  38613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38614. */
  38615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38616. /**
  38617. * Detach the current controls from the specified dom element.
  38618. * @param element Defines the element to stop listening the inputs from
  38619. */
  38620. detachControl(element: Nullable<HTMLElement>): void;
  38621. /**
  38622. * Gets the class name of the current intput.
  38623. * @returns the class name
  38624. */
  38625. getClassName(): string;
  38626. /**
  38627. * Get the friendly name associated with the input class.
  38628. * @returns the input friendly name
  38629. */
  38630. getSimpleName(): string;
  38631. }
  38632. }
  38633. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38634. import { Nullable } from "babylonjs/types";
  38635. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38636. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38637. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38638. /**
  38639. * Manage the pointers inputs to control an follow camera.
  38640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38641. */
  38642. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38643. /**
  38644. * Defines the camera the input is attached to.
  38645. */
  38646. camera: FollowCamera;
  38647. /**
  38648. * Gets the class name of the current input.
  38649. * @returns the class name
  38650. */
  38651. getClassName(): string;
  38652. /**
  38653. * Defines the pointer angular sensibility along the X axis or how fast is
  38654. * the camera rotating.
  38655. * A negative number will reverse the axis direction.
  38656. */
  38657. angularSensibilityX: number;
  38658. /**
  38659. * Defines the pointer angular sensibility along the Y axis or how fast is
  38660. * the camera rotating.
  38661. * A negative number will reverse the axis direction.
  38662. */
  38663. angularSensibilityY: number;
  38664. /**
  38665. * Defines the pointer pinch precision or how fast is the camera zooming.
  38666. * A negative number will reverse the axis direction.
  38667. */
  38668. pinchPrecision: number;
  38669. /**
  38670. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38671. * from 0.
  38672. * It defines the percentage of current camera.radius to use as delta when
  38673. * pinch zoom is used.
  38674. */
  38675. pinchDeltaPercentage: number;
  38676. /**
  38677. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38678. */
  38679. axisXControlRadius: boolean;
  38680. /**
  38681. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38682. */
  38683. axisXControlHeight: boolean;
  38684. /**
  38685. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38686. */
  38687. axisXControlRotation: boolean;
  38688. /**
  38689. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38690. */
  38691. axisYControlRadius: boolean;
  38692. /**
  38693. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38694. */
  38695. axisYControlHeight: boolean;
  38696. /**
  38697. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38698. */
  38699. axisYControlRotation: boolean;
  38700. /**
  38701. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38702. */
  38703. axisPinchControlRadius: boolean;
  38704. /**
  38705. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38706. */
  38707. axisPinchControlHeight: boolean;
  38708. /**
  38709. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38710. */
  38711. axisPinchControlRotation: boolean;
  38712. /**
  38713. * Log error messages if basic misconfiguration has occurred.
  38714. */
  38715. warningEnable: boolean;
  38716. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38717. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38718. private _warningCounter;
  38719. private _warning;
  38720. }
  38721. }
  38722. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38723. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38724. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38725. /**
  38726. * Default Inputs manager for the FollowCamera.
  38727. * It groups all the default supported inputs for ease of use.
  38728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38729. */
  38730. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38731. /**
  38732. * Instantiates a new FollowCameraInputsManager.
  38733. * @param camera Defines the camera the inputs belong to
  38734. */
  38735. constructor(camera: FollowCamera);
  38736. /**
  38737. * Add keyboard input support to the input manager.
  38738. * @returns the current input manager
  38739. */
  38740. addKeyboard(): FollowCameraInputsManager;
  38741. /**
  38742. * Add mouse wheel input support to the input manager.
  38743. * @returns the current input manager
  38744. */
  38745. addMouseWheel(): FollowCameraInputsManager;
  38746. /**
  38747. * Add pointers input support to the input manager.
  38748. * @returns the current input manager
  38749. */
  38750. addPointers(): FollowCameraInputsManager;
  38751. /**
  38752. * Add orientation input support to the input manager.
  38753. * @returns the current input manager
  38754. */
  38755. addVRDeviceOrientation(): FollowCameraInputsManager;
  38756. }
  38757. }
  38758. declare module "babylonjs/Cameras/followCamera" {
  38759. import { Nullable } from "babylonjs/types";
  38760. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38761. import { Scene } from "babylonjs/scene";
  38762. import { Vector3 } from "babylonjs/Maths/math.vector";
  38763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38764. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38765. /**
  38766. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38767. * an arc rotate version arcFollowCamera are available.
  38768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38769. */
  38770. export class FollowCamera extends TargetCamera {
  38771. /**
  38772. * Distance the follow camera should follow an object at
  38773. */
  38774. radius: number;
  38775. /**
  38776. * Minimum allowed distance of the camera to the axis of rotation
  38777. * (The camera can not get closer).
  38778. * This can help limiting how the Camera is able to move in the scene.
  38779. */
  38780. lowerRadiusLimit: Nullable<number>;
  38781. /**
  38782. * Maximum allowed distance of the camera to the axis of rotation
  38783. * (The camera can not get further).
  38784. * This can help limiting how the Camera is able to move in the scene.
  38785. */
  38786. upperRadiusLimit: Nullable<number>;
  38787. /**
  38788. * Define a rotation offset between the camera and the object it follows
  38789. */
  38790. rotationOffset: number;
  38791. /**
  38792. * Minimum allowed angle to camera position relative to target object.
  38793. * This can help limiting how the Camera is able to move in the scene.
  38794. */
  38795. lowerRotationOffsetLimit: Nullable<number>;
  38796. /**
  38797. * Maximum allowed angle to camera position relative to target object.
  38798. * This can help limiting how the Camera is able to move in the scene.
  38799. */
  38800. upperRotationOffsetLimit: Nullable<number>;
  38801. /**
  38802. * Define a height offset between the camera and the object it follows.
  38803. * It can help following an object from the top (like a car chaing a plane)
  38804. */
  38805. heightOffset: number;
  38806. /**
  38807. * Minimum allowed height of camera position relative to target object.
  38808. * This can help limiting how the Camera is able to move in the scene.
  38809. */
  38810. lowerHeightOffsetLimit: Nullable<number>;
  38811. /**
  38812. * Maximum allowed height of camera position relative to target object.
  38813. * This can help limiting how the Camera is able to move in the scene.
  38814. */
  38815. upperHeightOffsetLimit: Nullable<number>;
  38816. /**
  38817. * Define how fast the camera can accelerate to follow it s target.
  38818. */
  38819. cameraAcceleration: number;
  38820. /**
  38821. * Define the speed limit of the camera following an object.
  38822. */
  38823. maxCameraSpeed: number;
  38824. /**
  38825. * Define the target of the camera.
  38826. */
  38827. lockedTarget: Nullable<AbstractMesh>;
  38828. /**
  38829. * Defines the input associated with the camera.
  38830. */
  38831. inputs: FollowCameraInputsManager;
  38832. /**
  38833. * Instantiates the follow camera.
  38834. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38835. * @param name Define the name of the camera in the scene
  38836. * @param position Define the position of the camera
  38837. * @param scene Define the scene the camera belong to
  38838. * @param lockedTarget Define the target of the camera
  38839. */
  38840. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38841. private _follow;
  38842. /**
  38843. * Attached controls to the current camera.
  38844. * @param element Defines the element the controls should be listened from
  38845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38846. */
  38847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38848. /**
  38849. * Detach the current controls from the camera.
  38850. * The camera will stop reacting to inputs.
  38851. * @param element Defines the element to stop listening the inputs from
  38852. */
  38853. detachControl(element: HTMLElement): void;
  38854. /** @hidden */
  38855. _checkInputs(): void;
  38856. private _checkLimits;
  38857. /**
  38858. * Gets the camera class name.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. }
  38863. /**
  38864. * Arc Rotate version of the follow camera.
  38865. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38866. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38867. */
  38868. export class ArcFollowCamera extends TargetCamera {
  38869. /** The longitudinal angle of the camera */
  38870. alpha: number;
  38871. /** The latitudinal angle of the camera */
  38872. beta: number;
  38873. /** The radius of the camera from its target */
  38874. radius: number;
  38875. /** Define the camera target (the messh it should follow) */
  38876. target: Nullable<AbstractMesh>;
  38877. private _cartesianCoordinates;
  38878. /**
  38879. * Instantiates a new ArcFollowCamera
  38880. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38881. * @param name Define the name of the camera
  38882. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38883. * @param beta Define the rotation angle of the camera around the elevation axis
  38884. * @param radius Define the radius of the camera from its target point
  38885. * @param target Define the target of the camera
  38886. * @param scene Define the scene the camera belongs to
  38887. */
  38888. constructor(name: string,
  38889. /** The longitudinal angle of the camera */
  38890. alpha: number,
  38891. /** The latitudinal angle of the camera */
  38892. beta: number,
  38893. /** The radius of the camera from its target */
  38894. radius: number,
  38895. /** Define the camera target (the messh it should follow) */
  38896. target: Nullable<AbstractMesh>, scene: Scene);
  38897. private _follow;
  38898. /** @hidden */
  38899. _checkInputs(): void;
  38900. /**
  38901. * Returns the class name of the object.
  38902. * It is mostly used internally for serialization purposes.
  38903. */
  38904. getClassName(): string;
  38905. }
  38906. }
  38907. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38909. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38910. import { Nullable } from "babylonjs/types";
  38911. /**
  38912. * Manage the keyboard inputs to control the movement of a follow camera.
  38913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38914. */
  38915. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38916. /**
  38917. * Defines the camera the input is attached to.
  38918. */
  38919. camera: FollowCamera;
  38920. /**
  38921. * Defines the list of key codes associated with the up action (increase heightOffset)
  38922. */
  38923. keysHeightOffsetIncr: number[];
  38924. /**
  38925. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38926. */
  38927. keysHeightOffsetDecr: number[];
  38928. /**
  38929. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38930. */
  38931. keysHeightOffsetModifierAlt: boolean;
  38932. /**
  38933. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38934. */
  38935. keysHeightOffsetModifierCtrl: boolean;
  38936. /**
  38937. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38938. */
  38939. keysHeightOffsetModifierShift: boolean;
  38940. /**
  38941. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38942. */
  38943. keysRotationOffsetIncr: number[];
  38944. /**
  38945. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38946. */
  38947. keysRotationOffsetDecr: number[];
  38948. /**
  38949. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38950. */
  38951. keysRotationOffsetModifierAlt: boolean;
  38952. /**
  38953. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38954. */
  38955. keysRotationOffsetModifierCtrl: boolean;
  38956. /**
  38957. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38958. */
  38959. keysRotationOffsetModifierShift: boolean;
  38960. /**
  38961. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38962. */
  38963. keysRadiusIncr: number[];
  38964. /**
  38965. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38966. */
  38967. keysRadiusDecr: number[];
  38968. /**
  38969. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38970. */
  38971. keysRadiusModifierAlt: boolean;
  38972. /**
  38973. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38974. */
  38975. keysRadiusModifierCtrl: boolean;
  38976. /**
  38977. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38978. */
  38979. keysRadiusModifierShift: boolean;
  38980. /**
  38981. * Defines the rate of change of heightOffset.
  38982. */
  38983. heightSensibility: number;
  38984. /**
  38985. * Defines the rate of change of rotationOffset.
  38986. */
  38987. rotationSensibility: number;
  38988. /**
  38989. * Defines the rate of change of radius.
  38990. */
  38991. radiusSensibility: number;
  38992. private _keys;
  38993. private _ctrlPressed;
  38994. private _altPressed;
  38995. private _shiftPressed;
  38996. private _onCanvasBlurObserver;
  38997. private _onKeyboardObserver;
  38998. private _engine;
  38999. private _scene;
  39000. /**
  39001. * Attach the input controls to a specific dom element to get the input from.
  39002. * @param element Defines the element the controls should be listened from
  39003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39004. */
  39005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39006. /**
  39007. * Detach the current controls from the specified dom element.
  39008. * @param element Defines the element to stop listening the inputs from
  39009. */
  39010. detachControl(element: Nullable<HTMLElement>): void;
  39011. /**
  39012. * Update the current camera state depending on the inputs that have been used this frame.
  39013. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39014. */
  39015. checkInputs(): void;
  39016. /**
  39017. * Gets the class name of the current input.
  39018. * @returns the class name
  39019. */
  39020. getClassName(): string;
  39021. /**
  39022. * Get the friendly name associated with the input class.
  39023. * @returns the input friendly name
  39024. */
  39025. getSimpleName(): string;
  39026. /**
  39027. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39028. * allow modification of the heightOffset value.
  39029. */
  39030. private _modifierHeightOffset;
  39031. /**
  39032. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39033. * allow modification of the rotationOffset value.
  39034. */
  39035. private _modifierRotationOffset;
  39036. /**
  39037. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39038. * allow modification of the radius value.
  39039. */
  39040. private _modifierRadius;
  39041. }
  39042. }
  39043. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39044. import { Nullable } from "babylonjs/types";
  39045. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39046. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39047. import { Observable } from "babylonjs/Misc/observable";
  39048. module "babylonjs/Cameras/freeCameraInputsManager" {
  39049. interface FreeCameraInputsManager {
  39050. /**
  39051. * @hidden
  39052. */
  39053. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39054. /**
  39055. * Add orientation input support to the input manager.
  39056. * @returns the current input manager
  39057. */
  39058. addDeviceOrientation(): FreeCameraInputsManager;
  39059. }
  39060. }
  39061. /**
  39062. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39063. * Screen rotation is taken into account.
  39064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39065. */
  39066. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39067. private _camera;
  39068. private _screenOrientationAngle;
  39069. private _constantTranform;
  39070. private _screenQuaternion;
  39071. private _alpha;
  39072. private _beta;
  39073. private _gamma;
  39074. /**
  39075. * Can be used to detect if a device orientation sensor is availible on a device
  39076. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39077. * @returns a promise that will resolve on orientation change
  39078. */
  39079. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39080. /**
  39081. * @hidden
  39082. */
  39083. _onDeviceOrientationChangedObservable: Observable<void>;
  39084. /**
  39085. * Instantiates a new input
  39086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39087. */
  39088. constructor();
  39089. /**
  39090. * Define the camera controlled by the input.
  39091. */
  39092. camera: FreeCamera;
  39093. /**
  39094. * Attach the input controls to a specific dom element to get the input from.
  39095. * @param element Defines the element the controls should be listened from
  39096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39097. */
  39098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39099. private _orientationChanged;
  39100. private _deviceOrientation;
  39101. /**
  39102. * Detach the current controls from the specified dom element.
  39103. * @param element Defines the element to stop listening the inputs from
  39104. */
  39105. detachControl(element: Nullable<HTMLElement>): void;
  39106. /**
  39107. * Update the current camera state depending on the inputs that have been used this frame.
  39108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39109. */
  39110. checkInputs(): void;
  39111. /**
  39112. * Gets the class name of the current intput.
  39113. * @returns the class name
  39114. */
  39115. getClassName(): string;
  39116. /**
  39117. * Get the friendly name associated with the input class.
  39118. * @returns the input friendly name
  39119. */
  39120. getSimpleName(): string;
  39121. }
  39122. }
  39123. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39124. import { Nullable } from "babylonjs/types";
  39125. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39126. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39127. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39128. /**
  39129. * Manage the gamepad inputs to control a free camera.
  39130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39131. */
  39132. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39133. /**
  39134. * Define the camera the input is attached to.
  39135. */
  39136. camera: FreeCamera;
  39137. /**
  39138. * Define the Gamepad controlling the input
  39139. */
  39140. gamepad: Nullable<Gamepad>;
  39141. /**
  39142. * Defines the gamepad rotation sensiblity.
  39143. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39144. */
  39145. gamepadAngularSensibility: number;
  39146. /**
  39147. * Defines the gamepad move sensiblity.
  39148. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39149. */
  39150. gamepadMoveSensibility: number;
  39151. private _onGamepadConnectedObserver;
  39152. private _onGamepadDisconnectedObserver;
  39153. private _cameraTransform;
  39154. private _deltaTransform;
  39155. private _vector3;
  39156. private _vector2;
  39157. /**
  39158. * Attach the input controls to a specific dom element to get the input from.
  39159. * @param element Defines the element the controls should be listened from
  39160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39161. */
  39162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39163. /**
  39164. * Detach the current controls from the specified dom element.
  39165. * @param element Defines the element to stop listening the inputs from
  39166. */
  39167. detachControl(element: Nullable<HTMLElement>): void;
  39168. /**
  39169. * Update the current camera state depending on the inputs that have been used this frame.
  39170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39171. */
  39172. checkInputs(): void;
  39173. /**
  39174. * Gets the class name of the current intput.
  39175. * @returns the class name
  39176. */
  39177. getClassName(): string;
  39178. /**
  39179. * Get the friendly name associated with the input class.
  39180. * @returns the input friendly name
  39181. */
  39182. getSimpleName(): string;
  39183. }
  39184. }
  39185. declare module "babylonjs/Misc/virtualJoystick" {
  39186. import { Nullable } from "babylonjs/types";
  39187. import { Vector3 } from "babylonjs/Maths/math.vector";
  39188. /**
  39189. * Defines the potential axis of a Joystick
  39190. */
  39191. export enum JoystickAxis {
  39192. /** X axis */
  39193. X = 0,
  39194. /** Y axis */
  39195. Y = 1,
  39196. /** Z axis */
  39197. Z = 2
  39198. }
  39199. /**
  39200. * Class used to define virtual joystick (used in touch mode)
  39201. */
  39202. export class VirtualJoystick {
  39203. /**
  39204. * Gets or sets a boolean indicating that left and right values must be inverted
  39205. */
  39206. reverseLeftRight: boolean;
  39207. /**
  39208. * Gets or sets a boolean indicating that up and down values must be inverted
  39209. */
  39210. reverseUpDown: boolean;
  39211. /**
  39212. * Gets the offset value for the position (ie. the change of the position value)
  39213. */
  39214. deltaPosition: Vector3;
  39215. /**
  39216. * Gets a boolean indicating if the virtual joystick was pressed
  39217. */
  39218. pressed: boolean;
  39219. /**
  39220. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39221. */
  39222. static Canvas: Nullable<HTMLCanvasElement>;
  39223. private static _globalJoystickIndex;
  39224. private static vjCanvasContext;
  39225. private static vjCanvasWidth;
  39226. private static vjCanvasHeight;
  39227. private static halfWidth;
  39228. private _action;
  39229. private _axisTargetedByLeftAndRight;
  39230. private _axisTargetedByUpAndDown;
  39231. private _joystickSensibility;
  39232. private _inversedSensibility;
  39233. private _joystickPointerID;
  39234. private _joystickColor;
  39235. private _joystickPointerPos;
  39236. private _joystickPreviousPointerPos;
  39237. private _joystickPointerStartPos;
  39238. private _deltaJoystickVector;
  39239. private _leftJoystick;
  39240. private _touches;
  39241. private _onPointerDownHandlerRef;
  39242. private _onPointerMoveHandlerRef;
  39243. private _onPointerUpHandlerRef;
  39244. private _onResize;
  39245. /**
  39246. * Creates a new virtual joystick
  39247. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39248. */
  39249. constructor(leftJoystick?: boolean);
  39250. /**
  39251. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39252. * @param newJoystickSensibility defines the new sensibility
  39253. */
  39254. setJoystickSensibility(newJoystickSensibility: number): void;
  39255. private _onPointerDown;
  39256. private _onPointerMove;
  39257. private _onPointerUp;
  39258. /**
  39259. * Change the color of the virtual joystick
  39260. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39261. */
  39262. setJoystickColor(newColor: string): void;
  39263. /**
  39264. * Defines a callback to call when the joystick is touched
  39265. * @param action defines the callback
  39266. */
  39267. setActionOnTouch(action: () => any): void;
  39268. /**
  39269. * Defines which axis you'd like to control for left & right
  39270. * @param axis defines the axis to use
  39271. */
  39272. setAxisForLeftRight(axis: JoystickAxis): void;
  39273. /**
  39274. * Defines which axis you'd like to control for up & down
  39275. * @param axis defines the axis to use
  39276. */
  39277. setAxisForUpDown(axis: JoystickAxis): void;
  39278. private _drawVirtualJoystick;
  39279. /**
  39280. * Release internal HTML canvas
  39281. */
  39282. releaseCanvas(): void;
  39283. }
  39284. }
  39285. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39286. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39287. import { Nullable } from "babylonjs/types";
  39288. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39289. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39290. module "babylonjs/Cameras/freeCameraInputsManager" {
  39291. interface FreeCameraInputsManager {
  39292. /**
  39293. * Add virtual joystick input support to the input manager.
  39294. * @returns the current input manager
  39295. */
  39296. addVirtualJoystick(): FreeCameraInputsManager;
  39297. }
  39298. }
  39299. /**
  39300. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39302. */
  39303. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39304. /**
  39305. * Defines the camera the input is attached to.
  39306. */
  39307. camera: FreeCamera;
  39308. private _leftjoystick;
  39309. private _rightjoystick;
  39310. /**
  39311. * Gets the left stick of the virtual joystick.
  39312. * @returns The virtual Joystick
  39313. */
  39314. getLeftJoystick(): VirtualJoystick;
  39315. /**
  39316. * Gets the right stick of the virtual joystick.
  39317. * @returns The virtual Joystick
  39318. */
  39319. getRightJoystick(): VirtualJoystick;
  39320. /**
  39321. * Update the current camera state depending on the inputs that have been used this frame.
  39322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39323. */
  39324. checkInputs(): void;
  39325. /**
  39326. * Attach the input controls to a specific dom element to get the input from.
  39327. * @param element Defines the element the controls should be listened from
  39328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39329. */
  39330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39331. /**
  39332. * Detach the current controls from the specified dom element.
  39333. * @param element Defines the element to stop listening the inputs from
  39334. */
  39335. detachControl(element: Nullable<HTMLElement>): void;
  39336. /**
  39337. * Gets the class name of the current intput.
  39338. * @returns the class name
  39339. */
  39340. getClassName(): string;
  39341. /**
  39342. * Get the friendly name associated with the input class.
  39343. * @returns the input friendly name
  39344. */
  39345. getSimpleName(): string;
  39346. }
  39347. }
  39348. declare module "babylonjs/Cameras/Inputs/index" {
  39349. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39350. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39351. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39352. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39353. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39354. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39355. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39356. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39357. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39358. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39359. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39360. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39361. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39362. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39363. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39364. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39365. }
  39366. declare module "babylonjs/Cameras/touchCamera" {
  39367. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39368. import { Scene } from "babylonjs/scene";
  39369. import { Vector3 } from "babylonjs/Maths/math.vector";
  39370. /**
  39371. * This represents a FPS type of camera controlled by touch.
  39372. * This is like a universal camera minus the Gamepad controls.
  39373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39374. */
  39375. export class TouchCamera extends FreeCamera {
  39376. /**
  39377. * Defines the touch sensibility for rotation.
  39378. * The higher the faster.
  39379. */
  39380. touchAngularSensibility: number;
  39381. /**
  39382. * Defines the touch sensibility for move.
  39383. * The higher the faster.
  39384. */
  39385. touchMoveSensibility: number;
  39386. /**
  39387. * Instantiates a new touch camera.
  39388. * This represents a FPS type of camera controlled by touch.
  39389. * This is like a universal camera minus the Gamepad controls.
  39390. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39391. * @param name Define the name of the camera in the scene
  39392. * @param position Define the start position of the camera in the scene
  39393. * @param scene Define the scene the camera belongs to
  39394. */
  39395. constructor(name: string, position: Vector3, scene: Scene);
  39396. /**
  39397. * Gets the current object class name.
  39398. * @return the class name
  39399. */
  39400. getClassName(): string;
  39401. /** @hidden */
  39402. _setupInputs(): void;
  39403. }
  39404. }
  39405. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39406. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39407. import { Scene } from "babylonjs/scene";
  39408. import { Vector3 } from "babylonjs/Maths/math.vector";
  39409. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39410. import { Axis } from "babylonjs/Maths/math.axis";
  39411. /**
  39412. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39413. * being tilted forward or back and left or right.
  39414. */
  39415. export class DeviceOrientationCamera extends FreeCamera {
  39416. private _initialQuaternion;
  39417. private _quaternionCache;
  39418. private _tmpDragQuaternion;
  39419. /**
  39420. * Creates a new device orientation camera
  39421. * @param name The name of the camera
  39422. * @param position The start position camera
  39423. * @param scene The scene the camera belongs to
  39424. */
  39425. constructor(name: string, position: Vector3, scene: Scene);
  39426. /**
  39427. * @hidden
  39428. * Disabled pointer input on first orientation sensor update (Default: true)
  39429. */
  39430. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39431. private _dragFactor;
  39432. /**
  39433. * Enabled turning on the y axis when the orientation sensor is active
  39434. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39435. */
  39436. enableHorizontalDragging(dragFactor?: number): void;
  39437. /**
  39438. * Gets the current instance class name ("DeviceOrientationCamera").
  39439. * This helps avoiding instanceof at run time.
  39440. * @returns the class name
  39441. */
  39442. getClassName(): string;
  39443. /**
  39444. * @hidden
  39445. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39446. */
  39447. _checkInputs(): void;
  39448. /**
  39449. * Reset the camera to its default orientation on the specified axis only.
  39450. * @param axis The axis to reset
  39451. */
  39452. resetToCurrentRotation(axis?: Axis): void;
  39453. }
  39454. }
  39455. declare module "babylonjs/Gamepads/xboxGamepad" {
  39456. import { Observable } from "babylonjs/Misc/observable";
  39457. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39458. /**
  39459. * Defines supported buttons for XBox360 compatible gamepads
  39460. */
  39461. export enum Xbox360Button {
  39462. /** A */
  39463. A = 0,
  39464. /** B */
  39465. B = 1,
  39466. /** X */
  39467. X = 2,
  39468. /** Y */
  39469. Y = 3,
  39470. /** Start */
  39471. Start = 4,
  39472. /** Back */
  39473. Back = 5,
  39474. /** Left button */
  39475. LB = 6,
  39476. /** Right button */
  39477. RB = 7,
  39478. /** Left stick */
  39479. LeftStick = 8,
  39480. /** Right stick */
  39481. RightStick = 9
  39482. }
  39483. /** Defines values for XBox360 DPad */
  39484. export enum Xbox360Dpad {
  39485. /** Up */
  39486. Up = 0,
  39487. /** Down */
  39488. Down = 1,
  39489. /** Left */
  39490. Left = 2,
  39491. /** Right */
  39492. Right = 3
  39493. }
  39494. /**
  39495. * Defines a XBox360 gamepad
  39496. */
  39497. export class Xbox360Pad extends Gamepad {
  39498. private _leftTrigger;
  39499. private _rightTrigger;
  39500. private _onlefttriggerchanged;
  39501. private _onrighttriggerchanged;
  39502. private _onbuttondown;
  39503. private _onbuttonup;
  39504. private _ondpaddown;
  39505. private _ondpadup;
  39506. /** Observable raised when a button is pressed */
  39507. onButtonDownObservable: Observable<Xbox360Button>;
  39508. /** Observable raised when a button is released */
  39509. onButtonUpObservable: Observable<Xbox360Button>;
  39510. /** Observable raised when a pad is pressed */
  39511. onPadDownObservable: Observable<Xbox360Dpad>;
  39512. /** Observable raised when a pad is released */
  39513. onPadUpObservable: Observable<Xbox360Dpad>;
  39514. private _buttonA;
  39515. private _buttonB;
  39516. private _buttonX;
  39517. private _buttonY;
  39518. private _buttonBack;
  39519. private _buttonStart;
  39520. private _buttonLB;
  39521. private _buttonRB;
  39522. private _buttonLeftStick;
  39523. private _buttonRightStick;
  39524. private _dPadUp;
  39525. private _dPadDown;
  39526. private _dPadLeft;
  39527. private _dPadRight;
  39528. private _isXboxOnePad;
  39529. /**
  39530. * Creates a new XBox360 gamepad object
  39531. * @param id defines the id of this gamepad
  39532. * @param index defines its index
  39533. * @param gamepad defines the internal HTML gamepad object
  39534. * @param xboxOne defines if it is a XBox One gamepad
  39535. */
  39536. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39537. /**
  39538. * Defines the callback to call when left trigger is pressed
  39539. * @param callback defines the callback to use
  39540. */
  39541. onlefttriggerchanged(callback: (value: number) => void): void;
  39542. /**
  39543. * Defines the callback to call when right trigger is pressed
  39544. * @param callback defines the callback to use
  39545. */
  39546. onrighttriggerchanged(callback: (value: number) => void): void;
  39547. /**
  39548. * Gets the left trigger value
  39549. */
  39550. /**
  39551. * Sets the left trigger value
  39552. */
  39553. leftTrigger: number;
  39554. /**
  39555. * Gets the right trigger value
  39556. */
  39557. /**
  39558. * Sets the right trigger value
  39559. */
  39560. rightTrigger: number;
  39561. /**
  39562. * Defines the callback to call when a button is pressed
  39563. * @param callback defines the callback to use
  39564. */
  39565. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39566. /**
  39567. * Defines the callback to call when a button is released
  39568. * @param callback defines the callback to use
  39569. */
  39570. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39571. /**
  39572. * Defines the callback to call when a pad is pressed
  39573. * @param callback defines the callback to use
  39574. */
  39575. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39576. /**
  39577. * Defines the callback to call when a pad is released
  39578. * @param callback defines the callback to use
  39579. */
  39580. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39581. private _setButtonValue;
  39582. private _setDPadValue;
  39583. /**
  39584. * Gets the value of the `A` button
  39585. */
  39586. /**
  39587. * Sets the value of the `A` button
  39588. */
  39589. buttonA: number;
  39590. /**
  39591. * Gets the value of the `B` button
  39592. */
  39593. /**
  39594. * Sets the value of the `B` button
  39595. */
  39596. buttonB: number;
  39597. /**
  39598. * Gets the value of the `X` button
  39599. */
  39600. /**
  39601. * Sets the value of the `X` button
  39602. */
  39603. buttonX: number;
  39604. /**
  39605. * Gets the value of the `Y` button
  39606. */
  39607. /**
  39608. * Sets the value of the `Y` button
  39609. */
  39610. buttonY: number;
  39611. /**
  39612. * Gets the value of the `Start` button
  39613. */
  39614. /**
  39615. * Sets the value of the `Start` button
  39616. */
  39617. buttonStart: number;
  39618. /**
  39619. * Gets the value of the `Back` button
  39620. */
  39621. /**
  39622. * Sets the value of the `Back` button
  39623. */
  39624. buttonBack: number;
  39625. /**
  39626. * Gets the value of the `Left` button
  39627. */
  39628. /**
  39629. * Sets the value of the `Left` button
  39630. */
  39631. buttonLB: number;
  39632. /**
  39633. * Gets the value of the `Right` button
  39634. */
  39635. /**
  39636. * Sets the value of the `Right` button
  39637. */
  39638. buttonRB: number;
  39639. /**
  39640. * Gets the value of the Left joystick
  39641. */
  39642. /**
  39643. * Sets the value of the Left joystick
  39644. */
  39645. buttonLeftStick: number;
  39646. /**
  39647. * Gets the value of the Right joystick
  39648. */
  39649. /**
  39650. * Sets the value of the Right joystick
  39651. */
  39652. buttonRightStick: number;
  39653. /**
  39654. * Gets the value of D-pad up
  39655. */
  39656. /**
  39657. * Sets the value of D-pad up
  39658. */
  39659. dPadUp: number;
  39660. /**
  39661. * Gets the value of D-pad down
  39662. */
  39663. /**
  39664. * Sets the value of D-pad down
  39665. */
  39666. dPadDown: number;
  39667. /**
  39668. * Gets the value of D-pad left
  39669. */
  39670. /**
  39671. * Sets the value of D-pad left
  39672. */
  39673. dPadLeft: number;
  39674. /**
  39675. * Gets the value of D-pad right
  39676. */
  39677. /**
  39678. * Sets the value of D-pad right
  39679. */
  39680. dPadRight: number;
  39681. /**
  39682. * Force the gamepad to synchronize with device values
  39683. */
  39684. update(): void;
  39685. /**
  39686. * Disposes the gamepad
  39687. */
  39688. dispose(): void;
  39689. }
  39690. }
  39691. declare module "babylonjs/Gamepads/gamepadManager" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Nullable } from "babylonjs/types";
  39694. import { Scene } from "babylonjs/scene";
  39695. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39696. /**
  39697. * Manager for handling gamepads
  39698. */
  39699. export class GamepadManager {
  39700. private _scene?;
  39701. private _babylonGamepads;
  39702. private _oneGamepadConnected;
  39703. /** @hidden */
  39704. _isMonitoring: boolean;
  39705. private _gamepadEventSupported;
  39706. private _gamepadSupport;
  39707. /**
  39708. * observable to be triggered when the gamepad controller has been connected
  39709. */
  39710. onGamepadConnectedObservable: Observable<Gamepad>;
  39711. /**
  39712. * observable to be triggered when the gamepad controller has been disconnected
  39713. */
  39714. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39715. private _onGamepadConnectedEvent;
  39716. private _onGamepadDisconnectedEvent;
  39717. /**
  39718. * Initializes the gamepad manager
  39719. * @param _scene BabylonJS scene
  39720. */
  39721. constructor(_scene?: Scene | undefined);
  39722. /**
  39723. * The gamepads in the game pad manager
  39724. */
  39725. readonly gamepads: Gamepad[];
  39726. /**
  39727. * Get the gamepad controllers based on type
  39728. * @param type The type of gamepad controller
  39729. * @returns Nullable gamepad
  39730. */
  39731. getGamepadByType(type?: number): Nullable<Gamepad>;
  39732. /**
  39733. * Disposes the gamepad manager
  39734. */
  39735. dispose(): void;
  39736. private _addNewGamepad;
  39737. private _startMonitoringGamepads;
  39738. private _stopMonitoringGamepads;
  39739. /** @hidden */
  39740. _checkGamepadsStatus(): void;
  39741. private _updateGamepadObjects;
  39742. }
  39743. }
  39744. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39745. import { Nullable } from "babylonjs/types";
  39746. import { Scene } from "babylonjs/scene";
  39747. import { ISceneComponent } from "babylonjs/sceneComponent";
  39748. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39749. module "babylonjs/scene" {
  39750. interface Scene {
  39751. /** @hidden */
  39752. _gamepadManager: Nullable<GamepadManager>;
  39753. /**
  39754. * Gets the gamepad manager associated with the scene
  39755. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39756. */
  39757. gamepadManager: GamepadManager;
  39758. }
  39759. }
  39760. module "babylonjs/Cameras/freeCameraInputsManager" {
  39761. /**
  39762. * Interface representing a free camera inputs manager
  39763. */
  39764. interface FreeCameraInputsManager {
  39765. /**
  39766. * Adds gamepad input support to the FreeCameraInputsManager.
  39767. * @returns the FreeCameraInputsManager
  39768. */
  39769. addGamepad(): FreeCameraInputsManager;
  39770. }
  39771. }
  39772. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39773. /**
  39774. * Interface representing an arc rotate camera inputs manager
  39775. */
  39776. interface ArcRotateCameraInputsManager {
  39777. /**
  39778. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39779. * @returns the camera inputs manager
  39780. */
  39781. addGamepad(): ArcRotateCameraInputsManager;
  39782. }
  39783. }
  39784. /**
  39785. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39786. */
  39787. export class GamepadSystemSceneComponent implements ISceneComponent {
  39788. /**
  39789. * The component name helpfull to identify the component in the list of scene components.
  39790. */
  39791. readonly name: string;
  39792. /**
  39793. * The scene the component belongs to.
  39794. */
  39795. scene: Scene;
  39796. /**
  39797. * Creates a new instance of the component for the given scene
  39798. * @param scene Defines the scene to register the component in
  39799. */
  39800. constructor(scene: Scene);
  39801. /**
  39802. * Registers the component in a given scene
  39803. */
  39804. register(): void;
  39805. /**
  39806. * Rebuilds the elements related to this component in case of
  39807. * context lost for instance.
  39808. */
  39809. rebuild(): void;
  39810. /**
  39811. * Disposes the component and the associated ressources
  39812. */
  39813. dispose(): void;
  39814. private _beforeCameraUpdate;
  39815. }
  39816. }
  39817. declare module "babylonjs/Cameras/universalCamera" {
  39818. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39819. import { Scene } from "babylonjs/scene";
  39820. import { Vector3 } from "babylonjs/Maths/math.vector";
  39821. import "babylonjs/Gamepads/gamepadSceneComponent";
  39822. /**
  39823. * 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,
  39824. * which still works and will still be found in many Playgrounds.
  39825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39826. */
  39827. export class UniversalCamera extends TouchCamera {
  39828. /**
  39829. * Defines the gamepad rotation sensiblity.
  39830. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39831. */
  39832. gamepadAngularSensibility: number;
  39833. /**
  39834. * Defines the gamepad move sensiblity.
  39835. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39836. */
  39837. gamepadMoveSensibility: number;
  39838. /**
  39839. * 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,
  39840. * which still works and will still be found in many Playgrounds.
  39841. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39842. * @param name Define the name of the camera in the scene
  39843. * @param position Define the start position of the camera in the scene
  39844. * @param scene Define the scene the camera belongs to
  39845. */
  39846. constructor(name: string, position: Vector3, scene: Scene);
  39847. /**
  39848. * Gets the current object class name.
  39849. * @return the class name
  39850. */
  39851. getClassName(): string;
  39852. }
  39853. }
  39854. declare module "babylonjs/Cameras/gamepadCamera" {
  39855. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39856. import { Scene } from "babylonjs/scene";
  39857. import { Vector3 } from "babylonjs/Maths/math.vector";
  39858. /**
  39859. * This represents a FPS type of camera. This is only here for back compat purpose.
  39860. * Please use the UniversalCamera instead as both are identical.
  39861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39862. */
  39863. export class GamepadCamera extends UniversalCamera {
  39864. /**
  39865. * Instantiates a new Gamepad Camera
  39866. * This represents a FPS type of camera. This is only here for back compat purpose.
  39867. * Please use the UniversalCamera instead as both are identical.
  39868. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39869. * @param name Define the name of the camera in the scene
  39870. * @param position Define the start position of the camera in the scene
  39871. * @param scene Define the scene the camera belongs to
  39872. */
  39873. constructor(name: string, position: Vector3, scene: Scene);
  39874. /**
  39875. * Gets the current object class name.
  39876. * @return the class name
  39877. */
  39878. getClassName(): string;
  39879. }
  39880. }
  39881. declare module "babylonjs/Shaders/pass.fragment" {
  39882. /** @hidden */
  39883. export var passPixelShader: {
  39884. name: string;
  39885. shader: string;
  39886. };
  39887. }
  39888. declare module "babylonjs/Shaders/passCube.fragment" {
  39889. /** @hidden */
  39890. export var passCubePixelShader: {
  39891. name: string;
  39892. shader: string;
  39893. };
  39894. }
  39895. declare module "babylonjs/PostProcesses/passPostProcess" {
  39896. import { Nullable } from "babylonjs/types";
  39897. import { Camera } from "babylonjs/Cameras/camera";
  39898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39899. import { Engine } from "babylonjs/Engines/engine";
  39900. import "babylonjs/Shaders/pass.fragment";
  39901. import "babylonjs/Shaders/passCube.fragment";
  39902. /**
  39903. * PassPostProcess which produces an output the same as it's input
  39904. */
  39905. export class PassPostProcess extends PostProcess {
  39906. /**
  39907. * Creates the PassPostProcess
  39908. * @param name The name of the effect.
  39909. * @param options The required width/height ratio to downsize to before computing the render pass.
  39910. * @param camera The camera to apply the render pass to.
  39911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39912. * @param engine The engine which the post process will be applied. (default: current engine)
  39913. * @param reusable If the post process can be reused on the same frame. (default: false)
  39914. * @param textureType The type of texture to be used when performing the post processing.
  39915. * @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)
  39916. */
  39917. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39918. }
  39919. /**
  39920. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39921. */
  39922. export class PassCubePostProcess extends PostProcess {
  39923. private _face;
  39924. /**
  39925. * Gets or sets the cube face to display.
  39926. * * 0 is +X
  39927. * * 1 is -X
  39928. * * 2 is +Y
  39929. * * 3 is -Y
  39930. * * 4 is +Z
  39931. * * 5 is -Z
  39932. */
  39933. face: number;
  39934. /**
  39935. * Creates the PassCubePostProcess
  39936. * @param name The name of the effect.
  39937. * @param options The required width/height ratio to downsize to before computing the render pass.
  39938. * @param camera The camera to apply the render pass to.
  39939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39940. * @param engine The engine which the post process will be applied. (default: current engine)
  39941. * @param reusable If the post process can be reused on the same frame. (default: false)
  39942. * @param textureType The type of texture to be used when performing the post processing.
  39943. * @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)
  39944. */
  39945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39946. }
  39947. }
  39948. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39949. /** @hidden */
  39950. export var anaglyphPixelShader: {
  39951. name: string;
  39952. shader: string;
  39953. };
  39954. }
  39955. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39956. import { Engine } from "babylonjs/Engines/engine";
  39957. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39958. import { Camera } from "babylonjs/Cameras/camera";
  39959. import "babylonjs/Shaders/anaglyph.fragment";
  39960. /**
  39961. * Postprocess used to generate anaglyphic rendering
  39962. */
  39963. export class AnaglyphPostProcess extends PostProcess {
  39964. private _passedProcess;
  39965. /**
  39966. * Creates a new AnaglyphPostProcess
  39967. * @param name defines postprocess name
  39968. * @param options defines creation options or target ratio scale
  39969. * @param rigCameras defines cameras using this postprocess
  39970. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39971. * @param engine defines hosting engine
  39972. * @param reusable defines if the postprocess will be reused multiple times per frame
  39973. */
  39974. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39975. }
  39976. }
  39977. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39978. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39979. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39980. import { Scene } from "babylonjs/scene";
  39981. import { Vector3 } from "babylonjs/Maths/math.vector";
  39982. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39983. /**
  39984. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39985. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39986. */
  39987. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39988. /**
  39989. * Creates a new AnaglyphArcRotateCamera
  39990. * @param name defines camera name
  39991. * @param alpha defines alpha angle (in radians)
  39992. * @param beta defines beta angle (in radians)
  39993. * @param radius defines radius
  39994. * @param target defines camera target
  39995. * @param interaxialDistance defines distance between each color axis
  39996. * @param scene defines the hosting scene
  39997. */
  39998. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39999. /**
  40000. * Gets camera class name
  40001. * @returns AnaglyphArcRotateCamera
  40002. */
  40003. getClassName(): string;
  40004. }
  40005. }
  40006. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40007. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40008. import { Scene } from "babylonjs/scene";
  40009. import { Vector3 } from "babylonjs/Maths/math.vector";
  40010. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40011. /**
  40012. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40013. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40014. */
  40015. export class AnaglyphFreeCamera extends FreeCamera {
  40016. /**
  40017. * Creates a new AnaglyphFreeCamera
  40018. * @param name defines camera name
  40019. * @param position defines initial position
  40020. * @param interaxialDistance defines distance between each color axis
  40021. * @param scene defines the hosting scene
  40022. */
  40023. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40024. /**
  40025. * Gets camera class name
  40026. * @returns AnaglyphFreeCamera
  40027. */
  40028. getClassName(): string;
  40029. }
  40030. }
  40031. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40032. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40033. import { Scene } from "babylonjs/scene";
  40034. import { Vector3 } from "babylonjs/Maths/math.vector";
  40035. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40036. /**
  40037. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40038. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40039. */
  40040. export class AnaglyphGamepadCamera extends GamepadCamera {
  40041. /**
  40042. * Creates a new AnaglyphGamepadCamera
  40043. * @param name defines camera name
  40044. * @param position defines initial position
  40045. * @param interaxialDistance defines distance between each color axis
  40046. * @param scene defines the hosting scene
  40047. */
  40048. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40049. /**
  40050. * Gets camera class name
  40051. * @returns AnaglyphGamepadCamera
  40052. */
  40053. getClassName(): string;
  40054. }
  40055. }
  40056. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40057. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40058. import { Scene } from "babylonjs/scene";
  40059. import { Vector3 } from "babylonjs/Maths/math.vector";
  40060. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40061. /**
  40062. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40063. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40064. */
  40065. export class AnaglyphUniversalCamera extends UniversalCamera {
  40066. /**
  40067. * Creates a new AnaglyphUniversalCamera
  40068. * @param name defines camera name
  40069. * @param position defines initial position
  40070. * @param interaxialDistance defines distance between each color axis
  40071. * @param scene defines the hosting scene
  40072. */
  40073. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40074. /**
  40075. * Gets camera class name
  40076. * @returns AnaglyphUniversalCamera
  40077. */
  40078. getClassName(): string;
  40079. }
  40080. }
  40081. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40082. /** @hidden */
  40083. export var stereoscopicInterlacePixelShader: {
  40084. name: string;
  40085. shader: string;
  40086. };
  40087. }
  40088. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40089. import { Camera } from "babylonjs/Cameras/camera";
  40090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40091. import { Engine } from "babylonjs/Engines/engine";
  40092. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40093. /**
  40094. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40095. */
  40096. export class StereoscopicInterlacePostProcess extends PostProcess {
  40097. private _stepSize;
  40098. private _passedProcess;
  40099. /**
  40100. * Initializes a StereoscopicInterlacePostProcess
  40101. * @param name The name of the effect.
  40102. * @param rigCameras The rig cameras to be appled to the post process
  40103. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40105. * @param engine The engine which the post process will be applied. (default: current engine)
  40106. * @param reusable If the post process can be reused on the same frame. (default: false)
  40107. */
  40108. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40109. }
  40110. }
  40111. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40112. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40114. import { Scene } from "babylonjs/scene";
  40115. import { Vector3 } from "babylonjs/Maths/math.vector";
  40116. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40117. /**
  40118. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40119. * @see http://doc.babylonjs.com/features/cameras
  40120. */
  40121. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40122. /**
  40123. * Creates a new StereoscopicArcRotateCamera
  40124. * @param name defines camera name
  40125. * @param alpha defines alpha angle (in radians)
  40126. * @param beta defines beta angle (in radians)
  40127. * @param radius defines radius
  40128. * @param target defines camera target
  40129. * @param interaxialDistance defines distance between each color axis
  40130. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40131. * @param scene defines the hosting scene
  40132. */
  40133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40134. /**
  40135. * Gets camera class name
  40136. * @returns StereoscopicArcRotateCamera
  40137. */
  40138. getClassName(): string;
  40139. }
  40140. }
  40141. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40142. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40143. import { Scene } from "babylonjs/scene";
  40144. import { Vector3 } from "babylonjs/Maths/math.vector";
  40145. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40146. /**
  40147. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40148. * @see http://doc.babylonjs.com/features/cameras
  40149. */
  40150. export class StereoscopicFreeCamera extends FreeCamera {
  40151. /**
  40152. * Creates a new StereoscopicFreeCamera
  40153. * @param name defines camera name
  40154. * @param position defines initial position
  40155. * @param interaxialDistance defines distance between each color axis
  40156. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40157. * @param scene defines the hosting scene
  40158. */
  40159. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40160. /**
  40161. * Gets camera class name
  40162. * @returns StereoscopicFreeCamera
  40163. */
  40164. getClassName(): string;
  40165. }
  40166. }
  40167. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40168. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40169. import { Scene } from "babylonjs/scene";
  40170. import { Vector3 } from "babylonjs/Maths/math.vector";
  40171. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40172. /**
  40173. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40174. * @see http://doc.babylonjs.com/features/cameras
  40175. */
  40176. export class StereoscopicGamepadCamera extends GamepadCamera {
  40177. /**
  40178. * Creates a new StereoscopicGamepadCamera
  40179. * @param name defines camera name
  40180. * @param position defines initial position
  40181. * @param interaxialDistance defines distance between each color axis
  40182. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40183. * @param scene defines the hosting scene
  40184. */
  40185. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40186. /**
  40187. * Gets camera class name
  40188. * @returns StereoscopicGamepadCamera
  40189. */
  40190. getClassName(): string;
  40191. }
  40192. }
  40193. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40194. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40195. import { Scene } from "babylonjs/scene";
  40196. import { Vector3 } from "babylonjs/Maths/math.vector";
  40197. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40198. /**
  40199. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40200. * @see http://doc.babylonjs.com/features/cameras
  40201. */
  40202. export class StereoscopicUniversalCamera extends UniversalCamera {
  40203. /**
  40204. * Creates a new StereoscopicUniversalCamera
  40205. * @param name defines camera name
  40206. * @param position defines initial position
  40207. * @param interaxialDistance defines distance between each color axis
  40208. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40209. * @param scene defines the hosting scene
  40210. */
  40211. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40212. /**
  40213. * Gets camera class name
  40214. * @returns StereoscopicUniversalCamera
  40215. */
  40216. getClassName(): string;
  40217. }
  40218. }
  40219. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40220. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40221. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40222. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40223. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40224. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40225. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40226. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40227. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40228. }
  40229. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40230. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40231. import { Scene } from "babylonjs/scene";
  40232. import { Vector3 } from "babylonjs/Maths/math.vector";
  40233. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40234. /**
  40235. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40236. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40237. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40238. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40239. */
  40240. export class VirtualJoysticksCamera extends FreeCamera {
  40241. /**
  40242. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40243. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40244. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40245. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40246. * @param name Define the name of the camera in the scene
  40247. * @param position Define the start position of the camera in the scene
  40248. * @param scene Define the scene the camera belongs to
  40249. */
  40250. constructor(name: string, position: Vector3, scene: Scene);
  40251. /**
  40252. * Gets the current object class name.
  40253. * @return the class name
  40254. */
  40255. getClassName(): string;
  40256. }
  40257. }
  40258. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40259. import { Matrix } from "babylonjs/Maths/math.vector";
  40260. /**
  40261. * This represents all the required metrics to create a VR camera.
  40262. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40263. */
  40264. export class VRCameraMetrics {
  40265. /**
  40266. * Define the horizontal resolution off the screen.
  40267. */
  40268. hResolution: number;
  40269. /**
  40270. * Define the vertical resolution off the screen.
  40271. */
  40272. vResolution: number;
  40273. /**
  40274. * Define the horizontal screen size.
  40275. */
  40276. hScreenSize: number;
  40277. /**
  40278. * Define the vertical screen size.
  40279. */
  40280. vScreenSize: number;
  40281. /**
  40282. * Define the vertical screen center position.
  40283. */
  40284. vScreenCenter: number;
  40285. /**
  40286. * Define the distance of the eyes to the screen.
  40287. */
  40288. eyeToScreenDistance: number;
  40289. /**
  40290. * Define the distance between both lenses
  40291. */
  40292. lensSeparationDistance: number;
  40293. /**
  40294. * Define the distance between both viewer's eyes.
  40295. */
  40296. interpupillaryDistance: number;
  40297. /**
  40298. * Define the distortion factor of the VR postprocess.
  40299. * Please, touch with care.
  40300. */
  40301. distortionK: number[];
  40302. /**
  40303. * Define the chromatic aberration correction factors for the VR post process.
  40304. */
  40305. chromaAbCorrection: number[];
  40306. /**
  40307. * Define the scale factor of the post process.
  40308. * The smaller the better but the slower.
  40309. */
  40310. postProcessScaleFactor: number;
  40311. /**
  40312. * Define an offset for the lens center.
  40313. */
  40314. lensCenterOffset: number;
  40315. /**
  40316. * Define if the current vr camera should compensate the distortion of the lense or not.
  40317. */
  40318. compensateDistortion: boolean;
  40319. /**
  40320. * Defines if multiview should be enabled when rendering (Default: false)
  40321. */
  40322. multiviewEnabled: boolean;
  40323. /**
  40324. * Gets the rendering aspect ratio based on the provided resolutions.
  40325. */
  40326. readonly aspectRatio: number;
  40327. /**
  40328. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40329. */
  40330. readonly aspectRatioFov: number;
  40331. /**
  40332. * @hidden
  40333. */
  40334. readonly leftHMatrix: Matrix;
  40335. /**
  40336. * @hidden
  40337. */
  40338. readonly rightHMatrix: Matrix;
  40339. /**
  40340. * @hidden
  40341. */
  40342. readonly leftPreViewMatrix: Matrix;
  40343. /**
  40344. * @hidden
  40345. */
  40346. readonly rightPreViewMatrix: Matrix;
  40347. /**
  40348. * Get the default VRMetrics based on the most generic setup.
  40349. * @returns the default vr metrics
  40350. */
  40351. static GetDefault(): VRCameraMetrics;
  40352. }
  40353. }
  40354. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40355. /** @hidden */
  40356. export var vrDistortionCorrectionPixelShader: {
  40357. name: string;
  40358. shader: string;
  40359. };
  40360. }
  40361. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40362. import { Camera } from "babylonjs/Cameras/camera";
  40363. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40364. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40365. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40366. /**
  40367. * VRDistortionCorrectionPostProcess used for mobile VR
  40368. */
  40369. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40370. private _isRightEye;
  40371. private _distortionFactors;
  40372. private _postProcessScaleFactor;
  40373. private _lensCenterOffset;
  40374. private _scaleIn;
  40375. private _scaleFactor;
  40376. private _lensCenter;
  40377. /**
  40378. * Initializes the VRDistortionCorrectionPostProcess
  40379. * @param name The name of the effect.
  40380. * @param camera The camera to apply the render pass to.
  40381. * @param isRightEye If this is for the right eye distortion
  40382. * @param vrMetrics All the required metrics for the VR camera
  40383. */
  40384. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40385. }
  40386. }
  40387. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40388. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40389. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40390. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40391. import { Scene } from "babylonjs/scene";
  40392. import { Vector3 } from "babylonjs/Maths/math.vector";
  40393. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40394. import "babylonjs/Cameras/RigModes/vrRigMode";
  40395. /**
  40396. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40397. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40398. */
  40399. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40400. /**
  40401. * Creates a new VRDeviceOrientationArcRotateCamera
  40402. * @param name defines camera name
  40403. * @param alpha defines the camera rotation along the logitudinal axis
  40404. * @param beta defines the camera rotation along the latitudinal axis
  40405. * @param radius defines the camera distance from its target
  40406. * @param target defines the camera target
  40407. * @param scene defines the scene the camera belongs to
  40408. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40409. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40410. */
  40411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40412. /**
  40413. * Gets camera class name
  40414. * @returns VRDeviceOrientationArcRotateCamera
  40415. */
  40416. getClassName(): string;
  40417. }
  40418. }
  40419. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40420. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40421. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40422. import { Scene } from "babylonjs/scene";
  40423. import { Vector3 } from "babylonjs/Maths/math.vector";
  40424. import "babylonjs/Cameras/RigModes/vrRigMode";
  40425. /**
  40426. * Camera used to simulate VR rendering (based on FreeCamera)
  40427. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40428. */
  40429. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40430. /**
  40431. * Creates a new VRDeviceOrientationFreeCamera
  40432. * @param name defines camera name
  40433. * @param position defines the start position of the camera
  40434. * @param scene defines the scene the camera belongs to
  40435. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40436. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40437. */
  40438. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40439. /**
  40440. * Gets camera class name
  40441. * @returns VRDeviceOrientationFreeCamera
  40442. */
  40443. getClassName(): string;
  40444. }
  40445. }
  40446. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40447. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40448. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40449. import { Scene } from "babylonjs/scene";
  40450. import { Vector3 } from "babylonjs/Maths/math.vector";
  40451. import "babylonjs/Gamepads/gamepadSceneComponent";
  40452. /**
  40453. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40454. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40455. */
  40456. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40457. /**
  40458. * Creates a new VRDeviceOrientationGamepadCamera
  40459. * @param name defines camera name
  40460. * @param position defines the start position of the camera
  40461. * @param scene defines the scene the camera belongs to
  40462. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40463. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40464. */
  40465. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40466. /**
  40467. * Gets camera class name
  40468. * @returns VRDeviceOrientationGamepadCamera
  40469. */
  40470. getClassName(): string;
  40471. }
  40472. }
  40473. declare module "babylonjs/Materials/pushMaterial" {
  40474. import { Nullable } from "babylonjs/types";
  40475. import { Scene } from "babylonjs/scene";
  40476. import { Matrix } from "babylonjs/Maths/math.vector";
  40477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40478. import { Mesh } from "babylonjs/Meshes/mesh";
  40479. import { Material } from "babylonjs/Materials/material";
  40480. import { Effect } from "babylonjs/Materials/effect";
  40481. /**
  40482. * Base class of materials working in push mode in babylon JS
  40483. * @hidden
  40484. */
  40485. export class PushMaterial extends Material {
  40486. protected _activeEffect: Effect;
  40487. protected _normalMatrix: Matrix;
  40488. /**
  40489. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40490. * This means that the material can keep using a previous shader while a new one is being compiled.
  40491. * This is mostly used when shader parallel compilation is supported (true by default)
  40492. */
  40493. allowShaderHotSwapping: boolean;
  40494. constructor(name: string, scene: Scene);
  40495. getEffect(): Effect;
  40496. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40497. /**
  40498. * Binds the given world matrix to the active effect
  40499. *
  40500. * @param world the matrix to bind
  40501. */
  40502. bindOnlyWorldMatrix(world: Matrix): void;
  40503. /**
  40504. * Binds the given normal matrix to the active effect
  40505. *
  40506. * @param normalMatrix the matrix to bind
  40507. */
  40508. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40509. bind(world: Matrix, mesh?: Mesh): void;
  40510. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40511. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40512. }
  40513. }
  40514. declare module "babylonjs/Materials/materialFlags" {
  40515. /**
  40516. * This groups all the flags used to control the materials channel.
  40517. */
  40518. export class MaterialFlags {
  40519. private static _DiffuseTextureEnabled;
  40520. /**
  40521. * Are diffuse textures enabled in the application.
  40522. */
  40523. static DiffuseTextureEnabled: boolean;
  40524. private static _AmbientTextureEnabled;
  40525. /**
  40526. * Are ambient textures enabled in the application.
  40527. */
  40528. static AmbientTextureEnabled: boolean;
  40529. private static _OpacityTextureEnabled;
  40530. /**
  40531. * Are opacity textures enabled in the application.
  40532. */
  40533. static OpacityTextureEnabled: boolean;
  40534. private static _ReflectionTextureEnabled;
  40535. /**
  40536. * Are reflection textures enabled in the application.
  40537. */
  40538. static ReflectionTextureEnabled: boolean;
  40539. private static _EmissiveTextureEnabled;
  40540. /**
  40541. * Are emissive textures enabled in the application.
  40542. */
  40543. static EmissiveTextureEnabled: boolean;
  40544. private static _SpecularTextureEnabled;
  40545. /**
  40546. * Are specular textures enabled in the application.
  40547. */
  40548. static SpecularTextureEnabled: boolean;
  40549. private static _BumpTextureEnabled;
  40550. /**
  40551. * Are bump textures enabled in the application.
  40552. */
  40553. static BumpTextureEnabled: boolean;
  40554. private static _LightmapTextureEnabled;
  40555. /**
  40556. * Are lightmap textures enabled in the application.
  40557. */
  40558. static LightmapTextureEnabled: boolean;
  40559. private static _RefractionTextureEnabled;
  40560. /**
  40561. * Are refraction textures enabled in the application.
  40562. */
  40563. static RefractionTextureEnabled: boolean;
  40564. private static _ColorGradingTextureEnabled;
  40565. /**
  40566. * Are color grading textures enabled in the application.
  40567. */
  40568. static ColorGradingTextureEnabled: boolean;
  40569. private static _FresnelEnabled;
  40570. /**
  40571. * Are fresnels enabled in the application.
  40572. */
  40573. static FresnelEnabled: boolean;
  40574. private static _ClearCoatTextureEnabled;
  40575. /**
  40576. * Are clear coat textures enabled in the application.
  40577. */
  40578. static ClearCoatTextureEnabled: boolean;
  40579. private static _ClearCoatBumpTextureEnabled;
  40580. /**
  40581. * Are clear coat bump textures enabled in the application.
  40582. */
  40583. static ClearCoatBumpTextureEnabled: boolean;
  40584. private static _ClearCoatTintTextureEnabled;
  40585. /**
  40586. * Are clear coat tint textures enabled in the application.
  40587. */
  40588. static ClearCoatTintTextureEnabled: boolean;
  40589. private static _SheenTextureEnabled;
  40590. /**
  40591. * Are sheen textures enabled in the application.
  40592. */
  40593. static SheenTextureEnabled: boolean;
  40594. private static _AnisotropicTextureEnabled;
  40595. /**
  40596. * Are anisotropic textures enabled in the application.
  40597. */
  40598. static AnisotropicTextureEnabled: boolean;
  40599. private static _ThicknessTextureEnabled;
  40600. /**
  40601. * Are thickness textures enabled in the application.
  40602. */
  40603. static ThicknessTextureEnabled: boolean;
  40604. }
  40605. }
  40606. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40607. /** @hidden */
  40608. export var defaultFragmentDeclaration: {
  40609. name: string;
  40610. shader: string;
  40611. };
  40612. }
  40613. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40614. /** @hidden */
  40615. export var defaultUboDeclaration: {
  40616. name: string;
  40617. shader: string;
  40618. };
  40619. }
  40620. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40621. /** @hidden */
  40622. export var lightFragmentDeclaration: {
  40623. name: string;
  40624. shader: string;
  40625. };
  40626. }
  40627. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40628. /** @hidden */
  40629. export var lightUboDeclaration: {
  40630. name: string;
  40631. shader: string;
  40632. };
  40633. }
  40634. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40635. /** @hidden */
  40636. export var lightsFragmentFunctions: {
  40637. name: string;
  40638. shader: string;
  40639. };
  40640. }
  40641. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40642. /** @hidden */
  40643. export var shadowsFragmentFunctions: {
  40644. name: string;
  40645. shader: string;
  40646. };
  40647. }
  40648. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40649. /** @hidden */
  40650. export var fresnelFunction: {
  40651. name: string;
  40652. shader: string;
  40653. };
  40654. }
  40655. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40656. /** @hidden */
  40657. export var reflectionFunction: {
  40658. name: string;
  40659. shader: string;
  40660. };
  40661. }
  40662. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40663. /** @hidden */
  40664. export var bumpFragmentFunctions: {
  40665. name: string;
  40666. shader: string;
  40667. };
  40668. }
  40669. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40670. /** @hidden */
  40671. export var logDepthDeclaration: {
  40672. name: string;
  40673. shader: string;
  40674. };
  40675. }
  40676. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40677. /** @hidden */
  40678. export var bumpFragment: {
  40679. name: string;
  40680. shader: string;
  40681. };
  40682. }
  40683. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40684. /** @hidden */
  40685. export var depthPrePass: {
  40686. name: string;
  40687. shader: string;
  40688. };
  40689. }
  40690. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40691. /** @hidden */
  40692. export var lightFragment: {
  40693. name: string;
  40694. shader: string;
  40695. };
  40696. }
  40697. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40698. /** @hidden */
  40699. export var logDepthFragment: {
  40700. name: string;
  40701. shader: string;
  40702. };
  40703. }
  40704. declare module "babylonjs/Shaders/default.fragment" {
  40705. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40706. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40707. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40708. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40709. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40710. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40711. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40712. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40713. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40714. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40715. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40716. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40718. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40719. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40721. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40722. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40723. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40724. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40726. /** @hidden */
  40727. export var defaultPixelShader: {
  40728. name: string;
  40729. shader: string;
  40730. };
  40731. }
  40732. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40733. /** @hidden */
  40734. export var defaultVertexDeclaration: {
  40735. name: string;
  40736. shader: string;
  40737. };
  40738. }
  40739. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40740. /** @hidden */
  40741. export var bumpVertexDeclaration: {
  40742. name: string;
  40743. shader: string;
  40744. };
  40745. }
  40746. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40747. /** @hidden */
  40748. export var bumpVertex: {
  40749. name: string;
  40750. shader: string;
  40751. };
  40752. }
  40753. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40754. /** @hidden */
  40755. export var fogVertex: {
  40756. name: string;
  40757. shader: string;
  40758. };
  40759. }
  40760. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40761. /** @hidden */
  40762. export var shadowsVertex: {
  40763. name: string;
  40764. shader: string;
  40765. };
  40766. }
  40767. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40768. /** @hidden */
  40769. export var pointCloudVertex: {
  40770. name: string;
  40771. shader: string;
  40772. };
  40773. }
  40774. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40775. /** @hidden */
  40776. export var logDepthVertex: {
  40777. name: string;
  40778. shader: string;
  40779. };
  40780. }
  40781. declare module "babylonjs/Shaders/default.vertex" {
  40782. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40783. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40785. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40786. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40787. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40788. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40789. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40790. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40791. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40793. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40794. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40795. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40796. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40798. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40800. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40801. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40802. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40803. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40804. /** @hidden */
  40805. export var defaultVertexShader: {
  40806. name: string;
  40807. shader: string;
  40808. };
  40809. }
  40810. declare module "babylonjs/Materials/standardMaterial" {
  40811. import { SmartArray } from "babylonjs/Misc/smartArray";
  40812. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40813. import { Nullable } from "babylonjs/types";
  40814. import { Scene } from "babylonjs/scene";
  40815. import { Matrix } from "babylonjs/Maths/math.vector";
  40816. import { Color3 } from "babylonjs/Maths/math.color";
  40817. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40819. import { Mesh } from "babylonjs/Meshes/mesh";
  40820. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40821. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40822. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40823. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40824. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40826. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40827. import "babylonjs/Shaders/default.fragment";
  40828. import "babylonjs/Shaders/default.vertex";
  40829. /** @hidden */
  40830. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40831. MAINUV1: boolean;
  40832. MAINUV2: boolean;
  40833. DIFFUSE: boolean;
  40834. DIFFUSEDIRECTUV: number;
  40835. AMBIENT: boolean;
  40836. AMBIENTDIRECTUV: number;
  40837. OPACITY: boolean;
  40838. OPACITYDIRECTUV: number;
  40839. OPACITYRGB: boolean;
  40840. REFLECTION: boolean;
  40841. EMISSIVE: boolean;
  40842. EMISSIVEDIRECTUV: number;
  40843. SPECULAR: boolean;
  40844. SPECULARDIRECTUV: number;
  40845. BUMP: boolean;
  40846. BUMPDIRECTUV: number;
  40847. PARALLAX: boolean;
  40848. PARALLAXOCCLUSION: boolean;
  40849. SPECULAROVERALPHA: boolean;
  40850. CLIPPLANE: boolean;
  40851. CLIPPLANE2: boolean;
  40852. CLIPPLANE3: boolean;
  40853. CLIPPLANE4: boolean;
  40854. ALPHATEST: boolean;
  40855. DEPTHPREPASS: boolean;
  40856. ALPHAFROMDIFFUSE: boolean;
  40857. POINTSIZE: boolean;
  40858. FOG: boolean;
  40859. SPECULARTERM: boolean;
  40860. DIFFUSEFRESNEL: boolean;
  40861. OPACITYFRESNEL: boolean;
  40862. REFLECTIONFRESNEL: boolean;
  40863. REFRACTIONFRESNEL: boolean;
  40864. EMISSIVEFRESNEL: boolean;
  40865. FRESNEL: boolean;
  40866. NORMAL: boolean;
  40867. UV1: boolean;
  40868. UV2: boolean;
  40869. VERTEXCOLOR: boolean;
  40870. VERTEXALPHA: boolean;
  40871. NUM_BONE_INFLUENCERS: number;
  40872. BonesPerMesh: number;
  40873. BONETEXTURE: boolean;
  40874. INSTANCES: boolean;
  40875. GLOSSINESS: boolean;
  40876. ROUGHNESS: boolean;
  40877. EMISSIVEASILLUMINATION: boolean;
  40878. LINKEMISSIVEWITHDIFFUSE: boolean;
  40879. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40880. LIGHTMAP: boolean;
  40881. LIGHTMAPDIRECTUV: number;
  40882. OBJECTSPACE_NORMALMAP: boolean;
  40883. USELIGHTMAPASSHADOWMAP: boolean;
  40884. REFLECTIONMAP_3D: boolean;
  40885. REFLECTIONMAP_SPHERICAL: boolean;
  40886. REFLECTIONMAP_PLANAR: boolean;
  40887. REFLECTIONMAP_CUBIC: boolean;
  40888. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40889. REFLECTIONMAP_PROJECTION: boolean;
  40890. REFLECTIONMAP_SKYBOX: boolean;
  40891. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40892. REFLECTIONMAP_EXPLICIT: boolean;
  40893. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40894. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40895. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40896. INVERTCUBICMAP: boolean;
  40897. LOGARITHMICDEPTH: boolean;
  40898. REFRACTION: boolean;
  40899. REFRACTIONMAP_3D: boolean;
  40900. REFLECTIONOVERALPHA: boolean;
  40901. TWOSIDEDLIGHTING: boolean;
  40902. SHADOWFLOAT: boolean;
  40903. MORPHTARGETS: boolean;
  40904. MORPHTARGETS_NORMAL: boolean;
  40905. MORPHTARGETS_TANGENT: boolean;
  40906. MORPHTARGETS_UV: boolean;
  40907. NUM_MORPH_INFLUENCERS: number;
  40908. NONUNIFORMSCALING: boolean;
  40909. PREMULTIPLYALPHA: boolean;
  40910. IMAGEPROCESSING: boolean;
  40911. VIGNETTE: boolean;
  40912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40913. VIGNETTEBLENDMODEOPAQUE: boolean;
  40914. TONEMAPPING: boolean;
  40915. TONEMAPPING_ACES: boolean;
  40916. CONTRAST: boolean;
  40917. COLORCURVES: boolean;
  40918. COLORGRADING: boolean;
  40919. COLORGRADING3D: boolean;
  40920. SAMPLER3DGREENDEPTH: boolean;
  40921. SAMPLER3DBGRMAP: boolean;
  40922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40923. MULTIVIEW: boolean;
  40924. /**
  40925. * If the reflection texture on this material is in linear color space
  40926. * @hidden
  40927. */
  40928. IS_REFLECTION_LINEAR: boolean;
  40929. /**
  40930. * If the refraction texture on this material is in linear color space
  40931. * @hidden
  40932. */
  40933. IS_REFRACTION_LINEAR: boolean;
  40934. EXPOSURE: boolean;
  40935. constructor();
  40936. setReflectionMode(modeToEnable: string): void;
  40937. }
  40938. /**
  40939. * This is the default material used in Babylon. It is the best trade off between quality
  40940. * and performances.
  40941. * @see http://doc.babylonjs.com/babylon101/materials
  40942. */
  40943. export class StandardMaterial extends PushMaterial {
  40944. private _diffuseTexture;
  40945. /**
  40946. * The basic texture of the material as viewed under a light.
  40947. */
  40948. diffuseTexture: Nullable<BaseTexture>;
  40949. private _ambientTexture;
  40950. /**
  40951. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40952. */
  40953. ambientTexture: Nullable<BaseTexture>;
  40954. private _opacityTexture;
  40955. /**
  40956. * Define the transparency of the material from a texture.
  40957. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40958. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40959. */
  40960. opacityTexture: Nullable<BaseTexture>;
  40961. private _reflectionTexture;
  40962. /**
  40963. * Define the texture used to display the reflection.
  40964. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40965. */
  40966. reflectionTexture: Nullable<BaseTexture>;
  40967. private _emissiveTexture;
  40968. /**
  40969. * Define texture of the material as if self lit.
  40970. * This will be mixed in the final result even in the absence of light.
  40971. */
  40972. emissiveTexture: Nullable<BaseTexture>;
  40973. private _specularTexture;
  40974. /**
  40975. * Define how the color and intensity of the highlight given by the light in the material.
  40976. */
  40977. specularTexture: Nullable<BaseTexture>;
  40978. private _bumpTexture;
  40979. /**
  40980. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40981. * 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.
  40982. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40983. */
  40984. bumpTexture: Nullable<BaseTexture>;
  40985. private _lightmapTexture;
  40986. /**
  40987. * Complex lighting can be computationally expensive to compute at runtime.
  40988. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40989. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40990. */
  40991. lightmapTexture: Nullable<BaseTexture>;
  40992. private _refractionTexture;
  40993. /**
  40994. * Define the texture used to display the refraction.
  40995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40996. */
  40997. refractionTexture: Nullable<BaseTexture>;
  40998. /**
  40999. * The color of the material lit by the environmental background lighting.
  41000. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41001. */
  41002. ambientColor: Color3;
  41003. /**
  41004. * The basic color of the material as viewed under a light.
  41005. */
  41006. diffuseColor: Color3;
  41007. /**
  41008. * Define how the color and intensity of the highlight given by the light in the material.
  41009. */
  41010. specularColor: Color3;
  41011. /**
  41012. * Define the color of the material as if self lit.
  41013. * This will be mixed in the final result even in the absence of light.
  41014. */
  41015. emissiveColor: Color3;
  41016. /**
  41017. * Defines how sharp are the highlights in the material.
  41018. * The bigger the value the sharper giving a more glossy feeling to the result.
  41019. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41020. */
  41021. specularPower: number;
  41022. private _useAlphaFromDiffuseTexture;
  41023. /**
  41024. * Does the transparency come from the diffuse texture alpha channel.
  41025. */
  41026. useAlphaFromDiffuseTexture: boolean;
  41027. private _useEmissiveAsIllumination;
  41028. /**
  41029. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41030. */
  41031. useEmissiveAsIllumination: boolean;
  41032. private _linkEmissiveWithDiffuse;
  41033. /**
  41034. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41035. * the emissive level when the final color is close to one.
  41036. */
  41037. linkEmissiveWithDiffuse: boolean;
  41038. private _useSpecularOverAlpha;
  41039. /**
  41040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41042. */
  41043. useSpecularOverAlpha: boolean;
  41044. private _useReflectionOverAlpha;
  41045. /**
  41046. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41047. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41048. */
  41049. useReflectionOverAlpha: boolean;
  41050. private _disableLighting;
  41051. /**
  41052. * Does lights from the scene impacts this material.
  41053. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41054. */
  41055. disableLighting: boolean;
  41056. private _useObjectSpaceNormalMap;
  41057. /**
  41058. * Allows using an object space normal map (instead of tangent space).
  41059. */
  41060. useObjectSpaceNormalMap: boolean;
  41061. private _useParallax;
  41062. /**
  41063. * Is parallax enabled or not.
  41064. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41065. */
  41066. useParallax: boolean;
  41067. private _useParallaxOcclusion;
  41068. /**
  41069. * Is parallax occlusion enabled or not.
  41070. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41072. */
  41073. useParallaxOcclusion: boolean;
  41074. /**
  41075. * 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.
  41076. */
  41077. parallaxScaleBias: number;
  41078. private _roughness;
  41079. /**
  41080. * Helps to define how blurry the reflections should appears in the material.
  41081. */
  41082. roughness: number;
  41083. /**
  41084. * In case of refraction, define the value of the index of refraction.
  41085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41086. */
  41087. indexOfRefraction: number;
  41088. /**
  41089. * Invert the refraction texture alongside the y axis.
  41090. * It can be useful with procedural textures or probe for instance.
  41091. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41092. */
  41093. invertRefractionY: boolean;
  41094. /**
  41095. * Defines the alpha limits in alpha test mode.
  41096. */
  41097. alphaCutOff: number;
  41098. private _useLightmapAsShadowmap;
  41099. /**
  41100. * In case of light mapping, define whether the map contains light or shadow informations.
  41101. */
  41102. useLightmapAsShadowmap: boolean;
  41103. private _diffuseFresnelParameters;
  41104. /**
  41105. * Define the diffuse fresnel parameters of the material.
  41106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41107. */
  41108. diffuseFresnelParameters: FresnelParameters;
  41109. private _opacityFresnelParameters;
  41110. /**
  41111. * Define the opacity fresnel parameters of the material.
  41112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41113. */
  41114. opacityFresnelParameters: FresnelParameters;
  41115. private _reflectionFresnelParameters;
  41116. /**
  41117. * Define the reflection fresnel parameters of the material.
  41118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41119. */
  41120. reflectionFresnelParameters: FresnelParameters;
  41121. private _refractionFresnelParameters;
  41122. /**
  41123. * Define the refraction fresnel parameters of the material.
  41124. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41125. */
  41126. refractionFresnelParameters: FresnelParameters;
  41127. private _emissiveFresnelParameters;
  41128. /**
  41129. * Define the emissive fresnel parameters of the material.
  41130. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41131. */
  41132. emissiveFresnelParameters: FresnelParameters;
  41133. private _useReflectionFresnelFromSpecular;
  41134. /**
  41135. * If true automatically deducts the fresnels values from the material specularity.
  41136. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41137. */
  41138. useReflectionFresnelFromSpecular: boolean;
  41139. private _useGlossinessFromSpecularMapAlpha;
  41140. /**
  41141. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41142. */
  41143. useGlossinessFromSpecularMapAlpha: boolean;
  41144. private _maxSimultaneousLights;
  41145. /**
  41146. * Defines the maximum number of lights that can be used in the material
  41147. */
  41148. maxSimultaneousLights: number;
  41149. private _invertNormalMapX;
  41150. /**
  41151. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41152. */
  41153. invertNormalMapX: boolean;
  41154. private _invertNormalMapY;
  41155. /**
  41156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41157. */
  41158. invertNormalMapY: boolean;
  41159. private _twoSidedLighting;
  41160. /**
  41161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41162. */
  41163. twoSidedLighting: boolean;
  41164. /**
  41165. * Default configuration related to image processing available in the standard Material.
  41166. */
  41167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41168. /**
  41169. * Gets the image processing configuration used either in this material.
  41170. */
  41171. /**
  41172. * Sets the Default image processing configuration used either in the this material.
  41173. *
  41174. * If sets to null, the scene one is in use.
  41175. */
  41176. imageProcessingConfiguration: ImageProcessingConfiguration;
  41177. /**
  41178. * Keep track of the image processing observer to allow dispose and replace.
  41179. */
  41180. private _imageProcessingObserver;
  41181. /**
  41182. * Attaches a new image processing configuration to the Standard Material.
  41183. * @param configuration
  41184. */
  41185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41186. /**
  41187. * Gets wether the color curves effect is enabled.
  41188. */
  41189. /**
  41190. * Sets wether the color curves effect is enabled.
  41191. */
  41192. cameraColorCurvesEnabled: boolean;
  41193. /**
  41194. * Gets wether the color grading effect is enabled.
  41195. */
  41196. /**
  41197. * Gets wether the color grading effect is enabled.
  41198. */
  41199. cameraColorGradingEnabled: boolean;
  41200. /**
  41201. * Gets wether tonemapping is enabled or not.
  41202. */
  41203. /**
  41204. * Sets wether tonemapping is enabled or not
  41205. */
  41206. cameraToneMappingEnabled: boolean;
  41207. /**
  41208. * The camera exposure used on this material.
  41209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41210. * This corresponds to a photographic exposure.
  41211. */
  41212. /**
  41213. * The camera exposure used on this material.
  41214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41215. * This corresponds to a photographic exposure.
  41216. */
  41217. cameraExposure: number;
  41218. /**
  41219. * Gets The camera contrast used on this material.
  41220. */
  41221. /**
  41222. * Sets The camera contrast used on this material.
  41223. */
  41224. cameraContrast: number;
  41225. /**
  41226. * Gets the Color Grading 2D Lookup Texture.
  41227. */
  41228. /**
  41229. * Sets the Color Grading 2D Lookup Texture.
  41230. */
  41231. cameraColorGradingTexture: Nullable<BaseTexture>;
  41232. /**
  41233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41235. * 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;
  41236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41237. */
  41238. /**
  41239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41241. * 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;
  41242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41243. */
  41244. cameraColorCurves: Nullable<ColorCurves>;
  41245. /**
  41246. * Custom callback helping to override the default shader used in the material.
  41247. */
  41248. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41249. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41250. protected _worldViewProjectionMatrix: Matrix;
  41251. protected _globalAmbientColor: Color3;
  41252. protected _useLogarithmicDepth: boolean;
  41253. /**
  41254. * Instantiates a new standard material.
  41255. * This is the default material used in Babylon. It is the best trade off between quality
  41256. * and performances.
  41257. * @see http://doc.babylonjs.com/babylon101/materials
  41258. * @param name Define the name of the material in the scene
  41259. * @param scene Define the scene the material belong to
  41260. */
  41261. constructor(name: string, scene: Scene);
  41262. /**
  41263. * Gets a boolean indicating that current material needs to register RTT
  41264. */
  41265. readonly hasRenderTargetTextures: boolean;
  41266. /**
  41267. * Gets the current class name of the material e.g. "StandardMaterial"
  41268. * Mainly use in serialization.
  41269. * @returns the class name
  41270. */
  41271. getClassName(): string;
  41272. /**
  41273. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41274. * You can try switching to logarithmic depth.
  41275. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41276. */
  41277. useLogarithmicDepth: boolean;
  41278. /**
  41279. * Specifies if the material will require alpha blending
  41280. * @returns a boolean specifying if alpha blending is needed
  41281. */
  41282. needAlphaBlending(): boolean;
  41283. /**
  41284. * Specifies if this material should be rendered in alpha test mode
  41285. * @returns a boolean specifying if an alpha test is needed.
  41286. */
  41287. needAlphaTesting(): boolean;
  41288. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41289. /**
  41290. * Get the texture used for alpha test purpose.
  41291. * @returns the diffuse texture in case of the standard material.
  41292. */
  41293. getAlphaTestTexture(): Nullable<BaseTexture>;
  41294. /**
  41295. * Get if the submesh is ready to be used and all its information available.
  41296. * Child classes can use it to update shaders
  41297. * @param mesh defines the mesh to check
  41298. * @param subMesh defines which submesh to check
  41299. * @param useInstances specifies that instances should be used
  41300. * @returns a boolean indicating that the submesh is ready or not
  41301. */
  41302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41303. /**
  41304. * Builds the material UBO layouts.
  41305. * Used internally during the effect preparation.
  41306. */
  41307. buildUniformLayout(): void;
  41308. /**
  41309. * Unbinds the material from the mesh
  41310. */
  41311. unbind(): void;
  41312. /**
  41313. * Binds the submesh to this material by preparing the effect and shader to draw
  41314. * @param world defines the world transformation matrix
  41315. * @param mesh defines the mesh containing the submesh
  41316. * @param subMesh defines the submesh to bind the material to
  41317. */
  41318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41319. /**
  41320. * Get the list of animatables in the material.
  41321. * @returns the list of animatables object used in the material
  41322. */
  41323. getAnimatables(): IAnimatable[];
  41324. /**
  41325. * Gets the active textures from the material
  41326. * @returns an array of textures
  41327. */
  41328. getActiveTextures(): BaseTexture[];
  41329. /**
  41330. * Specifies if the material uses a texture
  41331. * @param texture defines the texture to check against the material
  41332. * @returns a boolean specifying if the material uses the texture
  41333. */
  41334. hasTexture(texture: BaseTexture): boolean;
  41335. /**
  41336. * Disposes the material
  41337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41339. */
  41340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41341. /**
  41342. * Makes a duplicate of the material, and gives it a new name
  41343. * @param name defines the new name for the duplicated material
  41344. * @returns the cloned material
  41345. */
  41346. clone(name: string): StandardMaterial;
  41347. /**
  41348. * Serializes this material in a JSON representation
  41349. * @returns the serialized material object
  41350. */
  41351. serialize(): any;
  41352. /**
  41353. * Creates a standard material from parsed material data
  41354. * @param source defines the JSON representation of the material
  41355. * @param scene defines the hosting scene
  41356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41357. * @returns a new standard material
  41358. */
  41359. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41360. /**
  41361. * Are diffuse textures enabled in the application.
  41362. */
  41363. static DiffuseTextureEnabled: boolean;
  41364. /**
  41365. * Are ambient textures enabled in the application.
  41366. */
  41367. static AmbientTextureEnabled: boolean;
  41368. /**
  41369. * Are opacity textures enabled in the application.
  41370. */
  41371. static OpacityTextureEnabled: boolean;
  41372. /**
  41373. * Are reflection textures enabled in the application.
  41374. */
  41375. static ReflectionTextureEnabled: boolean;
  41376. /**
  41377. * Are emissive textures enabled in the application.
  41378. */
  41379. static EmissiveTextureEnabled: boolean;
  41380. /**
  41381. * Are specular textures enabled in the application.
  41382. */
  41383. static SpecularTextureEnabled: boolean;
  41384. /**
  41385. * Are bump textures enabled in the application.
  41386. */
  41387. static BumpTextureEnabled: boolean;
  41388. /**
  41389. * Are lightmap textures enabled in the application.
  41390. */
  41391. static LightmapTextureEnabled: boolean;
  41392. /**
  41393. * Are refraction textures enabled in the application.
  41394. */
  41395. static RefractionTextureEnabled: boolean;
  41396. /**
  41397. * Are color grading textures enabled in the application.
  41398. */
  41399. static ColorGradingTextureEnabled: boolean;
  41400. /**
  41401. * Are fresnels enabled in the application.
  41402. */
  41403. static FresnelEnabled: boolean;
  41404. }
  41405. }
  41406. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41407. import { Scene } from "babylonjs/scene";
  41408. import { Texture } from "babylonjs/Materials/Textures/texture";
  41409. /**
  41410. * A class extending Texture allowing drawing on a texture
  41411. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41412. */
  41413. export class DynamicTexture extends Texture {
  41414. private _generateMipMaps;
  41415. private _canvas;
  41416. private _context;
  41417. private _engine;
  41418. /**
  41419. * Creates a DynamicTexture
  41420. * @param name defines the name of the texture
  41421. * @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
  41422. * @param scene defines the scene where you want the texture
  41423. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41424. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41425. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41426. */
  41427. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41428. /**
  41429. * Get the current class name of the texture useful for serialization or dynamic coding.
  41430. * @returns "DynamicTexture"
  41431. */
  41432. getClassName(): string;
  41433. /**
  41434. * Gets the current state of canRescale
  41435. */
  41436. readonly canRescale: boolean;
  41437. private _recreate;
  41438. /**
  41439. * Scales the texture
  41440. * @param ratio the scale factor to apply to both width and height
  41441. */
  41442. scale(ratio: number): void;
  41443. /**
  41444. * Resizes the texture
  41445. * @param width the new width
  41446. * @param height the new height
  41447. */
  41448. scaleTo(width: number, height: number): void;
  41449. /**
  41450. * Gets the context of the canvas used by the texture
  41451. * @returns the canvas context of the dynamic texture
  41452. */
  41453. getContext(): CanvasRenderingContext2D;
  41454. /**
  41455. * Clears the texture
  41456. */
  41457. clear(): void;
  41458. /**
  41459. * Updates the texture
  41460. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41461. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41462. */
  41463. update(invertY?: boolean, premulAlpha?: boolean): void;
  41464. /**
  41465. * Draws text onto the texture
  41466. * @param text defines the text to be drawn
  41467. * @param x defines the placement of the text from the left
  41468. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41469. * @param font defines the font to be used with font-style, font-size, font-name
  41470. * @param color defines the color used for the text
  41471. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41472. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41473. * @param update defines whether texture is immediately update (default is true)
  41474. */
  41475. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41476. /**
  41477. * Clones the texture
  41478. * @returns the clone of the texture.
  41479. */
  41480. clone(): DynamicTexture;
  41481. /**
  41482. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41483. * @returns a serialized dynamic texture object
  41484. */
  41485. serialize(): any;
  41486. /** @hidden */
  41487. _rebuild(): void;
  41488. }
  41489. }
  41490. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41491. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41493. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41494. /** @hidden */
  41495. export var imageProcessingPixelShader: {
  41496. name: string;
  41497. shader: string;
  41498. };
  41499. }
  41500. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41501. import { Nullable } from "babylonjs/types";
  41502. import { Color4 } from "babylonjs/Maths/math.color";
  41503. import { Camera } from "babylonjs/Cameras/camera";
  41504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41505. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41506. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41508. import { Engine } from "babylonjs/Engines/engine";
  41509. import "babylonjs/Shaders/imageProcessing.fragment";
  41510. import "babylonjs/Shaders/postprocess.vertex";
  41511. /**
  41512. * ImageProcessingPostProcess
  41513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41514. */
  41515. export class ImageProcessingPostProcess extends PostProcess {
  41516. /**
  41517. * Default configuration related to image processing available in the PBR Material.
  41518. */
  41519. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41520. /**
  41521. * Gets the image processing configuration used either in this material.
  41522. */
  41523. /**
  41524. * Sets the Default image processing configuration used either in the this material.
  41525. *
  41526. * If sets to null, the scene one is in use.
  41527. */
  41528. imageProcessingConfiguration: ImageProcessingConfiguration;
  41529. /**
  41530. * Keep track of the image processing observer to allow dispose and replace.
  41531. */
  41532. private _imageProcessingObserver;
  41533. /**
  41534. * Attaches a new image processing configuration to the PBR Material.
  41535. * @param configuration
  41536. */
  41537. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41538. /**
  41539. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41540. */
  41541. /**
  41542. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41543. */
  41544. colorCurves: Nullable<ColorCurves>;
  41545. /**
  41546. * Gets wether the color curves effect is enabled.
  41547. */
  41548. /**
  41549. * Sets wether the color curves effect is enabled.
  41550. */
  41551. colorCurvesEnabled: boolean;
  41552. /**
  41553. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41554. */
  41555. /**
  41556. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41557. */
  41558. colorGradingTexture: Nullable<BaseTexture>;
  41559. /**
  41560. * Gets wether the color grading effect is enabled.
  41561. */
  41562. /**
  41563. * Gets wether the color grading effect is enabled.
  41564. */
  41565. colorGradingEnabled: boolean;
  41566. /**
  41567. * Gets exposure used in the effect.
  41568. */
  41569. /**
  41570. * Sets exposure used in the effect.
  41571. */
  41572. exposure: number;
  41573. /**
  41574. * Gets wether tonemapping is enabled or not.
  41575. */
  41576. /**
  41577. * Sets wether tonemapping is enabled or not
  41578. */
  41579. toneMappingEnabled: boolean;
  41580. /**
  41581. * Gets the type of tone mapping effect.
  41582. */
  41583. /**
  41584. * Sets the type of tone mapping effect.
  41585. */
  41586. toneMappingType: number;
  41587. /**
  41588. * Gets contrast used in the effect.
  41589. */
  41590. /**
  41591. * Sets contrast used in the effect.
  41592. */
  41593. contrast: number;
  41594. /**
  41595. * Gets Vignette stretch size.
  41596. */
  41597. /**
  41598. * Sets Vignette stretch size.
  41599. */
  41600. vignetteStretch: number;
  41601. /**
  41602. * Gets Vignette centre X Offset.
  41603. */
  41604. /**
  41605. * Sets Vignette centre X Offset.
  41606. */
  41607. vignetteCentreX: number;
  41608. /**
  41609. * Gets Vignette centre Y Offset.
  41610. */
  41611. /**
  41612. * Sets Vignette centre Y Offset.
  41613. */
  41614. vignetteCentreY: number;
  41615. /**
  41616. * Gets Vignette weight or intensity of the vignette effect.
  41617. */
  41618. /**
  41619. * Sets Vignette weight or intensity of the vignette effect.
  41620. */
  41621. vignetteWeight: number;
  41622. /**
  41623. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41624. * if vignetteEnabled is set to true.
  41625. */
  41626. /**
  41627. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41628. * if vignetteEnabled is set to true.
  41629. */
  41630. vignetteColor: Color4;
  41631. /**
  41632. * Gets Camera field of view used by the Vignette effect.
  41633. */
  41634. /**
  41635. * Sets Camera field of view used by the Vignette effect.
  41636. */
  41637. vignetteCameraFov: number;
  41638. /**
  41639. * Gets the vignette blend mode allowing different kind of effect.
  41640. */
  41641. /**
  41642. * Sets the vignette blend mode allowing different kind of effect.
  41643. */
  41644. vignetteBlendMode: number;
  41645. /**
  41646. * Gets wether the vignette effect is enabled.
  41647. */
  41648. /**
  41649. * Sets wether the vignette effect is enabled.
  41650. */
  41651. vignetteEnabled: boolean;
  41652. private _fromLinearSpace;
  41653. /**
  41654. * Gets wether the input of the processing is in Gamma or Linear Space.
  41655. */
  41656. /**
  41657. * Sets wether the input of the processing is in Gamma or Linear Space.
  41658. */
  41659. fromLinearSpace: boolean;
  41660. /**
  41661. * Defines cache preventing GC.
  41662. */
  41663. private _defines;
  41664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41665. /**
  41666. * "ImageProcessingPostProcess"
  41667. * @returns "ImageProcessingPostProcess"
  41668. */
  41669. getClassName(): string;
  41670. protected _updateParameters(): void;
  41671. dispose(camera?: Camera): void;
  41672. }
  41673. }
  41674. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41675. import { Scene } from "babylonjs/scene";
  41676. import { Color3 } from "babylonjs/Maths/math.color";
  41677. import { Mesh } from "babylonjs/Meshes/mesh";
  41678. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41679. import { Nullable } from "babylonjs/types";
  41680. /**
  41681. * Class containing static functions to help procedurally build meshes
  41682. */
  41683. export class GroundBuilder {
  41684. /**
  41685. * Creates a ground mesh
  41686. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41687. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41689. * @param name defines the name of the mesh
  41690. * @param options defines the options used to create the mesh
  41691. * @param scene defines the hosting scene
  41692. * @returns the ground mesh
  41693. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41694. */
  41695. static CreateGround(name: string, options: {
  41696. width?: number;
  41697. height?: number;
  41698. subdivisions?: number;
  41699. subdivisionsX?: number;
  41700. subdivisionsY?: number;
  41701. updatable?: boolean;
  41702. }, scene: any): Mesh;
  41703. /**
  41704. * Creates a tiled ground mesh
  41705. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41706. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41707. * * 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
  41708. * * 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
  41709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41710. * @param name defines the name of the mesh
  41711. * @param options defines the options used to create the mesh
  41712. * @param scene defines the hosting scene
  41713. * @returns the tiled ground mesh
  41714. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41715. */
  41716. static CreateTiledGround(name: string, options: {
  41717. xmin: number;
  41718. zmin: number;
  41719. xmax: number;
  41720. zmax: number;
  41721. subdivisions?: {
  41722. w: number;
  41723. h: number;
  41724. };
  41725. precision?: {
  41726. w: number;
  41727. h: number;
  41728. };
  41729. updatable?: boolean;
  41730. }, scene?: Nullable<Scene>): Mesh;
  41731. /**
  41732. * Creates a ground mesh from a height map
  41733. * * The parameter `url` sets the URL of the height map image resource.
  41734. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41735. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41736. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41737. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41738. * * 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.
  41739. * * 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).
  41740. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41742. * @param name defines the name of the mesh
  41743. * @param url defines the url to the height map
  41744. * @param options defines the options used to create the mesh
  41745. * @param scene defines the hosting scene
  41746. * @returns the ground mesh
  41747. * @see https://doc.babylonjs.com/babylon101/height_map
  41748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41749. */
  41750. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41751. width?: number;
  41752. height?: number;
  41753. subdivisions?: number;
  41754. minHeight?: number;
  41755. maxHeight?: number;
  41756. colorFilter?: Color3;
  41757. alphaFilter?: number;
  41758. updatable?: boolean;
  41759. onReady?: (mesh: GroundMesh) => void;
  41760. }, scene?: Nullable<Scene>): GroundMesh;
  41761. }
  41762. }
  41763. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41764. import { Vector4 } from "babylonjs/Maths/math.vector";
  41765. import { Mesh } from "babylonjs/Meshes/mesh";
  41766. /**
  41767. * Class containing static functions to help procedurally build meshes
  41768. */
  41769. export class TorusBuilder {
  41770. /**
  41771. * Creates a torus mesh
  41772. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41773. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41774. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41778. * @param name defines the name of the mesh
  41779. * @param options defines the options used to create the mesh
  41780. * @param scene defines the hosting scene
  41781. * @returns the torus mesh
  41782. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41783. */
  41784. static CreateTorus(name: string, options: {
  41785. diameter?: number;
  41786. thickness?: number;
  41787. tessellation?: number;
  41788. updatable?: boolean;
  41789. sideOrientation?: number;
  41790. frontUVs?: Vector4;
  41791. backUVs?: Vector4;
  41792. }, scene: any): Mesh;
  41793. }
  41794. }
  41795. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41796. import { Vector4 } from "babylonjs/Maths/math.vector";
  41797. import { Color4 } from "babylonjs/Maths/math.color";
  41798. import { Mesh } from "babylonjs/Meshes/mesh";
  41799. /**
  41800. * Class containing static functions to help procedurally build meshes
  41801. */
  41802. export class CylinderBuilder {
  41803. /**
  41804. * Creates a cylinder or a cone mesh
  41805. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41806. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41807. * * 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.
  41808. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41809. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41810. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41811. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41812. * * 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).
  41813. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41814. * * 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).
  41815. * * 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
  41816. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41817. * * 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
  41818. * * 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.
  41819. * * If `enclose` is false, a ring surface is one element.
  41820. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41821. * * 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
  41822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41825. * @param name defines the name of the mesh
  41826. * @param options defines the options used to create the mesh
  41827. * @param scene defines the hosting scene
  41828. * @returns the cylinder mesh
  41829. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41830. */
  41831. static CreateCylinder(name: string, options: {
  41832. height?: number;
  41833. diameterTop?: number;
  41834. diameterBottom?: number;
  41835. diameter?: number;
  41836. tessellation?: number;
  41837. subdivisions?: number;
  41838. arc?: number;
  41839. faceColors?: Color4[];
  41840. faceUV?: Vector4[];
  41841. updatable?: boolean;
  41842. hasRings?: boolean;
  41843. enclose?: boolean;
  41844. cap?: number;
  41845. sideOrientation?: number;
  41846. frontUVs?: Vector4;
  41847. backUVs?: Vector4;
  41848. }, scene: any): Mesh;
  41849. }
  41850. }
  41851. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41852. import { Observable } from "babylonjs/Misc/observable";
  41853. import { Nullable } from "babylonjs/types";
  41854. import { Camera } from "babylonjs/Cameras/camera";
  41855. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41856. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41857. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41858. import { Scene } from "babylonjs/scene";
  41859. import { Vector3 } from "babylonjs/Maths/math.vector";
  41860. import { Color3 } from "babylonjs/Maths/math.color";
  41861. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41863. import { Mesh } from "babylonjs/Meshes/mesh";
  41864. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41865. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41866. import "babylonjs/Meshes/Builders/groundBuilder";
  41867. import "babylonjs/Meshes/Builders/torusBuilder";
  41868. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41869. import "babylonjs/Gamepads/gamepadSceneComponent";
  41870. import "babylonjs/Animations/animatable";
  41871. /**
  41872. * Options to modify the vr teleportation behavior.
  41873. */
  41874. export interface VRTeleportationOptions {
  41875. /**
  41876. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41877. */
  41878. floorMeshName?: string;
  41879. /**
  41880. * A list of meshes to be used as the teleportation floor. (default: empty)
  41881. */
  41882. floorMeshes?: Mesh[];
  41883. }
  41884. /**
  41885. * Options to modify the vr experience helper's behavior.
  41886. */
  41887. export interface VRExperienceHelperOptions extends WebVROptions {
  41888. /**
  41889. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41890. */
  41891. createDeviceOrientationCamera?: boolean;
  41892. /**
  41893. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41894. */
  41895. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41896. /**
  41897. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41898. */
  41899. laserToggle?: boolean;
  41900. /**
  41901. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41902. */
  41903. floorMeshes?: Mesh[];
  41904. /**
  41905. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41906. */
  41907. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41908. }
  41909. /**
  41910. * Event containing information after VR has been entered
  41911. */
  41912. export class OnAfterEnteringVRObservableEvent {
  41913. /**
  41914. * If entering vr was successful
  41915. */
  41916. success: boolean;
  41917. }
  41918. /**
  41919. * Helps to quickly add VR support to an existing scene.
  41920. * See http://doc.babylonjs.com/how_to/webvr_helper
  41921. */
  41922. export class VRExperienceHelper {
  41923. /** Options to modify the vr experience helper's behavior. */
  41924. webVROptions: VRExperienceHelperOptions;
  41925. private _scene;
  41926. private _position;
  41927. private _btnVR;
  41928. private _btnVRDisplayed;
  41929. private _webVRsupported;
  41930. private _webVRready;
  41931. private _webVRrequesting;
  41932. private _webVRpresenting;
  41933. private _hasEnteredVR;
  41934. private _fullscreenVRpresenting;
  41935. private _canvas;
  41936. private _webVRCamera;
  41937. private _vrDeviceOrientationCamera;
  41938. private _deviceOrientationCamera;
  41939. private _existingCamera;
  41940. private _onKeyDown;
  41941. private _onVrDisplayPresentChange;
  41942. private _onVRDisplayChanged;
  41943. private _onVRRequestPresentStart;
  41944. private _onVRRequestPresentComplete;
  41945. /**
  41946. * 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)
  41947. */
  41948. enableGazeEvenWhenNoPointerLock: boolean;
  41949. /**
  41950. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41951. */
  41952. exitVROnDoubleTap: boolean;
  41953. /**
  41954. * Observable raised right before entering VR.
  41955. */
  41956. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41957. /**
  41958. * Observable raised when entering VR has completed.
  41959. */
  41960. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41961. /**
  41962. * Observable raised when exiting VR.
  41963. */
  41964. onExitingVRObservable: Observable<VRExperienceHelper>;
  41965. /**
  41966. * Observable raised when controller mesh is loaded.
  41967. */
  41968. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41969. /** Return this.onEnteringVRObservable
  41970. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41971. */
  41972. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41973. /** Return this.onExitingVRObservable
  41974. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41975. */
  41976. readonly onExitingVR: Observable<VRExperienceHelper>;
  41977. /** Return this.onControllerMeshLoadedObservable
  41978. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41979. */
  41980. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41981. private _rayLength;
  41982. private _useCustomVRButton;
  41983. private _teleportationRequested;
  41984. private _teleportActive;
  41985. private _floorMeshName;
  41986. private _floorMeshesCollection;
  41987. private _rotationAllowed;
  41988. private _teleportBackwardsVector;
  41989. private _teleportationTarget;
  41990. private _isDefaultTeleportationTarget;
  41991. private _postProcessMove;
  41992. private _teleportationFillColor;
  41993. private _teleportationBorderColor;
  41994. private _rotationAngle;
  41995. private _haloCenter;
  41996. private _cameraGazer;
  41997. private _padSensibilityUp;
  41998. private _padSensibilityDown;
  41999. private _leftController;
  42000. private _rightController;
  42001. /**
  42002. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42003. */
  42004. onNewMeshSelected: Observable<AbstractMesh>;
  42005. /**
  42006. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42007. */
  42008. onNewMeshPicked: Observable<PickingInfo>;
  42009. private _circleEase;
  42010. /**
  42011. * Observable raised before camera teleportation
  42012. */
  42013. onBeforeCameraTeleport: Observable<Vector3>;
  42014. /**
  42015. * Observable raised after camera teleportation
  42016. */
  42017. onAfterCameraTeleport: Observable<Vector3>;
  42018. /**
  42019. * Observable raised when current selected mesh gets unselected
  42020. */
  42021. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42022. private _raySelectionPredicate;
  42023. /**
  42024. * To be optionaly changed by user to define custom ray selection
  42025. */
  42026. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42027. /**
  42028. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42029. */
  42030. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42031. /**
  42032. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42033. */
  42034. teleportationEnabled: boolean;
  42035. private _defaultHeight;
  42036. private _teleportationInitialized;
  42037. private _interactionsEnabled;
  42038. private _interactionsRequested;
  42039. private _displayGaze;
  42040. private _displayLaserPointer;
  42041. /**
  42042. * The mesh used to display where the user is going to teleport.
  42043. */
  42044. /**
  42045. * Sets the mesh to be used to display where the user is going to teleport.
  42046. */
  42047. teleportationTarget: Mesh;
  42048. /**
  42049. * 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
  42050. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42051. * See http://doc.babylonjs.com/resources/baking_transformations
  42052. */
  42053. gazeTrackerMesh: Mesh;
  42054. /**
  42055. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42056. */
  42057. updateGazeTrackerScale: boolean;
  42058. /**
  42059. * If the gaze trackers color should be updated when selecting meshes
  42060. */
  42061. updateGazeTrackerColor: boolean;
  42062. /**
  42063. * The gaze tracking mesh corresponding to the left controller
  42064. */
  42065. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42066. /**
  42067. * The gaze tracking mesh corresponding to the right controller
  42068. */
  42069. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42070. /**
  42071. * If the ray of the gaze should be displayed.
  42072. */
  42073. /**
  42074. * Sets if the ray of the gaze should be displayed.
  42075. */
  42076. displayGaze: boolean;
  42077. /**
  42078. * If the ray of the LaserPointer should be displayed.
  42079. */
  42080. /**
  42081. * Sets if the ray of the LaserPointer should be displayed.
  42082. */
  42083. displayLaserPointer: boolean;
  42084. /**
  42085. * The deviceOrientationCamera used as the camera when not in VR.
  42086. */
  42087. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42088. /**
  42089. * Based on the current WebVR support, returns the current VR camera used.
  42090. */
  42091. readonly currentVRCamera: Nullable<Camera>;
  42092. /**
  42093. * The webVRCamera which is used when in VR.
  42094. */
  42095. readonly webVRCamera: WebVRFreeCamera;
  42096. /**
  42097. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42098. */
  42099. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42100. /**
  42101. * The html button that is used to trigger entering into VR.
  42102. */
  42103. readonly vrButton: Nullable<HTMLButtonElement>;
  42104. private readonly _teleportationRequestInitiated;
  42105. /**
  42106. * Defines wether or not Pointer lock should be requested when switching to
  42107. * full screen.
  42108. */
  42109. requestPointerLockOnFullScreen: boolean;
  42110. /**
  42111. * Instantiates a VRExperienceHelper.
  42112. * Helps to quickly add VR support to an existing scene.
  42113. * @param scene The scene the VRExperienceHelper belongs to.
  42114. * @param webVROptions Options to modify the vr experience helper's behavior.
  42115. */
  42116. constructor(scene: Scene,
  42117. /** Options to modify the vr experience helper's behavior. */
  42118. webVROptions?: VRExperienceHelperOptions);
  42119. private _onDefaultMeshLoaded;
  42120. private _onResize;
  42121. private _onFullscreenChange;
  42122. /**
  42123. * Gets a value indicating if we are currently in VR mode.
  42124. */
  42125. readonly isInVRMode: boolean;
  42126. private onVrDisplayPresentChange;
  42127. private onVRDisplayChanged;
  42128. private moveButtonToBottomRight;
  42129. private displayVRButton;
  42130. private updateButtonVisibility;
  42131. private _cachedAngularSensibility;
  42132. /**
  42133. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42134. * Otherwise, will use the fullscreen API.
  42135. */
  42136. enterVR(): void;
  42137. /**
  42138. * Attempt to exit VR, or fullscreen.
  42139. */
  42140. exitVR(): void;
  42141. /**
  42142. * The position of the vr experience helper.
  42143. */
  42144. /**
  42145. * Sets the position of the vr experience helper.
  42146. */
  42147. position: Vector3;
  42148. /**
  42149. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42150. */
  42151. enableInteractions(): void;
  42152. private readonly _noControllerIsActive;
  42153. private beforeRender;
  42154. private _isTeleportationFloor;
  42155. /**
  42156. * Adds a floor mesh to be used for teleportation.
  42157. * @param floorMesh the mesh to be used for teleportation.
  42158. */
  42159. addFloorMesh(floorMesh: Mesh): void;
  42160. /**
  42161. * Removes a floor mesh from being used for teleportation.
  42162. * @param floorMesh the mesh to be removed.
  42163. */
  42164. removeFloorMesh(floorMesh: Mesh): void;
  42165. /**
  42166. * Enables interactions and teleportation using the VR controllers and gaze.
  42167. * @param vrTeleportationOptions options to modify teleportation behavior.
  42168. */
  42169. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42170. private _onNewGamepadConnected;
  42171. private _tryEnableInteractionOnController;
  42172. private _onNewGamepadDisconnected;
  42173. private _enableInteractionOnController;
  42174. private _checkTeleportWithRay;
  42175. private _checkRotate;
  42176. private _checkTeleportBackwards;
  42177. private _enableTeleportationOnController;
  42178. private _createTeleportationCircles;
  42179. private _displayTeleportationTarget;
  42180. private _hideTeleportationTarget;
  42181. private _rotateCamera;
  42182. private _moveTeleportationSelectorTo;
  42183. private _workingVector;
  42184. private _workingQuaternion;
  42185. private _workingMatrix;
  42186. /**
  42187. * Teleports the users feet to the desired location
  42188. * @param location The location where the user's feet should be placed
  42189. */
  42190. teleportCamera(location: Vector3): void;
  42191. private _convertNormalToDirectionOfRay;
  42192. private _castRayAndSelectObject;
  42193. private _notifySelectedMeshUnselected;
  42194. /**
  42195. * Sets the color of the laser ray from the vr controllers.
  42196. * @param color new color for the ray.
  42197. */
  42198. changeLaserColor(color: Color3): void;
  42199. /**
  42200. * Sets the color of the ray from the vr headsets gaze.
  42201. * @param color new color for the ray.
  42202. */
  42203. changeGazeColor(color: Color3): void;
  42204. /**
  42205. * Exits VR and disposes of the vr experience helper
  42206. */
  42207. dispose(): void;
  42208. /**
  42209. * Gets the name of the VRExperienceHelper class
  42210. * @returns "VRExperienceHelper"
  42211. */
  42212. getClassName(): string;
  42213. }
  42214. }
  42215. declare module "babylonjs/Cameras/VR/index" {
  42216. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42217. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42218. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42219. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42220. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42221. export * from "babylonjs/Cameras/VR/webVRCamera";
  42222. }
  42223. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42224. import { Observable } from "babylonjs/Misc/observable";
  42225. import { Nullable } from "babylonjs/types";
  42226. import { IDisposable, Scene } from "babylonjs/scene";
  42227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42228. /**
  42229. * Manages an XRSession to work with Babylon's engine
  42230. * @see https://doc.babylonjs.com/how_to/webxr
  42231. */
  42232. export class WebXRSessionManager implements IDisposable {
  42233. private scene;
  42234. /**
  42235. * Fires every time a new xrFrame arrives which can be used to update the camera
  42236. */
  42237. onXRFrameObservable: Observable<any>;
  42238. /**
  42239. * Fires when the xr session is ended either by the device or manually done
  42240. */
  42241. onXRSessionEnded: Observable<any>;
  42242. /**
  42243. * Underlying xr session
  42244. */
  42245. session: XRSession;
  42246. /**
  42247. * Type of reference space used when creating the session
  42248. */
  42249. referenceSpace: XRReferenceSpace;
  42250. /** @hidden */
  42251. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42252. /**
  42253. * Current XR frame
  42254. */
  42255. currentFrame: Nullable<XRFrame>;
  42256. private _xrNavigator;
  42257. private baseLayer;
  42258. /**
  42259. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42260. * @param scene The scene which the session should be created for
  42261. */
  42262. constructor(scene: Scene);
  42263. /**
  42264. * Initializes the manager
  42265. * After initialization enterXR can be called to start an XR session
  42266. * @returns Promise which resolves after it is initialized
  42267. */
  42268. initializeAsync(): Promise<void>;
  42269. /**
  42270. * Initializes an xr session
  42271. * @param xrSessionMode mode to initialize
  42272. * @returns a promise which will resolve once the session has been initialized
  42273. */
  42274. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42275. /**
  42276. * Sets the reference space on the xr session
  42277. * @param referenceSpace space to set
  42278. * @returns a promise that will resolve once the reference space has been set
  42279. */
  42280. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42281. /**
  42282. * Updates the render state of the session
  42283. * @param state state to set
  42284. * @returns a promise that resolves once the render state has been updated
  42285. */
  42286. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42287. /**
  42288. * Starts rendering to the xr layer
  42289. * @returns a promise that will resolve once rendering has started
  42290. */
  42291. startRenderingToXRAsync(): Promise<void>;
  42292. /**
  42293. * Stops the xrSession and restores the renderloop
  42294. * @returns Promise which resolves after it exits XR
  42295. */
  42296. exitXRAsync(): Promise<unknown>;
  42297. /**
  42298. * Checks if a session would be supported for the creation options specified
  42299. * @param sessionMode session mode to check if supported eg. immersive-vr
  42300. * @returns true if supported
  42301. */
  42302. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42303. /**
  42304. * @hidden
  42305. * Converts the render layer of xrSession to a render target
  42306. * @param session session to create render target for
  42307. * @param scene scene the new render target should be created for
  42308. */
  42309. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42310. /**
  42311. * Disposes of the session manager
  42312. */
  42313. dispose(): void;
  42314. }
  42315. }
  42316. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42317. import { Scene } from "babylonjs/scene";
  42318. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42319. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42320. /**
  42321. * WebXR Camera which holds the views for the xrSession
  42322. * @see https://doc.babylonjs.com/how_to/webxr
  42323. */
  42324. export class WebXRCamera extends FreeCamera {
  42325. private static _TmpMatrix;
  42326. /**
  42327. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42328. * @param name the name of the camera
  42329. * @param scene the scene to add the camera to
  42330. */
  42331. constructor(name: string, scene: Scene);
  42332. private _updateNumberOfRigCameras;
  42333. /** @hidden */
  42334. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42335. /**
  42336. * Updates the cameras position from the current pose information of the XR session
  42337. * @param xrSessionManager the session containing pose information
  42338. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42339. */
  42340. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42341. }
  42342. }
  42343. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42344. import { Nullable } from "babylonjs/types";
  42345. import { IDisposable } from "babylonjs/scene";
  42346. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42347. /**
  42348. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42349. */
  42350. export class WebXRManagedOutputCanvas implements IDisposable {
  42351. private helper;
  42352. private _canvas;
  42353. /**
  42354. * xrpresent context of the canvas which can be used to display/mirror xr content
  42355. */
  42356. canvasContext: WebGLRenderingContext;
  42357. /**
  42358. * xr layer for the canvas
  42359. */
  42360. xrLayer: Nullable<XRWebGLLayer>;
  42361. /**
  42362. * Initializes the xr layer for the session
  42363. * @param xrSession xr session
  42364. * @returns a promise that will resolve once the XR Layer has been created
  42365. */
  42366. initializeXRLayerAsync(xrSession: any): any;
  42367. /**
  42368. * Initializes the canvas to be added/removed upon entering/exiting xr
  42369. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42370. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42371. */
  42372. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42373. /**
  42374. * Disposes of the object
  42375. */
  42376. dispose(): void;
  42377. private _setManagedOutputCanvas;
  42378. private _addCanvas;
  42379. private _removeCanvas;
  42380. }
  42381. }
  42382. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42383. import { Observable } from "babylonjs/Misc/observable";
  42384. import { IDisposable, Scene } from "babylonjs/scene";
  42385. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42387. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42388. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42389. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42390. /**
  42391. * States of the webXR experience
  42392. */
  42393. export enum WebXRState {
  42394. /**
  42395. * Transitioning to being in XR mode
  42396. */
  42397. ENTERING_XR = 0,
  42398. /**
  42399. * Transitioning to non XR mode
  42400. */
  42401. EXITING_XR = 1,
  42402. /**
  42403. * In XR mode and presenting
  42404. */
  42405. IN_XR = 2,
  42406. /**
  42407. * Not entered XR mode
  42408. */
  42409. NOT_IN_XR = 3
  42410. }
  42411. /**
  42412. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42413. * @see https://doc.babylonjs.com/how_to/webxr
  42414. */
  42415. export class WebXRExperienceHelper implements IDisposable {
  42416. private scene;
  42417. /**
  42418. * 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
  42419. */
  42420. container: AbstractMesh;
  42421. /**
  42422. * Camera used to render xr content
  42423. */
  42424. camera: WebXRCamera;
  42425. /**
  42426. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42427. */
  42428. state: WebXRState;
  42429. private _setState;
  42430. private static _TmpVector;
  42431. /**
  42432. * Fires when the state of the experience helper has changed
  42433. */
  42434. onStateChangedObservable: Observable<WebXRState>;
  42435. /** Session manager used to keep track of xr session */
  42436. sessionManager: WebXRSessionManager;
  42437. private _nonVRCamera;
  42438. private _originalSceneAutoClear;
  42439. private _supported;
  42440. /**
  42441. * Creates the experience helper
  42442. * @param scene the scene to attach the experience helper to
  42443. * @returns a promise for the experience helper
  42444. */
  42445. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42446. /**
  42447. * Creates a WebXRExperienceHelper
  42448. * @param scene The scene the helper should be created in
  42449. */
  42450. private constructor();
  42451. /**
  42452. * Exits XR mode and returns the scene to its original state
  42453. * @returns promise that resolves after xr mode has exited
  42454. */
  42455. exitXRAsync(): Promise<unknown>;
  42456. /**
  42457. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42458. * @param sessionCreationOptions options for the XR session
  42459. * @param referenceSpaceType frame of reference of the XR session
  42460. * @param outputCanvas the output canvas that will be used to enter XR mode
  42461. * @returns promise that resolves after xr mode has entered
  42462. */
  42463. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42464. /**
  42465. * Updates the global position of the camera by moving the camera's container
  42466. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42467. * @param position The desired global position of the camera
  42468. */
  42469. setPositionOfCameraUsingContainer(position: Vector3): void;
  42470. /**
  42471. * Rotates the xr camera by rotating the camera's container around the camera's position
  42472. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42473. * @param rotation the desired quaternion rotation to apply to the camera
  42474. */
  42475. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42476. /**
  42477. * Disposes of the experience helper
  42478. */
  42479. dispose(): void;
  42480. }
  42481. }
  42482. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42483. import { Nullable } from "babylonjs/types";
  42484. import { Observable } from "babylonjs/Misc/observable";
  42485. import { IDisposable, Scene } from "babylonjs/scene";
  42486. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42487. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42488. /**
  42489. * Button which can be used to enter a different mode of XR
  42490. */
  42491. export class WebXREnterExitUIButton {
  42492. /** button element */
  42493. element: HTMLElement;
  42494. /** XR initialization options for the button */
  42495. sessionMode: XRSessionMode;
  42496. /** Reference space type */
  42497. referenceSpaceType: XRReferenceSpaceType;
  42498. /**
  42499. * Creates a WebXREnterExitUIButton
  42500. * @param element button element
  42501. * @param sessionMode XR initialization session mode
  42502. * @param referenceSpaceType the type of reference space to be used
  42503. */
  42504. constructor(
  42505. /** button element */
  42506. element: HTMLElement,
  42507. /** XR initialization options for the button */
  42508. sessionMode: XRSessionMode,
  42509. /** Reference space type */
  42510. referenceSpaceType: XRReferenceSpaceType);
  42511. /**
  42512. * Overwritable function which can be used to update the button's visuals when the state changes
  42513. * @param activeButton the current active button in the UI
  42514. */
  42515. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42516. }
  42517. /**
  42518. * Options to create the webXR UI
  42519. */
  42520. export class WebXREnterExitUIOptions {
  42521. /**
  42522. * Context to enter xr with
  42523. */
  42524. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42525. /**
  42526. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42527. */
  42528. customButtons?: Array<WebXREnterExitUIButton>;
  42529. }
  42530. /**
  42531. * UI to allow the user to enter/exit XR mode
  42532. */
  42533. export class WebXREnterExitUI implements IDisposable {
  42534. private scene;
  42535. private _overlay;
  42536. private _buttons;
  42537. private _activeButton;
  42538. /**
  42539. * Fired every time the active button is changed.
  42540. *
  42541. * When xr is entered via a button that launches xr that button will be the callback parameter
  42542. *
  42543. * When exiting xr the callback parameter will be null)
  42544. */
  42545. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42546. /**
  42547. * Creates UI to allow the user to enter/exit XR mode
  42548. * @param scene the scene to add the ui to
  42549. * @param helper the xr experience helper to enter/exit xr with
  42550. * @param options options to configure the UI
  42551. * @returns the created ui
  42552. */
  42553. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42554. private constructor();
  42555. private _updateButtons;
  42556. /**
  42557. * Disposes of the object
  42558. */
  42559. dispose(): void;
  42560. }
  42561. }
  42562. declare module "babylonjs/Cameras/XR/webXRController" {
  42563. import { Nullable } from "babylonjs/types";
  42564. import { Observable } from "babylonjs/Misc/observable";
  42565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42566. import { Ray } from "babylonjs/Culling/ray";
  42567. import { Scene } from "babylonjs/scene";
  42568. /**
  42569. * Represents an XR input
  42570. */
  42571. export class WebXRController {
  42572. private scene;
  42573. /** The underlying input source for the controller */
  42574. inputSource: XRInputSource;
  42575. private parentContainer;
  42576. /**
  42577. * 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
  42578. */
  42579. grip?: AbstractMesh;
  42580. /**
  42581. * Pointer which can be used to select objects or attach a visible laser to
  42582. */
  42583. pointer: AbstractMesh;
  42584. /**
  42585. * Event that fires when the controller is removed/disposed
  42586. */
  42587. onDisposeObservable: Observable<{}>;
  42588. private _tmpMatrix;
  42589. private _tmpQuaternion;
  42590. private _tmpVector;
  42591. /**
  42592. * Creates the controller
  42593. * @see https://doc.babylonjs.com/how_to/webxr
  42594. * @param scene the scene which the controller should be associated to
  42595. * @param inputSource the underlying input source for the controller
  42596. * @param parentContainer parent that the controller meshes should be children of
  42597. */
  42598. constructor(scene: Scene,
  42599. /** The underlying input source for the controller */
  42600. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42601. /**
  42602. * Updates the controller pose based on the given XRFrame
  42603. * @param xrFrame xr frame to update the pose with
  42604. * @param referenceSpace reference space to use
  42605. */
  42606. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42607. /**
  42608. * Gets a world space ray coming from the controller
  42609. * @param result the resulting ray
  42610. */
  42611. getWorldPointerRayToRef(result: Ray): void;
  42612. /**
  42613. * Disposes of the object
  42614. */
  42615. dispose(): void;
  42616. }
  42617. }
  42618. declare module "babylonjs/Cameras/XR/webXRInput" {
  42619. import { Observable } from "babylonjs/Misc/observable";
  42620. import { IDisposable } from "babylonjs/scene";
  42621. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42622. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42623. /**
  42624. * XR input used to track XR inputs such as controllers/rays
  42625. */
  42626. export class WebXRInput implements IDisposable {
  42627. /**
  42628. * Base experience the input listens to
  42629. */
  42630. baseExperience: WebXRExperienceHelper;
  42631. /**
  42632. * XR controllers being tracked
  42633. */
  42634. controllers: Array<WebXRController>;
  42635. private _frameObserver;
  42636. private _stateObserver;
  42637. /**
  42638. * Event when a controller has been connected/added
  42639. */
  42640. onControllerAddedObservable: Observable<WebXRController>;
  42641. /**
  42642. * Event when a controller has been removed/disconnected
  42643. */
  42644. onControllerRemovedObservable: Observable<WebXRController>;
  42645. /**
  42646. * Initializes the WebXRInput
  42647. * @param baseExperience experience helper which the input should be created for
  42648. */
  42649. constructor(
  42650. /**
  42651. * Base experience the input listens to
  42652. */
  42653. baseExperience: WebXRExperienceHelper);
  42654. private _onInputSourcesChange;
  42655. private _addAndRemoveControllers;
  42656. /**
  42657. * Disposes of the object
  42658. */
  42659. dispose(): void;
  42660. }
  42661. }
  42662. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42664. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42665. /**
  42666. * Enables teleportation
  42667. */
  42668. export class WebXRControllerTeleportation {
  42669. private _teleportationFillColor;
  42670. private _teleportationBorderColor;
  42671. private _tmpRay;
  42672. private _tmpVector;
  42673. /**
  42674. * Creates a WebXRControllerTeleportation
  42675. * @param input input manager to add teleportation to
  42676. * @param floorMeshes floormeshes which can be teleported to
  42677. */
  42678. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42679. }
  42680. }
  42681. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42682. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42683. /**
  42684. * Handles pointer input automatically for the pointer of XR controllers
  42685. */
  42686. export class WebXRControllerPointerSelection {
  42687. private static _idCounter;
  42688. private _tmpRay;
  42689. /**
  42690. * Creates a WebXRControllerPointerSelection
  42691. * @param input input manager to setup pointer selection
  42692. */
  42693. constructor(input: WebXRInput);
  42694. private _convertNormalToDirectionOfRay;
  42695. private _updatePointerDistance;
  42696. }
  42697. }
  42698. declare module "babylonjs/Loading/sceneLoader" {
  42699. import { Observable } from "babylonjs/Misc/observable";
  42700. import { Nullable } from "babylonjs/types";
  42701. import { Scene } from "babylonjs/scene";
  42702. import { Engine } from "babylonjs/Engines/engine";
  42703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42704. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42705. import { AssetContainer } from "babylonjs/assetContainer";
  42706. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42707. import { Skeleton } from "babylonjs/Bones/skeleton";
  42708. /**
  42709. * Class used to represent data loading progression
  42710. */
  42711. export class SceneLoaderProgressEvent {
  42712. /** defines if data length to load can be evaluated */
  42713. readonly lengthComputable: boolean;
  42714. /** defines the loaded data length */
  42715. readonly loaded: number;
  42716. /** defines the data length to load */
  42717. readonly total: number;
  42718. /**
  42719. * Create a new progress event
  42720. * @param lengthComputable defines if data length to load can be evaluated
  42721. * @param loaded defines the loaded data length
  42722. * @param total defines the data length to load
  42723. */
  42724. constructor(
  42725. /** defines if data length to load can be evaluated */
  42726. lengthComputable: boolean,
  42727. /** defines the loaded data length */
  42728. loaded: number,
  42729. /** defines the data length to load */
  42730. total: number);
  42731. /**
  42732. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42733. * @param event defines the source event
  42734. * @returns a new SceneLoaderProgressEvent
  42735. */
  42736. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42737. }
  42738. /**
  42739. * Interface used by SceneLoader plugins to define supported file extensions
  42740. */
  42741. export interface ISceneLoaderPluginExtensions {
  42742. /**
  42743. * Defines the list of supported extensions
  42744. */
  42745. [extension: string]: {
  42746. isBinary: boolean;
  42747. };
  42748. }
  42749. /**
  42750. * Interface used by SceneLoader plugin factory
  42751. */
  42752. export interface ISceneLoaderPluginFactory {
  42753. /**
  42754. * Defines the name of the factory
  42755. */
  42756. name: string;
  42757. /**
  42758. * Function called to create a new plugin
  42759. * @return the new plugin
  42760. */
  42761. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42762. /**
  42763. * Boolean indicating if the plugin can direct load specific data
  42764. */
  42765. canDirectLoad?: (data: string) => boolean;
  42766. }
  42767. /**
  42768. * Interface used to define a SceneLoader plugin
  42769. */
  42770. export interface ISceneLoaderPlugin {
  42771. /**
  42772. * The friendly name of this plugin.
  42773. */
  42774. name: string;
  42775. /**
  42776. * The file extensions supported by this plugin.
  42777. */
  42778. extensions: string | ISceneLoaderPluginExtensions;
  42779. /**
  42780. * Import meshes into a scene.
  42781. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42782. * @param scene The scene to import into
  42783. * @param data The data to import
  42784. * @param rootUrl The root url for scene and resources
  42785. * @param meshes The meshes array to import into
  42786. * @param particleSystems The particle systems array to import into
  42787. * @param skeletons The skeletons array to import into
  42788. * @param onError The callback when import fails
  42789. * @returns True if successful or false otherwise
  42790. */
  42791. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42792. /**
  42793. * Load into a scene.
  42794. * @param scene The scene to load into
  42795. * @param data The data to import
  42796. * @param rootUrl The root url for scene and resources
  42797. * @param onError The callback when import fails
  42798. * @returns true if successful or false otherwise
  42799. */
  42800. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42801. /**
  42802. * The callback that returns true if the data can be directly loaded.
  42803. */
  42804. canDirectLoad?: (data: string) => boolean;
  42805. /**
  42806. * The callback that allows custom handling of the root url based on the response url.
  42807. */
  42808. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42809. /**
  42810. * Load into an asset container.
  42811. * @param scene The scene to load into
  42812. * @param data The data to import
  42813. * @param rootUrl The root url for scene and resources
  42814. * @param onError The callback when import fails
  42815. * @returns The loaded asset container
  42816. */
  42817. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42818. }
  42819. /**
  42820. * Interface used to define an async SceneLoader plugin
  42821. */
  42822. export interface ISceneLoaderPluginAsync {
  42823. /**
  42824. * The friendly name of this plugin.
  42825. */
  42826. name: string;
  42827. /**
  42828. * The file extensions supported by this plugin.
  42829. */
  42830. extensions: string | ISceneLoaderPluginExtensions;
  42831. /**
  42832. * Import meshes into a scene.
  42833. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42834. * @param scene The scene to import into
  42835. * @param data The data to import
  42836. * @param rootUrl The root url for scene and resources
  42837. * @param onProgress The callback when the load progresses
  42838. * @param fileName Defines the name of the file to load
  42839. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42840. */
  42841. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42842. meshes: AbstractMesh[];
  42843. particleSystems: IParticleSystem[];
  42844. skeletons: Skeleton[];
  42845. animationGroups: AnimationGroup[];
  42846. }>;
  42847. /**
  42848. * Load into a scene.
  42849. * @param scene The scene to load into
  42850. * @param data The data to import
  42851. * @param rootUrl The root url for scene and resources
  42852. * @param onProgress The callback when the load progresses
  42853. * @param fileName Defines the name of the file to load
  42854. * @returns Nothing
  42855. */
  42856. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42857. /**
  42858. * The callback that returns true if the data can be directly loaded.
  42859. */
  42860. canDirectLoad?: (data: string) => boolean;
  42861. /**
  42862. * The callback that allows custom handling of the root url based on the response url.
  42863. */
  42864. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42865. /**
  42866. * Load into an asset container.
  42867. * @param scene The scene to load into
  42868. * @param data The data to import
  42869. * @param rootUrl The root url for scene and resources
  42870. * @param onProgress The callback when the load progresses
  42871. * @param fileName Defines the name of the file to load
  42872. * @returns The loaded asset container
  42873. */
  42874. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42875. }
  42876. /**
  42877. * Class used to load scene from various file formats using registered plugins
  42878. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42879. */
  42880. export class SceneLoader {
  42881. /**
  42882. * No logging while loading
  42883. */
  42884. static readonly NO_LOGGING: number;
  42885. /**
  42886. * Minimal logging while loading
  42887. */
  42888. static readonly MINIMAL_LOGGING: number;
  42889. /**
  42890. * Summary logging while loading
  42891. */
  42892. static readonly SUMMARY_LOGGING: number;
  42893. /**
  42894. * Detailled logging while loading
  42895. */
  42896. static readonly DETAILED_LOGGING: number;
  42897. /**
  42898. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42899. */
  42900. static ForceFullSceneLoadingForIncremental: boolean;
  42901. /**
  42902. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42903. */
  42904. static ShowLoadingScreen: boolean;
  42905. /**
  42906. * Defines the current logging level (while loading the scene)
  42907. * @ignorenaming
  42908. */
  42909. static loggingLevel: number;
  42910. /**
  42911. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42912. */
  42913. static CleanBoneMatrixWeights: boolean;
  42914. /**
  42915. * Event raised when a plugin is used to load a scene
  42916. */
  42917. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42918. private static _registeredPlugins;
  42919. private static _getDefaultPlugin;
  42920. private static _getPluginForExtension;
  42921. private static _getPluginForDirectLoad;
  42922. private static _getPluginForFilename;
  42923. private static _getDirectLoad;
  42924. private static _loadData;
  42925. private static _getFileInfo;
  42926. /**
  42927. * Gets a plugin that can load the given extension
  42928. * @param extension defines the extension to load
  42929. * @returns a plugin or null if none works
  42930. */
  42931. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42932. /**
  42933. * Gets a boolean indicating that the given extension can be loaded
  42934. * @param extension defines the extension to load
  42935. * @returns true if the extension is supported
  42936. */
  42937. static IsPluginForExtensionAvailable(extension: string): boolean;
  42938. /**
  42939. * Adds a new plugin to the list of registered plugins
  42940. * @param plugin defines the plugin to add
  42941. */
  42942. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42943. /**
  42944. * Import meshes into a scene
  42945. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42946. * @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)
  42947. * @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)
  42948. * @param scene the instance of BABYLON.Scene to append to
  42949. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42950. * @param onProgress a callback with a progress event for each file being loaded
  42951. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42952. * @param pluginExtension the extension used to determine the plugin
  42953. * @returns The loaded plugin
  42954. */
  42955. 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>;
  42956. /**
  42957. * Import meshes into a scene
  42958. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42959. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42960. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42961. * @param scene the instance of BABYLON.Scene to append to
  42962. * @param onProgress a callback with a progress event for each file being loaded
  42963. * @param pluginExtension the extension used to determine the plugin
  42964. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42965. */
  42966. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42967. meshes: AbstractMesh[];
  42968. particleSystems: IParticleSystem[];
  42969. skeletons: Skeleton[];
  42970. animationGroups: AnimationGroup[];
  42971. }>;
  42972. /**
  42973. * Load a scene
  42974. * @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)
  42975. * @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)
  42976. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42977. * @param onSuccess a callback with the scene when import succeeds
  42978. * @param onProgress a callback with a progress event for each file being loaded
  42979. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42980. * @param pluginExtension the extension used to determine the plugin
  42981. * @returns The loaded plugin
  42982. */
  42983. 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>;
  42984. /**
  42985. * Load a scene
  42986. * @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)
  42987. * @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)
  42988. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42989. * @param onProgress a callback with a progress event for each file being loaded
  42990. * @param pluginExtension the extension used to determine the plugin
  42991. * @returns The loaded scene
  42992. */
  42993. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42994. /**
  42995. * Append a scene
  42996. * @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)
  42997. * @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)
  42998. * @param scene is the instance of BABYLON.Scene to append to
  42999. * @param onSuccess a callback with the scene when import succeeds
  43000. * @param onProgress a callback with a progress event for each file being loaded
  43001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43002. * @param pluginExtension the extension used to determine the plugin
  43003. * @returns The loaded plugin
  43004. */
  43005. 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>;
  43006. /**
  43007. * Append a scene
  43008. * @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)
  43009. * @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)
  43010. * @param scene is the instance of BABYLON.Scene to append to
  43011. * @param onProgress a callback with a progress event for each file being loaded
  43012. * @param pluginExtension the extension used to determine the plugin
  43013. * @returns The given scene
  43014. */
  43015. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43016. /**
  43017. * Load a scene into an asset container
  43018. * @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)
  43019. * @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)
  43020. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43021. * @param onSuccess a callback with the scene when import succeeds
  43022. * @param onProgress a callback with a progress event for each file being loaded
  43023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43024. * @param pluginExtension the extension used to determine the plugin
  43025. * @returns The loaded plugin
  43026. */
  43027. 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>;
  43028. /**
  43029. * Load a scene into an asset container
  43030. * @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)
  43031. * @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)
  43032. * @param scene is the instance of Scene to append to
  43033. * @param onProgress a callback with a progress event for each file being loaded
  43034. * @param pluginExtension the extension used to determine the plugin
  43035. * @returns The loaded asset container
  43036. */
  43037. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43038. }
  43039. }
  43040. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43041. import { Scene } from "babylonjs/scene";
  43042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43043. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43044. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43045. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43046. /**
  43047. * Generic Controller
  43048. */
  43049. export class GenericController extends WebVRController {
  43050. /**
  43051. * Base Url for the controller model.
  43052. */
  43053. static readonly MODEL_BASE_URL: string;
  43054. /**
  43055. * File name for the controller model.
  43056. */
  43057. static readonly MODEL_FILENAME: string;
  43058. /**
  43059. * Creates a new GenericController from a gamepad
  43060. * @param vrGamepad the gamepad that the controller should be created from
  43061. */
  43062. constructor(vrGamepad: any);
  43063. /**
  43064. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43065. * @param scene scene in which to add meshes
  43066. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43067. */
  43068. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43069. /**
  43070. * Called once for each button that changed state since the last frame
  43071. * @param buttonIdx Which button index changed
  43072. * @param state New state of the button
  43073. * @param changes Which properties on the state changed since last frame
  43074. */
  43075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43076. }
  43077. }
  43078. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43079. import { Observable } from "babylonjs/Misc/observable";
  43080. import { Scene } from "babylonjs/scene";
  43081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43082. import { Ray } from "babylonjs/Culling/ray";
  43083. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43084. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43085. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43086. /**
  43087. * Defines the WindowsMotionController object that the state of the windows motion controller
  43088. */
  43089. export class WindowsMotionController extends WebVRController {
  43090. /**
  43091. * The base url used to load the left and right controller models
  43092. */
  43093. static MODEL_BASE_URL: string;
  43094. /**
  43095. * The name of the left controller model file
  43096. */
  43097. static MODEL_LEFT_FILENAME: string;
  43098. /**
  43099. * The name of the right controller model file
  43100. */
  43101. static MODEL_RIGHT_FILENAME: string;
  43102. /**
  43103. * The controller name prefix for this controller type
  43104. */
  43105. static readonly GAMEPAD_ID_PREFIX: string;
  43106. /**
  43107. * The controller id pattern for this controller type
  43108. */
  43109. private static readonly GAMEPAD_ID_PATTERN;
  43110. private _loadedMeshInfo;
  43111. private readonly _mapping;
  43112. /**
  43113. * Fired when the trackpad on this controller is clicked
  43114. */
  43115. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43116. /**
  43117. * Fired when the trackpad on this controller is modified
  43118. */
  43119. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43120. /**
  43121. * The current x and y values of this controller's trackpad
  43122. */
  43123. trackpad: StickValues;
  43124. /**
  43125. * Creates a new WindowsMotionController from a gamepad
  43126. * @param vrGamepad the gamepad that the controller should be created from
  43127. */
  43128. constructor(vrGamepad: any);
  43129. /**
  43130. * Fired when the trigger on this controller is modified
  43131. */
  43132. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43133. /**
  43134. * Fired when the menu button on this controller is modified
  43135. */
  43136. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43137. /**
  43138. * Fired when the grip button on this controller is modified
  43139. */
  43140. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43141. /**
  43142. * Fired when the thumbstick button on this controller is modified
  43143. */
  43144. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43145. /**
  43146. * Fired when the touchpad button on this controller is modified
  43147. */
  43148. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43149. /**
  43150. * Fired when the touchpad values on this controller are modified
  43151. */
  43152. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43153. private _updateTrackpad;
  43154. /**
  43155. * Called once per frame by the engine.
  43156. */
  43157. update(): void;
  43158. /**
  43159. * Called once for each button that changed state since the last frame
  43160. * @param buttonIdx Which button index changed
  43161. * @param state New state of the button
  43162. * @param changes Which properties on the state changed since last frame
  43163. */
  43164. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43165. /**
  43166. * Moves the buttons on the controller mesh based on their current state
  43167. * @param buttonName the name of the button to move
  43168. * @param buttonValue the value of the button which determines the buttons new position
  43169. */
  43170. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43171. /**
  43172. * Moves the axis on the controller mesh based on its current state
  43173. * @param axis the index of the axis
  43174. * @param axisValue the value of the axis which determines the meshes new position
  43175. * @hidden
  43176. */
  43177. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43178. /**
  43179. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43180. * @param scene scene in which to add meshes
  43181. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43182. */
  43183. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43184. /**
  43185. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43186. * can be transformed by button presses and axes values, based on this._mapping.
  43187. *
  43188. * @param scene scene in which the meshes exist
  43189. * @param meshes list of meshes that make up the controller model to process
  43190. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43191. */
  43192. private processModel;
  43193. private createMeshInfo;
  43194. /**
  43195. * Gets the ray of the controller in the direction the controller is pointing
  43196. * @param length the length the resulting ray should be
  43197. * @returns a ray in the direction the controller is pointing
  43198. */
  43199. getForwardRay(length?: number): Ray;
  43200. /**
  43201. * Disposes of the controller
  43202. */
  43203. dispose(): void;
  43204. }
  43205. }
  43206. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43207. import { Observable } from "babylonjs/Misc/observable";
  43208. import { Scene } from "babylonjs/scene";
  43209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43210. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43211. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43212. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43213. /**
  43214. * Oculus Touch Controller
  43215. */
  43216. export class OculusTouchController extends WebVRController {
  43217. /**
  43218. * Base Url for the controller model.
  43219. */
  43220. static MODEL_BASE_URL: string;
  43221. /**
  43222. * File name for the left controller model.
  43223. */
  43224. static MODEL_LEFT_FILENAME: string;
  43225. /**
  43226. * File name for the right controller model.
  43227. */
  43228. static MODEL_RIGHT_FILENAME: string;
  43229. /**
  43230. * Base Url for the Quest controller model.
  43231. */
  43232. static QUEST_MODEL_BASE_URL: string;
  43233. /**
  43234. * @hidden
  43235. * If the controllers are running on a device that needs the updated Quest controller models
  43236. */
  43237. static _IsQuest: boolean;
  43238. /**
  43239. * Fired when the secondary trigger on this controller is modified
  43240. */
  43241. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43242. /**
  43243. * Fired when the thumb rest on this controller is modified
  43244. */
  43245. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43246. /**
  43247. * Creates a new OculusTouchController from a gamepad
  43248. * @param vrGamepad the gamepad that the controller should be created from
  43249. */
  43250. constructor(vrGamepad: any);
  43251. /**
  43252. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43253. * @param scene scene in which to add meshes
  43254. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43255. */
  43256. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43257. /**
  43258. * Fired when the A button on this controller is modified
  43259. */
  43260. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43261. /**
  43262. * Fired when the B button on this controller is modified
  43263. */
  43264. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43265. /**
  43266. * Fired when the X button on this controller is modified
  43267. */
  43268. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43269. /**
  43270. * Fired when the Y button on this controller is modified
  43271. */
  43272. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43273. /**
  43274. * Called once for each button that changed state since the last frame
  43275. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43276. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43277. * 2) secondary trigger (same)
  43278. * 3) A (right) X (left), touch, pressed = value
  43279. * 4) B / Y
  43280. * 5) thumb rest
  43281. * @param buttonIdx Which button index changed
  43282. * @param state New state of the button
  43283. * @param changes Which properties on the state changed since last frame
  43284. */
  43285. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43286. }
  43287. }
  43288. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43289. import { Scene } from "babylonjs/scene";
  43290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43291. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43292. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43293. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43294. import { Observable } from "babylonjs/Misc/observable";
  43295. /**
  43296. * Vive Controller
  43297. */
  43298. export class ViveController extends WebVRController {
  43299. /**
  43300. * Base Url for the controller model.
  43301. */
  43302. static MODEL_BASE_URL: string;
  43303. /**
  43304. * File name for the controller model.
  43305. */
  43306. static MODEL_FILENAME: string;
  43307. /**
  43308. * Creates a new ViveController from a gamepad
  43309. * @param vrGamepad the gamepad that the controller should be created from
  43310. */
  43311. constructor(vrGamepad: any);
  43312. /**
  43313. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43314. * @param scene scene in which to add meshes
  43315. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43316. */
  43317. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43318. /**
  43319. * Fired when the left button on this controller is modified
  43320. */
  43321. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43322. /**
  43323. * Fired when the right button on this controller is modified
  43324. */
  43325. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43326. /**
  43327. * Fired when the menu button on this controller is modified
  43328. */
  43329. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43330. /**
  43331. * Called once for each button that changed state since the last frame
  43332. * Vive mapping:
  43333. * 0: touchpad
  43334. * 1: trigger
  43335. * 2: left AND right buttons
  43336. * 3: menu button
  43337. * @param buttonIdx Which button index changed
  43338. * @param state New state of the button
  43339. * @param changes Which properties on the state changed since last frame
  43340. */
  43341. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43342. }
  43343. }
  43344. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43345. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43346. /**
  43347. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43348. */
  43349. export class WebXRControllerModelLoader {
  43350. /**
  43351. * Creates the WebXRControllerModelLoader
  43352. * @param input xr input that creates the controllers
  43353. */
  43354. constructor(input: WebXRInput);
  43355. }
  43356. }
  43357. declare module "babylonjs/Cameras/XR/index" {
  43358. export * from "babylonjs/Cameras/XR/webXRCamera";
  43359. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43360. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43361. export * from "babylonjs/Cameras/XR/webXRInput";
  43362. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43363. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43364. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43365. export * from "babylonjs/Cameras/XR/webXRController";
  43366. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43367. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43368. }
  43369. declare module "babylonjs/Cameras/RigModes/index" {
  43370. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43371. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43372. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43373. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43374. }
  43375. declare module "babylonjs/Cameras/index" {
  43376. export * from "babylonjs/Cameras/Inputs/index";
  43377. export * from "babylonjs/Cameras/cameraInputsManager";
  43378. export * from "babylonjs/Cameras/camera";
  43379. export * from "babylonjs/Cameras/targetCamera";
  43380. export * from "babylonjs/Cameras/freeCamera";
  43381. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43382. export * from "babylonjs/Cameras/touchCamera";
  43383. export * from "babylonjs/Cameras/arcRotateCamera";
  43384. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43385. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43386. export * from "babylonjs/Cameras/flyCamera";
  43387. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43388. export * from "babylonjs/Cameras/followCamera";
  43389. export * from "babylonjs/Cameras/gamepadCamera";
  43390. export * from "babylonjs/Cameras/Stereoscopic/index";
  43391. export * from "babylonjs/Cameras/universalCamera";
  43392. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43393. export * from "babylonjs/Cameras/VR/index";
  43394. export * from "babylonjs/Cameras/XR/index";
  43395. export * from "babylonjs/Cameras/RigModes/index";
  43396. }
  43397. declare module "babylonjs/Collisions/index" {
  43398. export * from "babylonjs/Collisions/collider";
  43399. export * from "babylonjs/Collisions/collisionCoordinator";
  43400. export * from "babylonjs/Collisions/pickingInfo";
  43401. export * from "babylonjs/Collisions/intersectionInfo";
  43402. export * from "babylonjs/Collisions/meshCollisionData";
  43403. }
  43404. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43405. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43406. import { Vector3 } from "babylonjs/Maths/math.vector";
  43407. import { Ray } from "babylonjs/Culling/ray";
  43408. import { Plane } from "babylonjs/Maths/math.plane";
  43409. /**
  43410. * Contains an array of blocks representing the octree
  43411. */
  43412. export interface IOctreeContainer<T> {
  43413. /**
  43414. * Blocks within the octree
  43415. */
  43416. blocks: Array<OctreeBlock<T>>;
  43417. }
  43418. /**
  43419. * Class used to store a cell in an octree
  43420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43421. */
  43422. export class OctreeBlock<T> {
  43423. /**
  43424. * Gets the content of the current block
  43425. */
  43426. entries: T[];
  43427. /**
  43428. * Gets the list of block children
  43429. */
  43430. blocks: Array<OctreeBlock<T>>;
  43431. private _depth;
  43432. private _maxDepth;
  43433. private _capacity;
  43434. private _minPoint;
  43435. private _maxPoint;
  43436. private _boundingVectors;
  43437. private _creationFunc;
  43438. /**
  43439. * Creates a new block
  43440. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43441. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43442. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43443. * @param depth defines the current depth of this block in the octree
  43444. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43445. * @param creationFunc defines a callback to call when an element is added to the block
  43446. */
  43447. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43448. /**
  43449. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43450. */
  43451. readonly capacity: number;
  43452. /**
  43453. * Gets the minimum vector (in world space) of the block's bounding box
  43454. */
  43455. readonly minPoint: Vector3;
  43456. /**
  43457. * Gets the maximum vector (in world space) of the block's bounding box
  43458. */
  43459. readonly maxPoint: Vector3;
  43460. /**
  43461. * Add a new element to this block
  43462. * @param entry defines the element to add
  43463. */
  43464. addEntry(entry: T): void;
  43465. /**
  43466. * Remove an element from this block
  43467. * @param entry defines the element to remove
  43468. */
  43469. removeEntry(entry: T): void;
  43470. /**
  43471. * Add an array of elements to this block
  43472. * @param entries defines the array of elements to add
  43473. */
  43474. addEntries(entries: T[]): void;
  43475. /**
  43476. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43477. * @param frustumPlanes defines the frustum planes to test
  43478. * @param selection defines the array to store current content if selection is positive
  43479. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43480. */
  43481. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43482. /**
  43483. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43484. * @param sphereCenter defines the bounding sphere center
  43485. * @param sphereRadius defines the bounding sphere radius
  43486. * @param selection defines the array to store current content if selection is positive
  43487. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43488. */
  43489. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43490. /**
  43491. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43492. * @param ray defines the ray to test with
  43493. * @param selection defines the array to store current content if selection is positive
  43494. */
  43495. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43496. /**
  43497. * Subdivide the content into child blocks (this block will then be empty)
  43498. */
  43499. createInnerBlocks(): void;
  43500. /**
  43501. * @hidden
  43502. */
  43503. 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;
  43504. }
  43505. }
  43506. declare module "babylonjs/Culling/Octrees/octree" {
  43507. import { SmartArray } from "babylonjs/Misc/smartArray";
  43508. import { Vector3 } from "babylonjs/Maths/math.vector";
  43509. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43511. import { Ray } from "babylonjs/Culling/ray";
  43512. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43513. import { Plane } from "babylonjs/Maths/math.plane";
  43514. /**
  43515. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43516. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43517. */
  43518. export class Octree<T> {
  43519. /** 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.) */
  43520. maxDepth: number;
  43521. /**
  43522. * Blocks within the octree containing objects
  43523. */
  43524. blocks: Array<OctreeBlock<T>>;
  43525. /**
  43526. * Content stored in the octree
  43527. */
  43528. dynamicContent: T[];
  43529. private _maxBlockCapacity;
  43530. private _selectionContent;
  43531. private _creationFunc;
  43532. /**
  43533. * Creates a octree
  43534. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43535. * @param creationFunc function to be used to instatiate the octree
  43536. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43537. * @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.)
  43538. */
  43539. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43540. /** 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.) */
  43541. maxDepth?: number);
  43542. /**
  43543. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43544. * @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);
  43545. * @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);
  43546. * @param entries meshes to be added to the octree blocks
  43547. */
  43548. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43549. /**
  43550. * Adds a mesh to the octree
  43551. * @param entry Mesh to add to the octree
  43552. */
  43553. addMesh(entry: T): void;
  43554. /**
  43555. * Remove an element from the octree
  43556. * @param entry defines the element to remove
  43557. */
  43558. removeMesh(entry: T): void;
  43559. /**
  43560. * Selects an array of meshes within the frustum
  43561. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43562. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43563. * @returns array of meshes within the frustum
  43564. */
  43565. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43566. /**
  43567. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43568. * @param sphereCenter defines the bounding sphere center
  43569. * @param sphereRadius defines the bounding sphere radius
  43570. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43571. * @returns an array of objects that intersect the sphere
  43572. */
  43573. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43574. /**
  43575. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43576. * @param ray defines the ray to test with
  43577. * @returns array of intersected objects
  43578. */
  43579. intersectsRay(ray: Ray): SmartArray<T>;
  43580. /**
  43581. * Adds a mesh into the octree block if it intersects the block
  43582. */
  43583. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43584. /**
  43585. * Adds a submesh into the octree block if it intersects the block
  43586. */
  43587. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43588. }
  43589. }
  43590. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43591. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43592. import { Scene } from "babylonjs/scene";
  43593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43595. import { Ray } from "babylonjs/Culling/ray";
  43596. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43597. import { Collider } from "babylonjs/Collisions/collider";
  43598. module "babylonjs/scene" {
  43599. interface Scene {
  43600. /**
  43601. * @hidden
  43602. * Backing Filed
  43603. */
  43604. _selectionOctree: Octree<AbstractMesh>;
  43605. /**
  43606. * Gets the octree used to boost mesh selection (picking)
  43607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43608. */
  43609. selectionOctree: Octree<AbstractMesh>;
  43610. /**
  43611. * Creates or updates the octree used to boost selection (picking)
  43612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43613. * @param maxCapacity defines the maximum capacity per leaf
  43614. * @param maxDepth defines the maximum depth of the octree
  43615. * @returns an octree of AbstractMesh
  43616. */
  43617. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43618. }
  43619. }
  43620. module "babylonjs/Meshes/abstractMesh" {
  43621. interface AbstractMesh {
  43622. /**
  43623. * @hidden
  43624. * Backing Field
  43625. */
  43626. _submeshesOctree: Octree<SubMesh>;
  43627. /**
  43628. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43629. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43630. * @param maxCapacity defines the maximum size of each block (64 by default)
  43631. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43632. * @returns the new octree
  43633. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43634. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43635. */
  43636. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43637. }
  43638. }
  43639. /**
  43640. * Defines the octree scene component responsible to manage any octrees
  43641. * in a given scene.
  43642. */
  43643. export class OctreeSceneComponent {
  43644. /**
  43645. * The component name help to identify the component in the list of scene components.
  43646. */
  43647. readonly name: string;
  43648. /**
  43649. * The scene the component belongs to.
  43650. */
  43651. scene: Scene;
  43652. /**
  43653. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43654. */
  43655. readonly checksIsEnabled: boolean;
  43656. /**
  43657. * Creates a new instance of the component for the given scene
  43658. * @param scene Defines the scene to register the component in
  43659. */
  43660. constructor(scene: Scene);
  43661. /**
  43662. * Registers the component in a given scene
  43663. */
  43664. register(): void;
  43665. /**
  43666. * Return the list of active meshes
  43667. * @returns the list of active meshes
  43668. */
  43669. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43670. /**
  43671. * Return the list of active sub meshes
  43672. * @param mesh The mesh to get the candidates sub meshes from
  43673. * @returns the list of active sub meshes
  43674. */
  43675. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43676. private _tempRay;
  43677. /**
  43678. * Return the list of sub meshes intersecting with a given local ray
  43679. * @param mesh defines the mesh to find the submesh for
  43680. * @param localRay defines the ray in local space
  43681. * @returns the list of intersecting sub meshes
  43682. */
  43683. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43684. /**
  43685. * Return the list of sub meshes colliding with a collider
  43686. * @param mesh defines the mesh to find the submesh for
  43687. * @param collider defines the collider to evaluate the collision against
  43688. * @returns the list of colliding sub meshes
  43689. */
  43690. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43691. /**
  43692. * Rebuilds the elements related to this component in case of
  43693. * context lost for instance.
  43694. */
  43695. rebuild(): void;
  43696. /**
  43697. * Disposes the component and the associated ressources.
  43698. */
  43699. dispose(): void;
  43700. }
  43701. }
  43702. declare module "babylonjs/Culling/Octrees/index" {
  43703. export * from "babylonjs/Culling/Octrees/octree";
  43704. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43705. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43706. }
  43707. declare module "babylonjs/Culling/index" {
  43708. export * from "babylonjs/Culling/boundingBox";
  43709. export * from "babylonjs/Culling/boundingInfo";
  43710. export * from "babylonjs/Culling/boundingSphere";
  43711. export * from "babylonjs/Culling/Octrees/index";
  43712. export * from "babylonjs/Culling/ray";
  43713. }
  43714. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43715. import { IDisposable, Scene } from "babylonjs/scene";
  43716. import { Nullable } from "babylonjs/types";
  43717. import { Observable } from "babylonjs/Misc/observable";
  43718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43719. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43720. import { Camera } from "babylonjs/Cameras/camera";
  43721. /**
  43722. * Renders a layer on top of an existing scene
  43723. */
  43724. export class UtilityLayerRenderer implements IDisposable {
  43725. /** the original scene that will be rendered on top of */
  43726. originalScene: Scene;
  43727. private _pointerCaptures;
  43728. private _lastPointerEvents;
  43729. private static _DefaultUtilityLayer;
  43730. private static _DefaultKeepDepthUtilityLayer;
  43731. private _sharedGizmoLight;
  43732. private _renderCamera;
  43733. /**
  43734. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43735. * @returns the camera that is used when rendering the utility layer
  43736. */
  43737. getRenderCamera(): Nullable<Camera>;
  43738. /**
  43739. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43740. * @param cam the camera that should be used when rendering the utility layer
  43741. */
  43742. setRenderCamera(cam: Nullable<Camera>): void;
  43743. /**
  43744. * @hidden
  43745. * Light which used by gizmos to get light shading
  43746. */
  43747. _getSharedGizmoLight(): HemisphericLight;
  43748. /**
  43749. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43750. */
  43751. pickUtilitySceneFirst: boolean;
  43752. /**
  43753. * 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)
  43754. */
  43755. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43756. /**
  43757. * 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)
  43758. */
  43759. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43760. /**
  43761. * The scene that is rendered on top of the original scene
  43762. */
  43763. utilityLayerScene: Scene;
  43764. /**
  43765. * If the utility layer should automatically be rendered on top of existing scene
  43766. */
  43767. shouldRender: boolean;
  43768. /**
  43769. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43770. */
  43771. onlyCheckPointerDownEvents: boolean;
  43772. /**
  43773. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43774. */
  43775. processAllEvents: boolean;
  43776. /**
  43777. * Observable raised when the pointer move from the utility layer scene to the main scene
  43778. */
  43779. onPointerOutObservable: Observable<number>;
  43780. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43781. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43782. private _afterRenderObserver;
  43783. private _sceneDisposeObserver;
  43784. private _originalPointerObserver;
  43785. /**
  43786. * Instantiates a UtilityLayerRenderer
  43787. * @param originalScene the original scene that will be rendered on top of
  43788. * @param handleEvents boolean indicating if the utility layer should handle events
  43789. */
  43790. constructor(
  43791. /** the original scene that will be rendered on top of */
  43792. originalScene: Scene, handleEvents?: boolean);
  43793. private _notifyObservers;
  43794. /**
  43795. * Renders the utility layers scene on top of the original scene
  43796. */
  43797. render(): void;
  43798. /**
  43799. * Disposes of the renderer
  43800. */
  43801. dispose(): void;
  43802. private _updateCamera;
  43803. }
  43804. }
  43805. declare module "babylonjs/Gizmos/gizmo" {
  43806. import { Nullable } from "babylonjs/types";
  43807. import { IDisposable } from "babylonjs/scene";
  43808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43809. import { Mesh } from "babylonjs/Meshes/mesh";
  43810. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43811. /**
  43812. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43813. */
  43814. export class Gizmo implements IDisposable {
  43815. /** The utility layer the gizmo will be added to */
  43816. gizmoLayer: UtilityLayerRenderer;
  43817. /**
  43818. * The root mesh of the gizmo
  43819. */
  43820. _rootMesh: Mesh;
  43821. private _attachedMesh;
  43822. /**
  43823. * Ratio for the scale of the gizmo (Default: 1)
  43824. */
  43825. scaleRatio: number;
  43826. /**
  43827. * If a custom mesh has been set (Default: false)
  43828. */
  43829. protected _customMeshSet: boolean;
  43830. /**
  43831. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43832. * * When set, interactions will be enabled
  43833. */
  43834. attachedMesh: Nullable<AbstractMesh>;
  43835. /**
  43836. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43837. * @param mesh The mesh to replace the default mesh of the gizmo
  43838. */
  43839. setCustomMesh(mesh: Mesh): void;
  43840. /**
  43841. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43842. */
  43843. updateGizmoRotationToMatchAttachedMesh: boolean;
  43844. /**
  43845. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43846. */
  43847. updateGizmoPositionToMatchAttachedMesh: boolean;
  43848. /**
  43849. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43850. */
  43851. updateScale: boolean;
  43852. protected _interactionsEnabled: boolean;
  43853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43854. private _beforeRenderObserver;
  43855. private _tempVector;
  43856. /**
  43857. * Creates a gizmo
  43858. * @param gizmoLayer The utility layer the gizmo will be added to
  43859. */
  43860. constructor(
  43861. /** The utility layer the gizmo will be added to */
  43862. gizmoLayer?: UtilityLayerRenderer);
  43863. /**
  43864. * Updates the gizmo to match the attached mesh's position/rotation
  43865. */
  43866. protected _update(): void;
  43867. /**
  43868. * Disposes of the gizmo
  43869. */
  43870. dispose(): void;
  43871. }
  43872. }
  43873. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43874. import { Observable } from "babylonjs/Misc/observable";
  43875. import { Nullable } from "babylonjs/types";
  43876. import { Vector3 } from "babylonjs/Maths/math.vector";
  43877. import { Color3 } from "babylonjs/Maths/math.color";
  43878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43880. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43881. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43882. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43883. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43884. import { Scene } from "babylonjs/scene";
  43885. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43886. /**
  43887. * Single plane drag gizmo
  43888. */
  43889. export class PlaneDragGizmo extends Gizmo {
  43890. /**
  43891. * Drag behavior responsible for the gizmos dragging interactions
  43892. */
  43893. dragBehavior: PointerDragBehavior;
  43894. private _pointerObserver;
  43895. /**
  43896. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43897. */
  43898. snapDistance: number;
  43899. /**
  43900. * Event that fires each time the gizmo snaps to a new location.
  43901. * * snapDistance is the the change in distance
  43902. */
  43903. onSnapObservable: Observable<{
  43904. snapDistance: number;
  43905. }>;
  43906. private _plane;
  43907. private _coloredMaterial;
  43908. private _hoverMaterial;
  43909. private _isEnabled;
  43910. private _parent;
  43911. /** @hidden */
  43912. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43913. /** @hidden */
  43914. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43915. /**
  43916. * Creates a PlaneDragGizmo
  43917. * @param gizmoLayer The utility layer the gizmo will be added to
  43918. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43919. * @param color The color of the gizmo
  43920. */
  43921. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43922. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43923. /**
  43924. * If the gizmo is enabled
  43925. */
  43926. isEnabled: boolean;
  43927. /**
  43928. * Disposes of the gizmo
  43929. */
  43930. dispose(): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Gizmos/positionGizmo" {
  43934. import { Observable } from "babylonjs/Misc/observable";
  43935. import { Nullable } from "babylonjs/types";
  43936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43937. import { Mesh } from "babylonjs/Meshes/mesh";
  43938. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43939. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43940. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43941. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43942. /**
  43943. * Gizmo that enables dragging a mesh along 3 axis
  43944. */
  43945. export class PositionGizmo extends Gizmo {
  43946. /**
  43947. * Internal gizmo used for interactions on the x axis
  43948. */
  43949. xGizmo: AxisDragGizmo;
  43950. /**
  43951. * Internal gizmo used for interactions on the y axis
  43952. */
  43953. yGizmo: AxisDragGizmo;
  43954. /**
  43955. * Internal gizmo used for interactions on the z axis
  43956. */
  43957. zGizmo: AxisDragGizmo;
  43958. /**
  43959. * Internal gizmo used for interactions on the yz plane
  43960. */
  43961. xPlaneGizmo: PlaneDragGizmo;
  43962. /**
  43963. * Internal gizmo used for interactions on the xz plane
  43964. */
  43965. yPlaneGizmo: PlaneDragGizmo;
  43966. /**
  43967. * Internal gizmo used for interactions on the xy plane
  43968. */
  43969. zPlaneGizmo: PlaneDragGizmo;
  43970. /**
  43971. * private variables
  43972. */
  43973. private _meshAttached;
  43974. private _updateGizmoRotationToMatchAttachedMesh;
  43975. private _snapDistance;
  43976. private _scaleRatio;
  43977. /** Fires an event when any of it's sub gizmos are dragged */
  43978. onDragStartObservable: Observable<unknown>;
  43979. /** Fires an event when any of it's sub gizmos are released from dragging */
  43980. onDragEndObservable: Observable<unknown>;
  43981. /**
  43982. * If set to true, planar drag is enabled
  43983. */
  43984. private _planarGizmoEnabled;
  43985. attachedMesh: Nullable<AbstractMesh>;
  43986. /**
  43987. * Creates a PositionGizmo
  43988. * @param gizmoLayer The utility layer the gizmo will be added to
  43989. */
  43990. constructor(gizmoLayer?: UtilityLayerRenderer);
  43991. /**
  43992. * If the planar drag gizmo is enabled
  43993. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43994. */
  43995. planarGizmoEnabled: boolean;
  43996. updateGizmoRotationToMatchAttachedMesh: boolean;
  43997. /**
  43998. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43999. */
  44000. snapDistance: number;
  44001. /**
  44002. * Ratio for the scale of the gizmo (Default: 1)
  44003. */
  44004. scaleRatio: number;
  44005. /**
  44006. * Disposes of the gizmo
  44007. */
  44008. dispose(): void;
  44009. /**
  44010. * CustomMeshes are not supported by this gizmo
  44011. * @param mesh The mesh to replace the default mesh of the gizmo
  44012. */
  44013. setCustomMesh(mesh: Mesh): void;
  44014. }
  44015. }
  44016. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44017. import { Observable } from "babylonjs/Misc/observable";
  44018. import { Nullable } from "babylonjs/types";
  44019. import { Vector3 } from "babylonjs/Maths/math.vector";
  44020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44022. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44023. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44024. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44025. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44026. import { Scene } from "babylonjs/scene";
  44027. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44028. import { Color3 } from "babylonjs/Maths/math.color";
  44029. /**
  44030. * Single axis drag gizmo
  44031. */
  44032. export class AxisDragGizmo extends Gizmo {
  44033. /**
  44034. * Drag behavior responsible for the gizmos dragging interactions
  44035. */
  44036. dragBehavior: PointerDragBehavior;
  44037. private _pointerObserver;
  44038. /**
  44039. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44040. */
  44041. snapDistance: number;
  44042. /**
  44043. * Event that fires each time the gizmo snaps to a new location.
  44044. * * snapDistance is the the change in distance
  44045. */
  44046. onSnapObservable: Observable<{
  44047. snapDistance: number;
  44048. }>;
  44049. private _isEnabled;
  44050. private _parent;
  44051. private _arrow;
  44052. private _coloredMaterial;
  44053. private _hoverMaterial;
  44054. /** @hidden */
  44055. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44056. /** @hidden */
  44057. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44058. /**
  44059. * Creates an AxisDragGizmo
  44060. * @param gizmoLayer The utility layer the gizmo will be added to
  44061. * @param dragAxis The axis which the gizmo will be able to drag on
  44062. * @param color The color of the gizmo
  44063. */
  44064. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44065. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44066. /**
  44067. * If the gizmo is enabled
  44068. */
  44069. isEnabled: boolean;
  44070. /**
  44071. * Disposes of the gizmo
  44072. */
  44073. dispose(): void;
  44074. }
  44075. }
  44076. declare module "babylonjs/Debug/axesViewer" {
  44077. import { Vector3 } from "babylonjs/Maths/math.vector";
  44078. import { Nullable } from "babylonjs/types";
  44079. import { Scene } from "babylonjs/scene";
  44080. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44081. /**
  44082. * The Axes viewer will show 3 axes in a specific point in space
  44083. */
  44084. export class AxesViewer {
  44085. private _xAxis;
  44086. private _yAxis;
  44087. private _zAxis;
  44088. private _scaleLinesFactor;
  44089. private _instanced;
  44090. /**
  44091. * Gets the hosting scene
  44092. */
  44093. scene: Scene;
  44094. /**
  44095. * Gets or sets a number used to scale line length
  44096. */
  44097. scaleLines: number;
  44098. /** Gets the node hierarchy used to render x-axis */
  44099. readonly xAxis: TransformNode;
  44100. /** Gets the node hierarchy used to render y-axis */
  44101. readonly yAxis: TransformNode;
  44102. /** Gets the node hierarchy used to render z-axis */
  44103. readonly zAxis: TransformNode;
  44104. /**
  44105. * Creates a new AxesViewer
  44106. * @param scene defines the hosting scene
  44107. * @param scaleLines defines a number used to scale line length (1 by default)
  44108. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44109. * @param xAxis defines the node hierarchy used to render the x-axis
  44110. * @param yAxis defines the node hierarchy used to render the y-axis
  44111. * @param zAxis defines the node hierarchy used to render the z-axis
  44112. */
  44113. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44114. /**
  44115. * Force the viewer to update
  44116. * @param position defines the position of the viewer
  44117. * @param xaxis defines the x axis of the viewer
  44118. * @param yaxis defines the y axis of the viewer
  44119. * @param zaxis defines the z axis of the viewer
  44120. */
  44121. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44122. /**
  44123. * Creates an instance of this axes viewer.
  44124. * @returns a new axes viewer with instanced meshes
  44125. */
  44126. createInstance(): AxesViewer;
  44127. /** Releases resources */
  44128. dispose(): void;
  44129. private static _SetRenderingGroupId;
  44130. }
  44131. }
  44132. declare module "babylonjs/Debug/boneAxesViewer" {
  44133. import { Nullable } from "babylonjs/types";
  44134. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44135. import { Vector3 } from "babylonjs/Maths/math.vector";
  44136. import { Mesh } from "babylonjs/Meshes/mesh";
  44137. import { Bone } from "babylonjs/Bones/bone";
  44138. import { Scene } from "babylonjs/scene";
  44139. /**
  44140. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44141. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44142. */
  44143. export class BoneAxesViewer extends AxesViewer {
  44144. /**
  44145. * Gets or sets the target mesh where to display the axes viewer
  44146. */
  44147. mesh: Nullable<Mesh>;
  44148. /**
  44149. * Gets or sets the target bone where to display the axes viewer
  44150. */
  44151. bone: Nullable<Bone>;
  44152. /** Gets current position */
  44153. pos: Vector3;
  44154. /** Gets direction of X axis */
  44155. xaxis: Vector3;
  44156. /** Gets direction of Y axis */
  44157. yaxis: Vector3;
  44158. /** Gets direction of Z axis */
  44159. zaxis: Vector3;
  44160. /**
  44161. * Creates a new BoneAxesViewer
  44162. * @param scene defines the hosting scene
  44163. * @param bone defines the target bone
  44164. * @param mesh defines the target mesh
  44165. * @param scaleLines defines a scaling factor for line length (1 by default)
  44166. */
  44167. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44168. /**
  44169. * Force the viewer to update
  44170. */
  44171. update(): void;
  44172. /** Releases resources */
  44173. dispose(): void;
  44174. }
  44175. }
  44176. declare module "babylonjs/Debug/debugLayer" {
  44177. import { Scene } from "babylonjs/scene";
  44178. /**
  44179. * Interface used to define scene explorer extensibility option
  44180. */
  44181. export interface IExplorerExtensibilityOption {
  44182. /**
  44183. * Define the option label
  44184. */
  44185. label: string;
  44186. /**
  44187. * Defines the action to execute on click
  44188. */
  44189. action: (entity: any) => void;
  44190. }
  44191. /**
  44192. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44193. */
  44194. export interface IExplorerExtensibilityGroup {
  44195. /**
  44196. * Defines a predicate to test if a given type mut be extended
  44197. */
  44198. predicate: (entity: any) => boolean;
  44199. /**
  44200. * Gets the list of options added to a type
  44201. */
  44202. entries: IExplorerExtensibilityOption[];
  44203. }
  44204. /**
  44205. * Interface used to define the options to use to create the Inspector
  44206. */
  44207. export interface IInspectorOptions {
  44208. /**
  44209. * Display in overlay mode (default: false)
  44210. */
  44211. overlay?: boolean;
  44212. /**
  44213. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44214. */
  44215. globalRoot?: HTMLElement;
  44216. /**
  44217. * Display the Scene explorer
  44218. */
  44219. showExplorer?: boolean;
  44220. /**
  44221. * Display the property inspector
  44222. */
  44223. showInspector?: boolean;
  44224. /**
  44225. * Display in embed mode (both panes on the right)
  44226. */
  44227. embedMode?: boolean;
  44228. /**
  44229. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44230. */
  44231. handleResize?: boolean;
  44232. /**
  44233. * Allow the panes to popup (default: true)
  44234. */
  44235. enablePopup?: boolean;
  44236. /**
  44237. * Allow the panes to be closed by users (default: true)
  44238. */
  44239. enableClose?: boolean;
  44240. /**
  44241. * Optional list of extensibility entries
  44242. */
  44243. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44244. /**
  44245. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44246. */
  44247. inspectorURL?: string;
  44248. }
  44249. module "babylonjs/scene" {
  44250. interface Scene {
  44251. /**
  44252. * @hidden
  44253. * Backing field
  44254. */
  44255. _debugLayer: DebugLayer;
  44256. /**
  44257. * Gets the debug layer (aka Inspector) associated with the scene
  44258. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44259. */
  44260. debugLayer: DebugLayer;
  44261. }
  44262. }
  44263. /**
  44264. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44265. * what is happening in your scene
  44266. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44267. */
  44268. export class DebugLayer {
  44269. /**
  44270. * Define the url to get the inspector script from.
  44271. * By default it uses the babylonjs CDN.
  44272. * @ignoreNaming
  44273. */
  44274. static InspectorURL: string;
  44275. private _scene;
  44276. private BJSINSPECTOR;
  44277. private _onPropertyChangedObservable?;
  44278. /**
  44279. * Observable triggered when a property is changed through the inspector.
  44280. */
  44281. readonly onPropertyChangedObservable: any;
  44282. /**
  44283. * Instantiates a new debug layer.
  44284. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44285. * what is happening in your scene
  44286. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44287. * @param scene Defines the scene to inspect
  44288. */
  44289. constructor(scene: Scene);
  44290. /** Creates the inspector window. */
  44291. private _createInspector;
  44292. /**
  44293. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44294. * @param entity defines the entity to select
  44295. * @param lineContainerTitle defines the specific block to highlight
  44296. */
  44297. select(entity: any, lineContainerTitle?: string): void;
  44298. /** Get the inspector from bundle or global */
  44299. private _getGlobalInspector;
  44300. /**
  44301. * Get if the inspector is visible or not.
  44302. * @returns true if visible otherwise, false
  44303. */
  44304. isVisible(): boolean;
  44305. /**
  44306. * Hide the inspector and close its window.
  44307. */
  44308. hide(): void;
  44309. /**
  44310. * Launch the debugLayer.
  44311. * @param config Define the configuration of the inspector
  44312. * @return a promise fulfilled when the debug layer is visible
  44313. */
  44314. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44315. }
  44316. }
  44317. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44318. import { Nullable } from "babylonjs/types";
  44319. import { Scene } from "babylonjs/scene";
  44320. import { Vector4 } from "babylonjs/Maths/math.vector";
  44321. import { Color4 } from "babylonjs/Maths/math.color";
  44322. import { Mesh } from "babylonjs/Meshes/mesh";
  44323. /**
  44324. * Class containing static functions to help procedurally build meshes
  44325. */
  44326. export class BoxBuilder {
  44327. /**
  44328. * Creates a box mesh
  44329. * * The parameter `size` sets the size (float) of each box side (default 1)
  44330. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44331. * * 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)
  44332. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44336. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44337. * @param name defines the name of the mesh
  44338. * @param options defines the options used to create the mesh
  44339. * @param scene defines the hosting scene
  44340. * @returns the box mesh
  44341. */
  44342. static CreateBox(name: string, options: {
  44343. size?: number;
  44344. width?: number;
  44345. height?: number;
  44346. depth?: number;
  44347. faceUV?: Vector4[];
  44348. faceColors?: Color4[];
  44349. sideOrientation?: number;
  44350. frontUVs?: Vector4;
  44351. backUVs?: Vector4;
  44352. wrap?: boolean;
  44353. topBaseAt?: number;
  44354. bottomBaseAt?: number;
  44355. updatable?: boolean;
  44356. }, scene?: Nullable<Scene>): Mesh;
  44357. }
  44358. }
  44359. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44360. import { Vector4 } from "babylonjs/Maths/math.vector";
  44361. import { Mesh } from "babylonjs/Meshes/mesh";
  44362. /**
  44363. * Class containing static functions to help procedurally build meshes
  44364. */
  44365. export class SphereBuilder {
  44366. /**
  44367. * Creates a sphere mesh
  44368. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44369. * * 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`)
  44370. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44371. * * 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
  44372. * * 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)
  44373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44376. * @param name defines the name of the mesh
  44377. * @param options defines the options used to create the mesh
  44378. * @param scene defines the hosting scene
  44379. * @returns the sphere mesh
  44380. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44381. */
  44382. static CreateSphere(name: string, options: {
  44383. segments?: number;
  44384. diameter?: number;
  44385. diameterX?: number;
  44386. diameterY?: number;
  44387. diameterZ?: number;
  44388. arc?: number;
  44389. slice?: number;
  44390. sideOrientation?: number;
  44391. frontUVs?: Vector4;
  44392. backUVs?: Vector4;
  44393. updatable?: boolean;
  44394. }, scene: any): Mesh;
  44395. }
  44396. }
  44397. declare module "babylonjs/Debug/physicsViewer" {
  44398. import { Nullable } from "babylonjs/types";
  44399. import { Scene } from "babylonjs/scene";
  44400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44401. import { Mesh } from "babylonjs/Meshes/mesh";
  44402. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44403. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44404. /**
  44405. * Used to show the physics impostor around the specific mesh
  44406. */
  44407. export class PhysicsViewer {
  44408. /** @hidden */
  44409. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44410. /** @hidden */
  44411. protected _meshes: Array<Nullable<AbstractMesh>>;
  44412. /** @hidden */
  44413. protected _scene: Nullable<Scene>;
  44414. /** @hidden */
  44415. protected _numMeshes: number;
  44416. /** @hidden */
  44417. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44418. private _renderFunction;
  44419. private _utilityLayer;
  44420. private _debugBoxMesh;
  44421. private _debugSphereMesh;
  44422. private _debugCylinderMesh;
  44423. private _debugMaterial;
  44424. private _debugMeshMeshes;
  44425. /**
  44426. * Creates a new PhysicsViewer
  44427. * @param scene defines the hosting scene
  44428. */
  44429. constructor(scene: Scene);
  44430. /** @hidden */
  44431. protected _updateDebugMeshes(): void;
  44432. /**
  44433. * Renders a specified physic impostor
  44434. * @param impostor defines the impostor to render
  44435. * @param targetMesh defines the mesh represented by the impostor
  44436. * @returns the new debug mesh used to render the impostor
  44437. */
  44438. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44439. /**
  44440. * Hides a specified physic impostor
  44441. * @param impostor defines the impostor to hide
  44442. */
  44443. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44444. private _getDebugMaterial;
  44445. private _getDebugBoxMesh;
  44446. private _getDebugSphereMesh;
  44447. private _getDebugCylinderMesh;
  44448. private _getDebugMeshMesh;
  44449. private _getDebugMesh;
  44450. /** Releases all resources */
  44451. dispose(): void;
  44452. }
  44453. }
  44454. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44455. import { Vector3 } from "babylonjs/Maths/math.vector";
  44456. import { Color4 } from "babylonjs/Maths/math.color";
  44457. import { Nullable } from "babylonjs/types";
  44458. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44459. import { Scene } from "babylonjs/scene";
  44460. /**
  44461. * Class containing static functions to help procedurally build meshes
  44462. */
  44463. export class LinesBuilder {
  44464. /**
  44465. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44466. * * 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
  44467. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44468. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44469. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44470. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44471. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44472. * * 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
  44473. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44476. * @param name defines the name of the new line system
  44477. * @param options defines the options used to create the line system
  44478. * @param scene defines the hosting scene
  44479. * @returns a new line system mesh
  44480. */
  44481. static CreateLineSystem(name: string, options: {
  44482. lines: Vector3[][];
  44483. updatable?: boolean;
  44484. instance?: Nullable<LinesMesh>;
  44485. colors?: Nullable<Color4[][]>;
  44486. useVertexAlpha?: boolean;
  44487. }, scene: Nullable<Scene>): LinesMesh;
  44488. /**
  44489. * Creates a line mesh
  44490. * 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
  44491. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44492. * * The parameter `points` is an array successive Vector3
  44493. * * 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
  44494. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44495. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44496. * * When updating an instance, remember that only point positions can change, not the number of points
  44497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44499. * @param name defines the name of the new line system
  44500. * @param options defines the options used to create the line system
  44501. * @param scene defines the hosting scene
  44502. * @returns a new line mesh
  44503. */
  44504. static CreateLines(name: string, options: {
  44505. points: Vector3[];
  44506. updatable?: boolean;
  44507. instance?: Nullable<LinesMesh>;
  44508. colors?: Color4[];
  44509. useVertexAlpha?: boolean;
  44510. }, scene?: Nullable<Scene>): LinesMesh;
  44511. /**
  44512. * Creates a dashed line mesh
  44513. * * 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
  44514. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44515. * * The parameter `points` is an array successive Vector3
  44516. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44517. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44518. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44519. * * 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
  44520. * * When updating an instance, remember that only point positions can change, not the number of points
  44521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44522. * @param name defines the name of the mesh
  44523. * @param options defines the options used to create the mesh
  44524. * @param scene defines the hosting scene
  44525. * @returns the dashed line mesh
  44526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44527. */
  44528. static CreateDashedLines(name: string, options: {
  44529. points: Vector3[];
  44530. dashSize?: number;
  44531. gapSize?: number;
  44532. dashNb?: number;
  44533. updatable?: boolean;
  44534. instance?: LinesMesh;
  44535. }, scene?: Nullable<Scene>): LinesMesh;
  44536. }
  44537. }
  44538. declare module "babylonjs/Debug/rayHelper" {
  44539. import { Nullable } from "babylonjs/types";
  44540. import { Ray } from "babylonjs/Culling/ray";
  44541. import { Vector3 } from "babylonjs/Maths/math.vector";
  44542. import { Color3 } from "babylonjs/Maths/math.color";
  44543. import { Scene } from "babylonjs/scene";
  44544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44545. import "babylonjs/Meshes/Builders/linesBuilder";
  44546. /**
  44547. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44548. * in order to better appreciate the issue one might have.
  44549. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44550. */
  44551. export class RayHelper {
  44552. /**
  44553. * Defines the ray we are currently tryin to visualize.
  44554. */
  44555. ray: Nullable<Ray>;
  44556. private _renderPoints;
  44557. private _renderLine;
  44558. private _renderFunction;
  44559. private _scene;
  44560. private _updateToMeshFunction;
  44561. private _attachedToMesh;
  44562. private _meshSpaceDirection;
  44563. private _meshSpaceOrigin;
  44564. /**
  44565. * Helper function to create a colored helper in a scene in one line.
  44566. * @param ray Defines the ray we are currently tryin to visualize
  44567. * @param scene Defines the scene the ray is used in
  44568. * @param color Defines the color we want to see the ray in
  44569. * @returns The newly created ray helper.
  44570. */
  44571. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44572. /**
  44573. * Instantiate a new ray helper.
  44574. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44575. * in order to better appreciate the issue one might have.
  44576. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44577. * @param ray Defines the ray we are currently tryin to visualize
  44578. */
  44579. constructor(ray: Ray);
  44580. /**
  44581. * Shows the ray we are willing to debug.
  44582. * @param scene Defines the scene the ray needs to be rendered in
  44583. * @param color Defines the color the ray needs to be rendered in
  44584. */
  44585. show(scene: Scene, color?: Color3): void;
  44586. /**
  44587. * Hides the ray we are debugging.
  44588. */
  44589. hide(): void;
  44590. private _render;
  44591. /**
  44592. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44593. * @param mesh Defines the mesh we want the helper attached to
  44594. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44595. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44596. * @param length Defines the length of the ray
  44597. */
  44598. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44599. /**
  44600. * Detach the ray helper from the mesh it has previously been attached to.
  44601. */
  44602. detachFromMesh(): void;
  44603. private _updateToMesh;
  44604. /**
  44605. * Dispose the helper and release its associated resources.
  44606. */
  44607. dispose(): void;
  44608. }
  44609. }
  44610. declare module "babylonjs/Debug/skeletonViewer" {
  44611. import { Color3 } from "babylonjs/Maths/math.color";
  44612. import { Scene } from "babylonjs/scene";
  44613. import { Nullable } from "babylonjs/types";
  44614. import { Skeleton } from "babylonjs/Bones/skeleton";
  44615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44616. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44617. /**
  44618. * Class used to render a debug view of a given skeleton
  44619. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44620. */
  44621. export class SkeletonViewer {
  44622. /** defines the skeleton to render */
  44623. skeleton: Skeleton;
  44624. /** defines the mesh attached to the skeleton */
  44625. mesh: AbstractMesh;
  44626. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44627. autoUpdateBonesMatrices: boolean;
  44628. /** defines the rendering group id to use with the viewer */
  44629. renderingGroupId: number;
  44630. /** Gets or sets the color used to render the skeleton */
  44631. color: Color3;
  44632. private _scene;
  44633. private _debugLines;
  44634. private _debugMesh;
  44635. private _isEnabled;
  44636. private _renderFunction;
  44637. private _utilityLayer;
  44638. /**
  44639. * Returns the mesh used to render the bones
  44640. */
  44641. readonly debugMesh: Nullable<LinesMesh>;
  44642. /**
  44643. * Creates a new SkeletonViewer
  44644. * @param skeleton defines the skeleton to render
  44645. * @param mesh defines the mesh attached to the skeleton
  44646. * @param scene defines the hosting scene
  44647. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44648. * @param renderingGroupId defines the rendering group id to use with the viewer
  44649. */
  44650. constructor(
  44651. /** defines the skeleton to render */
  44652. skeleton: Skeleton,
  44653. /** defines the mesh attached to the skeleton */
  44654. mesh: AbstractMesh, scene: Scene,
  44655. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44656. autoUpdateBonesMatrices?: boolean,
  44657. /** defines the rendering group id to use with the viewer */
  44658. renderingGroupId?: number);
  44659. /** Gets or sets a boolean indicating if the viewer is enabled */
  44660. isEnabled: boolean;
  44661. private _getBonePosition;
  44662. private _getLinesForBonesWithLength;
  44663. private _getLinesForBonesNoLength;
  44664. /** Update the viewer to sync with current skeleton state */
  44665. update(): void;
  44666. /** Release associated resources */
  44667. dispose(): void;
  44668. }
  44669. }
  44670. declare module "babylonjs/Debug/index" {
  44671. export * from "babylonjs/Debug/axesViewer";
  44672. export * from "babylonjs/Debug/boneAxesViewer";
  44673. export * from "babylonjs/Debug/debugLayer";
  44674. export * from "babylonjs/Debug/physicsViewer";
  44675. export * from "babylonjs/Debug/rayHelper";
  44676. export * from "babylonjs/Debug/skeletonViewer";
  44677. }
  44678. declare module "babylonjs/Engines/nullEngine" {
  44679. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44680. import { Scene } from "babylonjs/scene";
  44681. import { Engine } from "babylonjs/Engines/engine";
  44682. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44683. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44685. import { Effect } from "babylonjs/Materials/effect";
  44686. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44687. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44688. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44689. /**
  44690. * Options to create the null engine
  44691. */
  44692. export class NullEngineOptions {
  44693. /**
  44694. * Render width (Default: 512)
  44695. */
  44696. renderWidth: number;
  44697. /**
  44698. * Render height (Default: 256)
  44699. */
  44700. renderHeight: number;
  44701. /**
  44702. * Texture size (Default: 512)
  44703. */
  44704. textureSize: number;
  44705. /**
  44706. * If delta time between frames should be constant
  44707. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44708. */
  44709. deterministicLockstep: boolean;
  44710. /**
  44711. * Maximum about of steps between frames (Default: 4)
  44712. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44713. */
  44714. lockstepMaxSteps: number;
  44715. }
  44716. /**
  44717. * The null engine class provides support for headless version of babylon.js.
  44718. * This can be used in server side scenario or for testing purposes
  44719. */
  44720. export class NullEngine extends Engine {
  44721. private _options;
  44722. /**
  44723. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44724. */
  44725. isDeterministicLockStep(): boolean;
  44726. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44727. getLockstepMaxSteps(): number;
  44728. /**
  44729. * Sets hardware scaling, used to save performance if needed
  44730. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44731. */
  44732. getHardwareScalingLevel(): number;
  44733. constructor(options?: NullEngineOptions);
  44734. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44735. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44736. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44737. getRenderWidth(useScreen?: boolean): number;
  44738. getRenderHeight(useScreen?: boolean): number;
  44739. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44740. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44741. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44742. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44743. bindSamplers(effect: Effect): void;
  44744. enableEffect(effect: Effect): void;
  44745. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44746. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44747. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44748. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44749. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44750. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44751. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44752. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44753. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44754. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44755. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44756. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44757. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44758. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44759. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44760. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44761. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44762. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44763. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44764. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44765. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44767. bindBuffers(vertexBuffers: {
  44768. [key: string]: VertexBuffer;
  44769. }, indexBuffer: DataBuffer, effect: Effect): void;
  44770. wipeCaches(bruteForce?: boolean): void;
  44771. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44772. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44773. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44774. /** @hidden */
  44775. _createTexture(): WebGLTexture;
  44776. /** @hidden */
  44777. _releaseTexture(texture: InternalTexture): void;
  44778. 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;
  44779. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44780. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44781. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44782. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44783. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44784. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44785. areAllEffectsReady(): boolean;
  44786. /**
  44787. * @hidden
  44788. * Get the current error code of the webGL context
  44789. * @returns the error code
  44790. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44791. */
  44792. getError(): number;
  44793. /** @hidden */
  44794. _getUnpackAlignement(): number;
  44795. /** @hidden */
  44796. _unpackFlipY(value: boolean): void;
  44797. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44798. /**
  44799. * Updates a dynamic vertex buffer.
  44800. * @param vertexBuffer the vertex buffer to update
  44801. * @param data the data used to update the vertex buffer
  44802. * @param byteOffset the byte offset of the data (optional)
  44803. * @param byteLength the byte length of the data (optional)
  44804. */
  44805. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44806. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44807. /** @hidden */
  44808. _bindTexture(channel: number, texture: InternalTexture): void;
  44809. /** @hidden */
  44810. _releaseBuffer(buffer: DataBuffer): boolean;
  44811. releaseEffects(): void;
  44812. displayLoadingUI(): void;
  44813. hideLoadingUI(): void;
  44814. /** @hidden */
  44815. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44816. /** @hidden */
  44817. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44818. /** @hidden */
  44819. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44820. /** @hidden */
  44821. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44822. }
  44823. }
  44824. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44825. import { Nullable, int } from "babylonjs/types";
  44826. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44827. /** @hidden */
  44828. export class _OcclusionDataStorage {
  44829. /** @hidden */
  44830. occlusionInternalRetryCounter: number;
  44831. /** @hidden */
  44832. isOcclusionQueryInProgress: boolean;
  44833. /** @hidden */
  44834. isOccluded: boolean;
  44835. /** @hidden */
  44836. occlusionRetryCount: number;
  44837. /** @hidden */
  44838. occlusionType: number;
  44839. /** @hidden */
  44840. occlusionQueryAlgorithmType: number;
  44841. }
  44842. module "babylonjs/Engines/engine" {
  44843. interface Engine {
  44844. /**
  44845. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44846. * @return the new query
  44847. */
  44848. createQuery(): WebGLQuery;
  44849. /**
  44850. * Delete and release a webGL query
  44851. * @param query defines the query to delete
  44852. * @return the current engine
  44853. */
  44854. deleteQuery(query: WebGLQuery): Engine;
  44855. /**
  44856. * Check if a given query has resolved and got its value
  44857. * @param query defines the query to check
  44858. * @returns true if the query got its value
  44859. */
  44860. isQueryResultAvailable(query: WebGLQuery): boolean;
  44861. /**
  44862. * Gets the value of a given query
  44863. * @param query defines the query to check
  44864. * @returns the value of the query
  44865. */
  44866. getQueryResult(query: WebGLQuery): number;
  44867. /**
  44868. * Initiates an occlusion query
  44869. * @param algorithmType defines the algorithm to use
  44870. * @param query defines the query to use
  44871. * @returns the current engine
  44872. * @see http://doc.babylonjs.com/features/occlusionquery
  44873. */
  44874. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44875. /**
  44876. * Ends an occlusion query
  44877. * @see http://doc.babylonjs.com/features/occlusionquery
  44878. * @param algorithmType defines the algorithm to use
  44879. * @returns the current engine
  44880. */
  44881. endOcclusionQuery(algorithmType: number): Engine;
  44882. /**
  44883. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44884. * Please note that only one query can be issued at a time
  44885. * @returns a time token used to track the time span
  44886. */
  44887. startTimeQuery(): Nullable<_TimeToken>;
  44888. /**
  44889. * Ends a time query
  44890. * @param token defines the token used to measure the time span
  44891. * @returns the time spent (in ns)
  44892. */
  44893. endTimeQuery(token: _TimeToken): int;
  44894. /** @hidden */
  44895. _currentNonTimestampToken: Nullable<_TimeToken>;
  44896. /** @hidden */
  44897. _createTimeQuery(): WebGLQuery;
  44898. /** @hidden */
  44899. _deleteTimeQuery(query: WebGLQuery): void;
  44900. /** @hidden */
  44901. _getGlAlgorithmType(algorithmType: number): number;
  44902. /** @hidden */
  44903. _getTimeQueryResult(query: WebGLQuery): any;
  44904. /** @hidden */
  44905. _getTimeQueryAvailability(query: WebGLQuery): any;
  44906. }
  44907. }
  44908. module "babylonjs/Meshes/abstractMesh" {
  44909. interface AbstractMesh {
  44910. /**
  44911. * Backing filed
  44912. * @hidden
  44913. */
  44914. __occlusionDataStorage: _OcclusionDataStorage;
  44915. /**
  44916. * Access property
  44917. * @hidden
  44918. */
  44919. _occlusionDataStorage: _OcclusionDataStorage;
  44920. /**
  44921. * 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.
  44922. * The default value is -1 which means don't break the query and wait till the result
  44923. * @see http://doc.babylonjs.com/features/occlusionquery
  44924. */
  44925. occlusionRetryCount: number;
  44926. /**
  44927. * 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:
  44928. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44929. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44930. * * 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.
  44931. * @see http://doc.babylonjs.com/features/occlusionquery
  44932. */
  44933. occlusionType: number;
  44934. /**
  44935. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44936. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44937. * * 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.
  44938. * @see http://doc.babylonjs.com/features/occlusionquery
  44939. */
  44940. occlusionQueryAlgorithmType: number;
  44941. /**
  44942. * 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
  44943. * @see http://doc.babylonjs.com/features/occlusionquery
  44944. */
  44945. isOccluded: boolean;
  44946. /**
  44947. * Flag to check the progress status of the query
  44948. * @see http://doc.babylonjs.com/features/occlusionquery
  44949. */
  44950. isOcclusionQueryInProgress: boolean;
  44951. }
  44952. }
  44953. }
  44954. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44955. import { Nullable } from "babylonjs/types";
  44956. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44957. /** @hidden */
  44958. export var _forceTransformFeedbackToBundle: boolean;
  44959. module "babylonjs/Engines/engine" {
  44960. interface Engine {
  44961. /**
  44962. * Creates a webGL transform feedback object
  44963. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44964. * @returns the webGL transform feedback object
  44965. */
  44966. createTransformFeedback(): WebGLTransformFeedback;
  44967. /**
  44968. * Delete a webGL transform feedback object
  44969. * @param value defines the webGL transform feedback object to delete
  44970. */
  44971. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44972. /**
  44973. * Bind a webGL transform feedback object to the webgl context
  44974. * @param value defines the webGL transform feedback object to bind
  44975. */
  44976. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44977. /**
  44978. * Begins a transform feedback operation
  44979. * @param usePoints defines if points or triangles must be used
  44980. */
  44981. beginTransformFeedback(usePoints: boolean): void;
  44982. /**
  44983. * Ends a transform feedback operation
  44984. */
  44985. endTransformFeedback(): void;
  44986. /**
  44987. * Specify the varyings to use with transform feedback
  44988. * @param program defines the associated webGL program
  44989. * @param value defines the list of strings representing the varying names
  44990. */
  44991. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44992. /**
  44993. * Bind a webGL buffer for a transform feedback operation
  44994. * @param value defines the webGL buffer to bind
  44995. */
  44996. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44997. }
  44998. }
  44999. }
  45000. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45001. import { Scene } from "babylonjs/scene";
  45002. import { Engine } from "babylonjs/Engines/engine";
  45003. import { Texture } from "babylonjs/Materials/Textures/texture";
  45004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45005. import "babylonjs/Engines/Extensions/engine.multiRender";
  45006. /**
  45007. * Creation options of the multi render target texture.
  45008. */
  45009. export interface IMultiRenderTargetOptions {
  45010. /**
  45011. * Define if the texture needs to create mip maps after render.
  45012. */
  45013. generateMipMaps?: boolean;
  45014. /**
  45015. * Define the types of all the draw buffers we want to create
  45016. */
  45017. types?: number[];
  45018. /**
  45019. * Define the sampling modes of all the draw buffers we want to create
  45020. */
  45021. samplingModes?: number[];
  45022. /**
  45023. * Define if a depth buffer is required
  45024. */
  45025. generateDepthBuffer?: boolean;
  45026. /**
  45027. * Define if a stencil buffer is required
  45028. */
  45029. generateStencilBuffer?: boolean;
  45030. /**
  45031. * Define if a depth texture is required instead of a depth buffer
  45032. */
  45033. generateDepthTexture?: boolean;
  45034. /**
  45035. * Define the number of desired draw buffers
  45036. */
  45037. textureCount?: number;
  45038. /**
  45039. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45040. */
  45041. doNotChangeAspectRatio?: boolean;
  45042. /**
  45043. * Define the default type of the buffers we are creating
  45044. */
  45045. defaultType?: number;
  45046. }
  45047. /**
  45048. * A multi render target, like a render target provides the ability to render to a texture.
  45049. * Unlike the render target, it can render to several draw buffers in one draw.
  45050. * This is specially interesting in deferred rendering or for any effects requiring more than
  45051. * just one color from a single pass.
  45052. */
  45053. export class MultiRenderTarget extends RenderTargetTexture {
  45054. private _internalTextures;
  45055. private _textures;
  45056. private _multiRenderTargetOptions;
  45057. /**
  45058. * Get if draw buffers are currently supported by the used hardware and browser.
  45059. */
  45060. readonly isSupported: boolean;
  45061. /**
  45062. * Get the list of textures generated by the multi render target.
  45063. */
  45064. readonly textures: Texture[];
  45065. /**
  45066. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45067. */
  45068. readonly depthTexture: Texture;
  45069. /**
  45070. * Set the wrapping mode on U of all the textures we are rendering to.
  45071. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45072. */
  45073. wrapU: number;
  45074. /**
  45075. * Set the wrapping mode on V of all the textures we are rendering to.
  45076. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45077. */
  45078. wrapV: number;
  45079. /**
  45080. * Instantiate a new multi render target texture.
  45081. * A multi render target, like a render target provides the ability to render to a texture.
  45082. * Unlike the render target, it can render to several draw buffers in one draw.
  45083. * This is specially interesting in deferred rendering or for any effects requiring more than
  45084. * just one color from a single pass.
  45085. * @param name Define the name of the texture
  45086. * @param size Define the size of the buffers to render to
  45087. * @param count Define the number of target we are rendering into
  45088. * @param scene Define the scene the texture belongs to
  45089. * @param options Define the options used to create the multi render target
  45090. */
  45091. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45092. /** @hidden */
  45093. _rebuild(): void;
  45094. private _createInternalTextures;
  45095. private _createTextures;
  45096. /**
  45097. * Define the number of samples used if MSAA is enabled.
  45098. */
  45099. samples: number;
  45100. /**
  45101. * Resize all the textures in the multi render target.
  45102. * Be carrefull as it will recreate all the data in the new texture.
  45103. * @param size Define the new size
  45104. */
  45105. resize(size: any): void;
  45106. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45107. /**
  45108. * Dispose the render targets and their associated resources
  45109. */
  45110. dispose(): void;
  45111. /**
  45112. * Release all the underlying texture used as draw buffers.
  45113. */
  45114. releaseInternalTextures(): void;
  45115. }
  45116. }
  45117. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45119. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45120. import { Nullable } from "babylonjs/types";
  45121. module "babylonjs/Engines/engine" {
  45122. interface Engine {
  45123. /**
  45124. * Unbind a list of render target textures from the webGL context
  45125. * This is used only when drawBuffer extension or webGL2 are active
  45126. * @param textures defines the render target textures to unbind
  45127. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45128. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45129. */
  45130. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45131. /**
  45132. * Create a multi render target texture
  45133. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45134. * @param size defines the size of the texture
  45135. * @param options defines the creation options
  45136. * @returns the cube texture as an InternalTexture
  45137. */
  45138. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45139. /**
  45140. * Update the sample count for a given multiple render target texture
  45141. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45142. * @param textures defines the textures to update
  45143. * @param samples defines the sample count to set
  45144. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45145. */
  45146. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45147. }
  45148. }
  45149. }
  45150. declare module "babylonjs/Engines/Extensions/index" {
  45151. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45152. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45153. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45154. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45155. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45156. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45157. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45158. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45159. }
  45160. declare module "babylonjs/Engines/index" {
  45161. export * from "babylonjs/Engines/constants";
  45162. export * from "babylonjs/Engines/engine";
  45163. export * from "babylonjs/Engines/engineStore";
  45164. export * from "babylonjs/Engines/nullEngine";
  45165. export * from "babylonjs/Engines/Extensions/index";
  45166. export * from "babylonjs/Engines/IPipelineContext";
  45167. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45168. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45169. }
  45170. declare module "babylonjs/Events/clipboardEvents" {
  45171. /**
  45172. * Gather the list of clipboard event types as constants.
  45173. */
  45174. export class ClipboardEventTypes {
  45175. /**
  45176. * The clipboard event is fired when a copy command is active (pressed).
  45177. */
  45178. static readonly COPY: number;
  45179. /**
  45180. * The clipboard event is fired when a cut command is active (pressed).
  45181. */
  45182. static readonly CUT: number;
  45183. /**
  45184. * The clipboard event is fired when a paste command is active (pressed).
  45185. */
  45186. static readonly PASTE: number;
  45187. }
  45188. /**
  45189. * This class is used to store clipboard related info for the onClipboardObservable event.
  45190. */
  45191. export class ClipboardInfo {
  45192. /**
  45193. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45194. */
  45195. type: number;
  45196. /**
  45197. * Defines the related dom event
  45198. */
  45199. event: ClipboardEvent;
  45200. /**
  45201. *Creates an instance of ClipboardInfo.
  45202. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45203. * @param event Defines the related dom event
  45204. */
  45205. constructor(
  45206. /**
  45207. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45208. */
  45209. type: number,
  45210. /**
  45211. * Defines the related dom event
  45212. */
  45213. event: ClipboardEvent);
  45214. /**
  45215. * Get the clipboard event's type from the keycode.
  45216. * @param keyCode Defines the keyCode for the current keyboard event.
  45217. * @return {number}
  45218. */
  45219. static GetTypeFromCharacter(keyCode: number): number;
  45220. }
  45221. }
  45222. declare module "babylonjs/Events/index" {
  45223. export * from "babylonjs/Events/keyboardEvents";
  45224. export * from "babylonjs/Events/pointerEvents";
  45225. export * from "babylonjs/Events/clipboardEvents";
  45226. }
  45227. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45228. import { Scene } from "babylonjs/scene";
  45229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45230. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45231. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45232. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45233. /**
  45234. * Google Daydream controller
  45235. */
  45236. export class DaydreamController extends WebVRController {
  45237. /**
  45238. * Base Url for the controller model.
  45239. */
  45240. static MODEL_BASE_URL: string;
  45241. /**
  45242. * File name for the controller model.
  45243. */
  45244. static MODEL_FILENAME: string;
  45245. /**
  45246. * Gamepad Id prefix used to identify Daydream Controller.
  45247. */
  45248. static readonly GAMEPAD_ID_PREFIX: string;
  45249. /**
  45250. * Creates a new DaydreamController from a gamepad
  45251. * @param vrGamepad the gamepad that the controller should be created from
  45252. */
  45253. constructor(vrGamepad: any);
  45254. /**
  45255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45256. * @param scene scene in which to add meshes
  45257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45258. */
  45259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45260. /**
  45261. * Called once for each button that changed state since the last frame
  45262. * @param buttonIdx Which button index changed
  45263. * @param state New state of the button
  45264. * @param changes Which properties on the state changed since last frame
  45265. */
  45266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45267. }
  45268. }
  45269. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45270. import { Scene } from "babylonjs/scene";
  45271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45272. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45273. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45274. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45275. /**
  45276. * Gear VR Controller
  45277. */
  45278. export class GearVRController extends WebVRController {
  45279. /**
  45280. * Base Url for the controller model.
  45281. */
  45282. static MODEL_BASE_URL: string;
  45283. /**
  45284. * File name for the controller model.
  45285. */
  45286. static MODEL_FILENAME: string;
  45287. /**
  45288. * Gamepad Id prefix used to identify this controller.
  45289. */
  45290. static readonly GAMEPAD_ID_PREFIX: string;
  45291. private readonly _buttonIndexToObservableNameMap;
  45292. /**
  45293. * Creates a new GearVRController from a gamepad
  45294. * @param vrGamepad the gamepad that the controller should be created from
  45295. */
  45296. constructor(vrGamepad: any);
  45297. /**
  45298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45299. * @param scene scene in which to add meshes
  45300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45301. */
  45302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45303. /**
  45304. * Called once for each button that changed state since the last frame
  45305. * @param buttonIdx Which button index changed
  45306. * @param state New state of the button
  45307. * @param changes Which properties on the state changed since last frame
  45308. */
  45309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45310. }
  45311. }
  45312. declare module "babylonjs/Gamepads/Controllers/index" {
  45313. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45314. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45315. export * from "babylonjs/Gamepads/Controllers/genericController";
  45316. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45317. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45318. export * from "babylonjs/Gamepads/Controllers/viveController";
  45319. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45320. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45321. }
  45322. declare module "babylonjs/Gamepads/index" {
  45323. export * from "babylonjs/Gamepads/Controllers/index";
  45324. export * from "babylonjs/Gamepads/gamepad";
  45325. export * from "babylonjs/Gamepads/gamepadManager";
  45326. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45327. export * from "babylonjs/Gamepads/xboxGamepad";
  45328. }
  45329. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45330. import { Scene } from "babylonjs/scene";
  45331. import { Vector4 } from "babylonjs/Maths/math.vector";
  45332. import { Color4 } from "babylonjs/Maths/math.color";
  45333. import { Mesh } from "babylonjs/Meshes/mesh";
  45334. import { Nullable } from "babylonjs/types";
  45335. /**
  45336. * Class containing static functions to help procedurally build meshes
  45337. */
  45338. export class PolyhedronBuilder {
  45339. /**
  45340. * Creates a polyhedron mesh
  45341. * * 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
  45342. * * The parameter `size` (positive float, default 1) sets the polygon size
  45343. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45344. * * 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`
  45345. * * 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
  45346. * * 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)`)
  45347. * * 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
  45348. * * 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
  45349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45352. * @param name defines the name of the mesh
  45353. * @param options defines the options used to create the mesh
  45354. * @param scene defines the hosting scene
  45355. * @returns the polyhedron mesh
  45356. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45357. */
  45358. static CreatePolyhedron(name: string, options: {
  45359. type?: number;
  45360. size?: number;
  45361. sizeX?: number;
  45362. sizeY?: number;
  45363. sizeZ?: number;
  45364. custom?: any;
  45365. faceUV?: Vector4[];
  45366. faceColors?: Color4[];
  45367. flat?: boolean;
  45368. updatable?: boolean;
  45369. sideOrientation?: number;
  45370. frontUVs?: Vector4;
  45371. backUVs?: Vector4;
  45372. }, scene?: Nullable<Scene>): Mesh;
  45373. }
  45374. }
  45375. declare module "babylonjs/Gizmos/scaleGizmo" {
  45376. import { Observable } from "babylonjs/Misc/observable";
  45377. import { Nullable } from "babylonjs/types";
  45378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45380. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45381. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45382. /**
  45383. * Gizmo that enables scaling a mesh along 3 axis
  45384. */
  45385. export class ScaleGizmo extends Gizmo {
  45386. /**
  45387. * Internal gizmo used for interactions on the x axis
  45388. */
  45389. xGizmo: AxisScaleGizmo;
  45390. /**
  45391. * Internal gizmo used for interactions on the y axis
  45392. */
  45393. yGizmo: AxisScaleGizmo;
  45394. /**
  45395. * Internal gizmo used for interactions on the z axis
  45396. */
  45397. zGizmo: AxisScaleGizmo;
  45398. /**
  45399. * Internal gizmo used to scale all axis equally
  45400. */
  45401. uniformScaleGizmo: AxisScaleGizmo;
  45402. private _meshAttached;
  45403. private _updateGizmoRotationToMatchAttachedMesh;
  45404. private _snapDistance;
  45405. private _scaleRatio;
  45406. private _uniformScalingMesh;
  45407. private _octahedron;
  45408. /** Fires an event when any of it's sub gizmos are dragged */
  45409. onDragStartObservable: Observable<unknown>;
  45410. /** Fires an event when any of it's sub gizmos are released from dragging */
  45411. onDragEndObservable: Observable<unknown>;
  45412. attachedMesh: Nullable<AbstractMesh>;
  45413. /**
  45414. * Creates a ScaleGizmo
  45415. * @param gizmoLayer The utility layer the gizmo will be added to
  45416. */
  45417. constructor(gizmoLayer?: UtilityLayerRenderer);
  45418. updateGizmoRotationToMatchAttachedMesh: boolean;
  45419. /**
  45420. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45421. */
  45422. snapDistance: number;
  45423. /**
  45424. * Ratio for the scale of the gizmo (Default: 1)
  45425. */
  45426. scaleRatio: number;
  45427. /**
  45428. * Disposes of the gizmo
  45429. */
  45430. dispose(): void;
  45431. }
  45432. }
  45433. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45434. import { Observable } from "babylonjs/Misc/observable";
  45435. import { Nullable } from "babylonjs/types";
  45436. import { Vector3 } from "babylonjs/Maths/math.vector";
  45437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45438. import { Mesh } from "babylonjs/Meshes/mesh";
  45439. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45440. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45442. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45443. import { Color3 } from "babylonjs/Maths/math.color";
  45444. /**
  45445. * Single axis scale gizmo
  45446. */
  45447. export class AxisScaleGizmo extends Gizmo {
  45448. /**
  45449. * Drag behavior responsible for the gizmos dragging interactions
  45450. */
  45451. dragBehavior: PointerDragBehavior;
  45452. private _pointerObserver;
  45453. /**
  45454. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45455. */
  45456. snapDistance: number;
  45457. /**
  45458. * Event that fires each time the gizmo snaps to a new location.
  45459. * * snapDistance is the the change in distance
  45460. */
  45461. onSnapObservable: Observable<{
  45462. snapDistance: number;
  45463. }>;
  45464. /**
  45465. * If the scaling operation should be done on all axis (default: false)
  45466. */
  45467. uniformScaling: boolean;
  45468. private _isEnabled;
  45469. private _parent;
  45470. private _arrow;
  45471. private _coloredMaterial;
  45472. private _hoverMaterial;
  45473. /**
  45474. * Creates an AxisScaleGizmo
  45475. * @param gizmoLayer The utility layer the gizmo will be added to
  45476. * @param dragAxis The axis which the gizmo will be able to scale on
  45477. * @param color The color of the gizmo
  45478. */
  45479. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45481. /**
  45482. * If the gizmo is enabled
  45483. */
  45484. isEnabled: boolean;
  45485. /**
  45486. * Disposes of the gizmo
  45487. */
  45488. dispose(): void;
  45489. /**
  45490. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45491. * @param mesh The mesh to replace the default mesh of the gizmo
  45492. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45493. */
  45494. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45495. }
  45496. }
  45497. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45498. import { Observable } from "babylonjs/Misc/observable";
  45499. import { Nullable } from "babylonjs/types";
  45500. import { Vector3 } from "babylonjs/Maths/math.vector";
  45501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45502. import { Mesh } from "babylonjs/Meshes/mesh";
  45503. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45504. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45505. import { Color3 } from "babylonjs/Maths/math.color";
  45506. import "babylonjs/Meshes/Builders/boxBuilder";
  45507. /**
  45508. * Bounding box gizmo
  45509. */
  45510. export class BoundingBoxGizmo extends Gizmo {
  45511. private _lineBoundingBox;
  45512. private _rotateSpheresParent;
  45513. private _scaleBoxesParent;
  45514. private _boundingDimensions;
  45515. private _renderObserver;
  45516. private _pointerObserver;
  45517. private _scaleDragSpeed;
  45518. private _tmpQuaternion;
  45519. private _tmpVector;
  45520. private _tmpRotationMatrix;
  45521. /**
  45522. * 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)
  45523. */
  45524. ignoreChildren: boolean;
  45525. /**
  45526. * 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)
  45527. */
  45528. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45529. /**
  45530. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45531. */
  45532. rotationSphereSize: number;
  45533. /**
  45534. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45535. */
  45536. scaleBoxSize: number;
  45537. /**
  45538. * 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)
  45539. */
  45540. fixedDragMeshScreenSize: boolean;
  45541. /**
  45542. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45543. */
  45544. fixedDragMeshScreenSizeDistanceFactor: number;
  45545. /**
  45546. * Fired when a rotation sphere or scale box is dragged
  45547. */
  45548. onDragStartObservable: Observable<{}>;
  45549. /**
  45550. * Fired when a scale box is dragged
  45551. */
  45552. onScaleBoxDragObservable: Observable<{}>;
  45553. /**
  45554. * Fired when a scale box drag is ended
  45555. */
  45556. onScaleBoxDragEndObservable: Observable<{}>;
  45557. /**
  45558. * Fired when a rotation sphere is dragged
  45559. */
  45560. onRotationSphereDragObservable: Observable<{}>;
  45561. /**
  45562. * Fired when a rotation sphere drag is ended
  45563. */
  45564. onRotationSphereDragEndObservable: Observable<{}>;
  45565. /**
  45566. * 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)
  45567. */
  45568. scalePivot: Nullable<Vector3>;
  45569. /**
  45570. * Mesh used as a pivot to rotate the attached mesh
  45571. */
  45572. private _anchorMesh;
  45573. private _existingMeshScale;
  45574. private _dragMesh;
  45575. private pointerDragBehavior;
  45576. private coloredMaterial;
  45577. private hoverColoredMaterial;
  45578. /**
  45579. * Sets the color of the bounding box gizmo
  45580. * @param color the color to set
  45581. */
  45582. setColor(color: Color3): void;
  45583. /**
  45584. * Creates an BoundingBoxGizmo
  45585. * @param gizmoLayer The utility layer the gizmo will be added to
  45586. * @param color The color of the gizmo
  45587. */
  45588. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45589. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45590. private _selectNode;
  45591. /**
  45592. * Updates the bounding box information for the Gizmo
  45593. */
  45594. updateBoundingBox(): void;
  45595. private _updateRotationSpheres;
  45596. private _updateScaleBoxes;
  45597. /**
  45598. * Enables rotation on the specified axis and disables rotation on the others
  45599. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45600. */
  45601. setEnabledRotationAxis(axis: string): void;
  45602. /**
  45603. * Enables/disables scaling
  45604. * @param enable if scaling should be enabled
  45605. */
  45606. setEnabledScaling(enable: boolean): void;
  45607. private _updateDummy;
  45608. /**
  45609. * Enables a pointer drag behavior on the bounding box of the gizmo
  45610. */
  45611. enableDragBehavior(): void;
  45612. /**
  45613. * Disposes of the gizmo
  45614. */
  45615. dispose(): void;
  45616. /**
  45617. * 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)
  45618. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45619. * @returns the bounding box mesh with the passed in mesh as a child
  45620. */
  45621. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45622. /**
  45623. * CustomMeshes are not supported by this gizmo
  45624. * @param mesh The mesh to replace the default mesh of the gizmo
  45625. */
  45626. setCustomMesh(mesh: Mesh): void;
  45627. }
  45628. }
  45629. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45630. import { Observable } from "babylonjs/Misc/observable";
  45631. import { Nullable } from "babylonjs/types";
  45632. import { Vector3 } from "babylonjs/Maths/math.vector";
  45633. import { Color3 } from "babylonjs/Maths/math.color";
  45634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45635. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45636. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45637. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45638. import "babylonjs/Meshes/Builders/linesBuilder";
  45639. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45640. /**
  45641. * Single plane rotation gizmo
  45642. */
  45643. export class PlaneRotationGizmo extends Gizmo {
  45644. /**
  45645. * Drag behavior responsible for the gizmos dragging interactions
  45646. */
  45647. dragBehavior: PointerDragBehavior;
  45648. private _pointerObserver;
  45649. /**
  45650. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45651. */
  45652. snapDistance: number;
  45653. /**
  45654. * Event that fires each time the gizmo snaps to a new location.
  45655. * * snapDistance is the the change in distance
  45656. */
  45657. onSnapObservable: Observable<{
  45658. snapDistance: number;
  45659. }>;
  45660. private _isEnabled;
  45661. private _parent;
  45662. /**
  45663. * Creates a PlaneRotationGizmo
  45664. * @param gizmoLayer The utility layer the gizmo will be added to
  45665. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45666. * @param color The color of the gizmo
  45667. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45668. */
  45669. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45670. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45671. /**
  45672. * If the gizmo is enabled
  45673. */
  45674. isEnabled: boolean;
  45675. /**
  45676. * Disposes of the gizmo
  45677. */
  45678. dispose(): void;
  45679. }
  45680. }
  45681. declare module "babylonjs/Gizmos/rotationGizmo" {
  45682. import { Observable } from "babylonjs/Misc/observable";
  45683. import { Nullable } from "babylonjs/types";
  45684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45685. import { Mesh } from "babylonjs/Meshes/mesh";
  45686. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45687. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45689. /**
  45690. * Gizmo that enables rotating a mesh along 3 axis
  45691. */
  45692. export class RotationGizmo extends Gizmo {
  45693. /**
  45694. * Internal gizmo used for interactions on the x axis
  45695. */
  45696. xGizmo: PlaneRotationGizmo;
  45697. /**
  45698. * Internal gizmo used for interactions on the y axis
  45699. */
  45700. yGizmo: PlaneRotationGizmo;
  45701. /**
  45702. * Internal gizmo used for interactions on the z axis
  45703. */
  45704. zGizmo: PlaneRotationGizmo;
  45705. /** Fires an event when any of it's sub gizmos are dragged */
  45706. onDragStartObservable: Observable<unknown>;
  45707. /** Fires an event when any of it's sub gizmos are released from dragging */
  45708. onDragEndObservable: Observable<unknown>;
  45709. private _meshAttached;
  45710. attachedMesh: Nullable<AbstractMesh>;
  45711. /**
  45712. * Creates a RotationGizmo
  45713. * @param gizmoLayer The utility layer the gizmo will be added to
  45714. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45715. */
  45716. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45717. updateGizmoRotationToMatchAttachedMesh: boolean;
  45718. /**
  45719. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45720. */
  45721. snapDistance: number;
  45722. /**
  45723. * Ratio for the scale of the gizmo (Default: 1)
  45724. */
  45725. scaleRatio: number;
  45726. /**
  45727. * Disposes of the gizmo
  45728. */
  45729. dispose(): void;
  45730. /**
  45731. * CustomMeshes are not supported by this gizmo
  45732. * @param mesh The mesh to replace the default mesh of the gizmo
  45733. */
  45734. setCustomMesh(mesh: Mesh): void;
  45735. }
  45736. }
  45737. declare module "babylonjs/Gizmos/gizmoManager" {
  45738. import { Observable } from "babylonjs/Misc/observable";
  45739. import { Nullable } from "babylonjs/types";
  45740. import { Scene, IDisposable } from "babylonjs/scene";
  45741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45742. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45743. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45744. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45745. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45746. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45747. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45748. /**
  45749. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45750. */
  45751. export class GizmoManager implements IDisposable {
  45752. private scene;
  45753. /**
  45754. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45755. */
  45756. gizmos: {
  45757. positionGizmo: Nullable<PositionGizmo>;
  45758. rotationGizmo: Nullable<RotationGizmo>;
  45759. scaleGizmo: Nullable<ScaleGizmo>;
  45760. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45761. };
  45762. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45763. clearGizmoOnEmptyPointerEvent: boolean;
  45764. /** Fires an event when the manager is attached to a mesh */
  45765. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45766. private _gizmosEnabled;
  45767. private _pointerObserver;
  45768. private _attachedMesh;
  45769. private _boundingBoxColor;
  45770. private _defaultUtilityLayer;
  45771. private _defaultKeepDepthUtilityLayer;
  45772. /**
  45773. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45774. */
  45775. boundingBoxDragBehavior: SixDofDragBehavior;
  45776. /**
  45777. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45778. */
  45779. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45780. /**
  45781. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45782. */
  45783. usePointerToAttachGizmos: boolean;
  45784. /**
  45785. * Utility layer that the bounding box gizmo belongs to
  45786. */
  45787. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45788. /**
  45789. * Utility layer that all gizmos besides bounding box belong to
  45790. */
  45791. readonly utilityLayer: UtilityLayerRenderer;
  45792. /**
  45793. * Instatiates a gizmo manager
  45794. * @param scene the scene to overlay the gizmos on top of
  45795. */
  45796. constructor(scene: Scene);
  45797. /**
  45798. * Attaches a set of gizmos to the specified mesh
  45799. * @param mesh The mesh the gizmo's should be attached to
  45800. */
  45801. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45802. /**
  45803. * If the position gizmo is enabled
  45804. */
  45805. positionGizmoEnabled: boolean;
  45806. /**
  45807. * If the rotation gizmo is enabled
  45808. */
  45809. rotationGizmoEnabled: boolean;
  45810. /**
  45811. * If the scale gizmo is enabled
  45812. */
  45813. scaleGizmoEnabled: boolean;
  45814. /**
  45815. * If the boundingBox gizmo is enabled
  45816. */
  45817. boundingBoxGizmoEnabled: boolean;
  45818. /**
  45819. * Disposes of the gizmo manager
  45820. */
  45821. dispose(): void;
  45822. }
  45823. }
  45824. declare module "babylonjs/Lights/directionalLight" {
  45825. import { Camera } from "babylonjs/Cameras/camera";
  45826. import { Scene } from "babylonjs/scene";
  45827. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45829. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45830. import { Effect } from "babylonjs/Materials/effect";
  45831. /**
  45832. * A directional light is defined by a direction (what a surprise!).
  45833. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45834. * 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.
  45835. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45836. */
  45837. export class DirectionalLight extends ShadowLight {
  45838. private _shadowFrustumSize;
  45839. /**
  45840. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45841. */
  45842. /**
  45843. * Specifies a fix frustum size for the shadow generation.
  45844. */
  45845. shadowFrustumSize: number;
  45846. private _shadowOrthoScale;
  45847. /**
  45848. * Gets the shadow projection scale against the optimal computed one.
  45849. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45850. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45851. */
  45852. /**
  45853. * Sets the shadow projection scale against the optimal computed one.
  45854. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45855. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45856. */
  45857. shadowOrthoScale: number;
  45858. /**
  45859. * Automatically compute the projection matrix to best fit (including all the casters)
  45860. * on each frame.
  45861. */
  45862. autoUpdateExtends: boolean;
  45863. private _orthoLeft;
  45864. private _orthoRight;
  45865. private _orthoTop;
  45866. private _orthoBottom;
  45867. /**
  45868. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45869. * The directional light is emitted from everywhere in the given direction.
  45870. * It can cast shadows.
  45871. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45872. * @param name The friendly name of the light
  45873. * @param direction The direction of the light
  45874. * @param scene The scene the light belongs to
  45875. */
  45876. constructor(name: string, direction: Vector3, scene: Scene);
  45877. /**
  45878. * Returns the string "DirectionalLight".
  45879. * @return The class name
  45880. */
  45881. getClassName(): string;
  45882. /**
  45883. * Returns the integer 1.
  45884. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45885. */
  45886. getTypeID(): number;
  45887. /**
  45888. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45889. * Returns the DirectionalLight Shadow projection matrix.
  45890. */
  45891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45892. /**
  45893. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45894. * Returns the DirectionalLight Shadow projection matrix.
  45895. */
  45896. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45897. /**
  45898. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45899. * Returns the DirectionalLight Shadow projection matrix.
  45900. */
  45901. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45902. protected _buildUniformLayout(): void;
  45903. /**
  45904. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45905. * @param effect The effect to update
  45906. * @param lightIndex The index of the light in the effect to update
  45907. * @returns The directional light
  45908. */
  45909. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45910. /**
  45911. * Gets the minZ used for shadow according to both the scene and the light.
  45912. *
  45913. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45914. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45915. * @param activeCamera The camera we are returning the min for
  45916. * @returns the depth min z
  45917. */
  45918. getDepthMinZ(activeCamera: Camera): number;
  45919. /**
  45920. * Gets the maxZ used for shadow according to both the scene and the light.
  45921. *
  45922. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45923. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45924. * @param activeCamera The camera we are returning the max for
  45925. * @returns the depth max z
  45926. */
  45927. getDepthMaxZ(activeCamera: Camera): number;
  45928. /**
  45929. * Prepares the list of defines specific to the light type.
  45930. * @param defines the list of defines
  45931. * @param lightIndex defines the index of the light for the effect
  45932. */
  45933. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45934. }
  45935. }
  45936. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45937. import { Mesh } from "babylonjs/Meshes/mesh";
  45938. /**
  45939. * Class containing static functions to help procedurally build meshes
  45940. */
  45941. export class HemisphereBuilder {
  45942. /**
  45943. * Creates a hemisphere mesh
  45944. * @param name defines the name of the mesh
  45945. * @param options defines the options used to create the mesh
  45946. * @param scene defines the hosting scene
  45947. * @returns the hemisphere mesh
  45948. */
  45949. static CreateHemisphere(name: string, options: {
  45950. segments?: number;
  45951. diameter?: number;
  45952. sideOrientation?: number;
  45953. }, scene: any): Mesh;
  45954. }
  45955. }
  45956. declare module "babylonjs/Lights/spotLight" {
  45957. import { Nullable } from "babylonjs/types";
  45958. import { Scene } from "babylonjs/scene";
  45959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45961. import { Effect } from "babylonjs/Materials/effect";
  45962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45963. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45964. /**
  45965. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45966. * These values define a cone of light starting from the position, emitting toward the direction.
  45967. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45968. * and the exponent defines the speed of the decay of the light with distance (reach).
  45969. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45970. */
  45971. export class SpotLight extends ShadowLight {
  45972. private _angle;
  45973. private _innerAngle;
  45974. private _cosHalfAngle;
  45975. private _lightAngleScale;
  45976. private _lightAngleOffset;
  45977. /**
  45978. * Gets the cone angle of the spot light in Radians.
  45979. */
  45980. /**
  45981. * Sets the cone angle of the spot light in Radians.
  45982. */
  45983. angle: number;
  45984. /**
  45985. * Only used in gltf falloff mode, this defines the angle where
  45986. * the directional falloff will start before cutting at angle which could be seen
  45987. * as outer angle.
  45988. */
  45989. /**
  45990. * Only used in gltf falloff mode, this defines the angle where
  45991. * the directional falloff will start before cutting at angle which could be seen
  45992. * as outer angle.
  45993. */
  45994. innerAngle: number;
  45995. private _shadowAngleScale;
  45996. /**
  45997. * Allows scaling the angle of the light for shadow generation only.
  45998. */
  45999. /**
  46000. * Allows scaling the angle of the light for shadow generation only.
  46001. */
  46002. shadowAngleScale: number;
  46003. /**
  46004. * The light decay speed with the distance from the emission spot.
  46005. */
  46006. exponent: number;
  46007. private _projectionTextureMatrix;
  46008. /**
  46009. * Allows reading the projecton texture
  46010. */
  46011. readonly projectionTextureMatrix: Matrix;
  46012. protected _projectionTextureLightNear: number;
  46013. /**
  46014. * Gets the near clip of the Spotlight for texture projection.
  46015. */
  46016. /**
  46017. * Sets the near clip of the Spotlight for texture projection.
  46018. */
  46019. projectionTextureLightNear: number;
  46020. protected _projectionTextureLightFar: number;
  46021. /**
  46022. * Gets the far clip of the Spotlight for texture projection.
  46023. */
  46024. /**
  46025. * Sets the far clip of the Spotlight for texture projection.
  46026. */
  46027. projectionTextureLightFar: number;
  46028. protected _projectionTextureUpDirection: Vector3;
  46029. /**
  46030. * Gets the Up vector of the Spotlight for texture projection.
  46031. */
  46032. /**
  46033. * Sets the Up vector of the Spotlight for texture projection.
  46034. */
  46035. projectionTextureUpDirection: Vector3;
  46036. private _projectionTexture;
  46037. /**
  46038. * Gets the projection texture of the light.
  46039. */
  46040. /**
  46041. * Sets the projection texture of the light.
  46042. */
  46043. projectionTexture: Nullable<BaseTexture>;
  46044. private _projectionTextureViewLightDirty;
  46045. private _projectionTextureProjectionLightDirty;
  46046. private _projectionTextureDirty;
  46047. private _projectionTextureViewTargetVector;
  46048. private _projectionTextureViewLightMatrix;
  46049. private _projectionTextureProjectionLightMatrix;
  46050. private _projectionTextureScalingMatrix;
  46051. /**
  46052. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46053. * It can cast shadows.
  46054. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46055. * @param name The light friendly name
  46056. * @param position The position of the spot light in the scene
  46057. * @param direction The direction of the light in the scene
  46058. * @param angle The cone angle of the light in Radians
  46059. * @param exponent The light decay speed with the distance from the emission spot
  46060. * @param scene The scene the lights belongs to
  46061. */
  46062. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46063. /**
  46064. * Returns the string "SpotLight".
  46065. * @returns the class name
  46066. */
  46067. getClassName(): string;
  46068. /**
  46069. * Returns the integer 2.
  46070. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46071. */
  46072. getTypeID(): number;
  46073. /**
  46074. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46075. */
  46076. protected _setDirection(value: Vector3): void;
  46077. /**
  46078. * Overrides the position setter to recompute the projection texture view light Matrix.
  46079. */
  46080. protected _setPosition(value: Vector3): void;
  46081. /**
  46082. * 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.
  46083. * Returns the SpotLight.
  46084. */
  46085. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46086. protected _computeProjectionTextureViewLightMatrix(): void;
  46087. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46088. /**
  46089. * Main function for light texture projection matrix computing.
  46090. */
  46091. protected _computeProjectionTextureMatrix(): void;
  46092. protected _buildUniformLayout(): void;
  46093. private _computeAngleValues;
  46094. /**
  46095. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46096. * @param effect The effect to update
  46097. * @param lightIndex The index of the light in the effect to update
  46098. * @returns The spot light
  46099. */
  46100. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46101. /**
  46102. * Disposes the light and the associated resources.
  46103. */
  46104. dispose(): void;
  46105. /**
  46106. * Prepares the list of defines specific to the light type.
  46107. * @param defines the list of defines
  46108. * @param lightIndex defines the index of the light for the effect
  46109. */
  46110. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46111. }
  46112. }
  46113. declare module "babylonjs/Gizmos/lightGizmo" {
  46114. import { Nullable } from "babylonjs/types";
  46115. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46116. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46117. import { Light } from "babylonjs/Lights/light";
  46118. /**
  46119. * Gizmo that enables viewing a light
  46120. */
  46121. export class LightGizmo extends Gizmo {
  46122. private _lightMesh;
  46123. private _material;
  46124. private cachedPosition;
  46125. private cachedForward;
  46126. /**
  46127. * Creates a LightGizmo
  46128. * @param gizmoLayer The utility layer the gizmo will be added to
  46129. */
  46130. constructor(gizmoLayer?: UtilityLayerRenderer);
  46131. private _light;
  46132. /**
  46133. * The light that the gizmo is attached to
  46134. */
  46135. light: Nullable<Light>;
  46136. /**
  46137. * @hidden
  46138. * Updates the gizmo to match the attached mesh's position/rotation
  46139. */
  46140. protected _update(): void;
  46141. private static _Scale;
  46142. /**
  46143. * Creates the lines for a light mesh
  46144. */
  46145. private static _createLightLines;
  46146. /**
  46147. * Disposes of the light gizmo
  46148. */
  46149. dispose(): void;
  46150. private static _CreateHemisphericLightMesh;
  46151. private static _CreatePointLightMesh;
  46152. private static _CreateSpotLightMesh;
  46153. private static _CreateDirectionalLightMesh;
  46154. }
  46155. }
  46156. declare module "babylonjs/Gizmos/index" {
  46157. export * from "babylonjs/Gizmos/axisDragGizmo";
  46158. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46159. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46160. export * from "babylonjs/Gizmos/gizmo";
  46161. export * from "babylonjs/Gizmos/gizmoManager";
  46162. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46163. export * from "babylonjs/Gizmos/positionGizmo";
  46164. export * from "babylonjs/Gizmos/rotationGizmo";
  46165. export * from "babylonjs/Gizmos/scaleGizmo";
  46166. export * from "babylonjs/Gizmos/lightGizmo";
  46167. export * from "babylonjs/Gizmos/planeDragGizmo";
  46168. }
  46169. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46170. /** @hidden */
  46171. export var backgroundFragmentDeclaration: {
  46172. name: string;
  46173. shader: string;
  46174. };
  46175. }
  46176. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46177. /** @hidden */
  46178. export var backgroundUboDeclaration: {
  46179. name: string;
  46180. shader: string;
  46181. };
  46182. }
  46183. declare module "babylonjs/Shaders/background.fragment" {
  46184. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46185. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46187. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46188. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46189. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46191. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46192. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46193. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46194. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46195. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46196. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46197. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46198. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46199. /** @hidden */
  46200. export var backgroundPixelShader: {
  46201. name: string;
  46202. shader: string;
  46203. };
  46204. }
  46205. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46206. /** @hidden */
  46207. export var backgroundVertexDeclaration: {
  46208. name: string;
  46209. shader: string;
  46210. };
  46211. }
  46212. declare module "babylonjs/Shaders/background.vertex" {
  46213. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46214. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46215. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46216. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46217. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46218. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46219. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46220. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46221. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46222. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46223. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46224. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46225. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46226. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46227. /** @hidden */
  46228. export var backgroundVertexShader: {
  46229. name: string;
  46230. shader: string;
  46231. };
  46232. }
  46233. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46234. import { Nullable, int, float } from "babylonjs/types";
  46235. import { Scene } from "babylonjs/scene";
  46236. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46239. import { Mesh } from "babylonjs/Meshes/mesh";
  46240. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46241. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46242. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46244. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46245. import { Color3 } from "babylonjs/Maths/math.color";
  46246. import "babylonjs/Shaders/background.fragment";
  46247. import "babylonjs/Shaders/background.vertex";
  46248. /**
  46249. * Background material used to create an efficient environement around your scene.
  46250. */
  46251. export class BackgroundMaterial extends PushMaterial {
  46252. /**
  46253. * Standard reflectance value at parallel view angle.
  46254. */
  46255. static StandardReflectance0: number;
  46256. /**
  46257. * Standard reflectance value at grazing angle.
  46258. */
  46259. static StandardReflectance90: number;
  46260. protected _primaryColor: Color3;
  46261. /**
  46262. * Key light Color (multiply against the environement texture)
  46263. */
  46264. primaryColor: Color3;
  46265. protected __perceptualColor: Nullable<Color3>;
  46266. /**
  46267. * Experimental Internal Use Only.
  46268. *
  46269. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46270. * This acts as a helper to set the primary color to a more "human friendly" value.
  46271. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46272. * output color as close as possible from the chosen value.
  46273. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46274. * part of lighting setup.)
  46275. */
  46276. _perceptualColor: Nullable<Color3>;
  46277. protected _primaryColorShadowLevel: float;
  46278. /**
  46279. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46280. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46281. */
  46282. primaryColorShadowLevel: float;
  46283. protected _primaryColorHighlightLevel: float;
  46284. /**
  46285. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46286. * The primary color is used at the level chosen to define what the white area would look.
  46287. */
  46288. primaryColorHighlightLevel: float;
  46289. protected _reflectionTexture: Nullable<BaseTexture>;
  46290. /**
  46291. * Reflection Texture used in the material.
  46292. * Should be author in a specific way for the best result (refer to the documentation).
  46293. */
  46294. reflectionTexture: Nullable<BaseTexture>;
  46295. protected _reflectionBlur: float;
  46296. /**
  46297. * Reflection Texture level of blur.
  46298. *
  46299. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46300. * texture twice.
  46301. */
  46302. reflectionBlur: float;
  46303. protected _diffuseTexture: Nullable<BaseTexture>;
  46304. /**
  46305. * Diffuse Texture used in the material.
  46306. * Should be author in a specific way for the best result (refer to the documentation).
  46307. */
  46308. diffuseTexture: Nullable<BaseTexture>;
  46309. protected _shadowLights: Nullable<IShadowLight[]>;
  46310. /**
  46311. * Specify the list of lights casting shadow on the material.
  46312. * All scene shadow lights will be included if null.
  46313. */
  46314. shadowLights: Nullable<IShadowLight[]>;
  46315. protected _shadowLevel: float;
  46316. /**
  46317. * Helps adjusting the shadow to a softer level if required.
  46318. * 0 means black shadows and 1 means no shadows.
  46319. */
  46320. shadowLevel: float;
  46321. protected _sceneCenter: Vector3;
  46322. /**
  46323. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46324. * It is usually zero but might be interesting to modify according to your setup.
  46325. */
  46326. sceneCenter: Vector3;
  46327. protected _opacityFresnel: boolean;
  46328. /**
  46329. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46330. * This helps ensuring a nice transition when the camera goes under the ground.
  46331. */
  46332. opacityFresnel: boolean;
  46333. protected _reflectionFresnel: boolean;
  46334. /**
  46335. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46336. * This helps adding a mirror texture on the ground.
  46337. */
  46338. reflectionFresnel: boolean;
  46339. protected _reflectionFalloffDistance: number;
  46340. /**
  46341. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46342. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46343. */
  46344. reflectionFalloffDistance: number;
  46345. protected _reflectionAmount: number;
  46346. /**
  46347. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46348. */
  46349. reflectionAmount: number;
  46350. protected _reflectionReflectance0: number;
  46351. /**
  46352. * This specifies the weight of the reflection at grazing angle.
  46353. */
  46354. reflectionReflectance0: number;
  46355. protected _reflectionReflectance90: number;
  46356. /**
  46357. * This specifies the weight of the reflection at a perpendicular point of view.
  46358. */
  46359. reflectionReflectance90: number;
  46360. /**
  46361. * Sets the reflection reflectance fresnel values according to the default standard
  46362. * empirically know to work well :-)
  46363. */
  46364. reflectionStandardFresnelWeight: number;
  46365. protected _useRGBColor: boolean;
  46366. /**
  46367. * Helps to directly use the maps channels instead of their level.
  46368. */
  46369. useRGBColor: boolean;
  46370. protected _enableNoise: boolean;
  46371. /**
  46372. * This helps reducing the banding effect that could occur on the background.
  46373. */
  46374. enableNoise: boolean;
  46375. /**
  46376. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46377. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46378. * Recommended to be keep at 1.0 except for special cases.
  46379. */
  46380. fovMultiplier: number;
  46381. private _fovMultiplier;
  46382. /**
  46383. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46384. */
  46385. useEquirectangularFOV: boolean;
  46386. private _maxSimultaneousLights;
  46387. /**
  46388. * Number of Simultaneous lights allowed on the material.
  46389. */
  46390. maxSimultaneousLights: int;
  46391. /**
  46392. * Default configuration related to image processing available in the Background Material.
  46393. */
  46394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46395. /**
  46396. * Keep track of the image processing observer to allow dispose and replace.
  46397. */
  46398. private _imageProcessingObserver;
  46399. /**
  46400. * Attaches a new image processing configuration to the PBR Material.
  46401. * @param configuration (if null the scene configuration will be use)
  46402. */
  46403. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46404. /**
  46405. * Gets the image processing configuration used either in this material.
  46406. */
  46407. /**
  46408. * Sets the Default image processing configuration used either in the this material.
  46409. *
  46410. * If sets to null, the scene one is in use.
  46411. */
  46412. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46413. /**
  46414. * Gets wether the color curves effect is enabled.
  46415. */
  46416. /**
  46417. * Sets wether the color curves effect is enabled.
  46418. */
  46419. cameraColorCurvesEnabled: boolean;
  46420. /**
  46421. * Gets wether the color grading effect is enabled.
  46422. */
  46423. /**
  46424. * Gets wether the color grading effect is enabled.
  46425. */
  46426. cameraColorGradingEnabled: boolean;
  46427. /**
  46428. * Gets wether tonemapping is enabled or not.
  46429. */
  46430. /**
  46431. * Sets wether tonemapping is enabled or not
  46432. */
  46433. cameraToneMappingEnabled: boolean;
  46434. /**
  46435. * The camera exposure used on this material.
  46436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46437. * This corresponds to a photographic exposure.
  46438. */
  46439. /**
  46440. * The camera exposure used on this material.
  46441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46442. * This corresponds to a photographic exposure.
  46443. */
  46444. cameraExposure: float;
  46445. /**
  46446. * Gets The camera contrast used on this material.
  46447. */
  46448. /**
  46449. * Sets The camera contrast used on this material.
  46450. */
  46451. cameraContrast: float;
  46452. /**
  46453. * Gets the Color Grading 2D Lookup Texture.
  46454. */
  46455. /**
  46456. * Sets the Color Grading 2D Lookup Texture.
  46457. */
  46458. cameraColorGradingTexture: Nullable<BaseTexture>;
  46459. /**
  46460. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46461. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46462. * 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;
  46463. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46464. */
  46465. /**
  46466. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46467. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46468. * 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;
  46469. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46470. */
  46471. cameraColorCurves: Nullable<ColorCurves>;
  46472. /**
  46473. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46474. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46475. */
  46476. switchToBGR: boolean;
  46477. private _renderTargets;
  46478. private _reflectionControls;
  46479. private _white;
  46480. private _primaryShadowColor;
  46481. private _primaryHighlightColor;
  46482. /**
  46483. * Instantiates a Background Material in the given scene
  46484. * @param name The friendly name of the material
  46485. * @param scene The scene to add the material to
  46486. */
  46487. constructor(name: string, scene: Scene);
  46488. /**
  46489. * Gets a boolean indicating that current material needs to register RTT
  46490. */
  46491. readonly hasRenderTargetTextures: boolean;
  46492. /**
  46493. * The entire material has been created in order to prevent overdraw.
  46494. * @returns false
  46495. */
  46496. needAlphaTesting(): boolean;
  46497. /**
  46498. * The entire material has been created in order to prevent overdraw.
  46499. * @returns true if blending is enable
  46500. */
  46501. needAlphaBlending(): boolean;
  46502. /**
  46503. * Checks wether the material is ready to be rendered for a given mesh.
  46504. * @param mesh The mesh to render
  46505. * @param subMesh The submesh to check against
  46506. * @param useInstances Specify wether or not the material is used with instances
  46507. * @returns true if all the dependencies are ready (Textures, Effects...)
  46508. */
  46509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46510. /**
  46511. * Compute the primary color according to the chosen perceptual color.
  46512. */
  46513. private _computePrimaryColorFromPerceptualColor;
  46514. /**
  46515. * Compute the highlights and shadow colors according to their chosen levels.
  46516. */
  46517. private _computePrimaryColors;
  46518. /**
  46519. * Build the uniform buffer used in the material.
  46520. */
  46521. buildUniformLayout(): void;
  46522. /**
  46523. * Unbind the material.
  46524. */
  46525. unbind(): void;
  46526. /**
  46527. * Bind only the world matrix to the material.
  46528. * @param world The world matrix to bind.
  46529. */
  46530. bindOnlyWorldMatrix(world: Matrix): void;
  46531. /**
  46532. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46533. * @param world The world matrix to bind.
  46534. * @param subMesh The submesh to bind for.
  46535. */
  46536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46537. /**
  46538. * Dispose the material.
  46539. * @param forceDisposeEffect Force disposal of the associated effect.
  46540. * @param forceDisposeTextures Force disposal of the associated textures.
  46541. */
  46542. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46543. /**
  46544. * Clones the material.
  46545. * @param name The cloned name.
  46546. * @returns The cloned material.
  46547. */
  46548. clone(name: string): BackgroundMaterial;
  46549. /**
  46550. * Serializes the current material to its JSON representation.
  46551. * @returns The JSON representation.
  46552. */
  46553. serialize(): any;
  46554. /**
  46555. * Gets the class name of the material
  46556. * @returns "BackgroundMaterial"
  46557. */
  46558. getClassName(): string;
  46559. /**
  46560. * Parse a JSON input to create back a background material.
  46561. * @param source The JSON data to parse
  46562. * @param scene The scene to create the parsed material in
  46563. * @param rootUrl The root url of the assets the material depends upon
  46564. * @returns the instantiated BackgroundMaterial.
  46565. */
  46566. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46567. }
  46568. }
  46569. declare module "babylonjs/Helpers/environmentHelper" {
  46570. import { Observable } from "babylonjs/Misc/observable";
  46571. import { Nullable } from "babylonjs/types";
  46572. import { Scene } from "babylonjs/scene";
  46573. import { Vector3 } from "babylonjs/Maths/math.vector";
  46574. import { Color3 } from "babylonjs/Maths/math.color";
  46575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46576. import { Mesh } from "babylonjs/Meshes/mesh";
  46577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46578. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46579. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46580. import "babylonjs/Meshes/Builders/planeBuilder";
  46581. import "babylonjs/Meshes/Builders/boxBuilder";
  46582. /**
  46583. * Represents the different options available during the creation of
  46584. * a Environment helper.
  46585. *
  46586. * This can control the default ground, skybox and image processing setup of your scene.
  46587. */
  46588. export interface IEnvironmentHelperOptions {
  46589. /**
  46590. * Specifies wether or not to create a ground.
  46591. * True by default.
  46592. */
  46593. createGround: boolean;
  46594. /**
  46595. * Specifies the ground size.
  46596. * 15 by default.
  46597. */
  46598. groundSize: number;
  46599. /**
  46600. * The texture used on the ground for the main color.
  46601. * Comes from the BabylonJS CDN by default.
  46602. *
  46603. * Remarks: Can be either a texture or a url.
  46604. */
  46605. groundTexture: string | BaseTexture;
  46606. /**
  46607. * The color mixed in the ground texture by default.
  46608. * BabylonJS clearColor by default.
  46609. */
  46610. groundColor: Color3;
  46611. /**
  46612. * Specifies the ground opacity.
  46613. * 1 by default.
  46614. */
  46615. groundOpacity: number;
  46616. /**
  46617. * Enables the ground to receive shadows.
  46618. * True by default.
  46619. */
  46620. enableGroundShadow: boolean;
  46621. /**
  46622. * Helps preventing the shadow to be fully black on the ground.
  46623. * 0.5 by default.
  46624. */
  46625. groundShadowLevel: number;
  46626. /**
  46627. * Creates a mirror texture attach to the ground.
  46628. * false by default.
  46629. */
  46630. enableGroundMirror: boolean;
  46631. /**
  46632. * Specifies the ground mirror size ratio.
  46633. * 0.3 by default as the default kernel is 64.
  46634. */
  46635. groundMirrorSizeRatio: number;
  46636. /**
  46637. * Specifies the ground mirror blur kernel size.
  46638. * 64 by default.
  46639. */
  46640. groundMirrorBlurKernel: number;
  46641. /**
  46642. * Specifies the ground mirror visibility amount.
  46643. * 1 by default
  46644. */
  46645. groundMirrorAmount: number;
  46646. /**
  46647. * Specifies the ground mirror reflectance weight.
  46648. * This uses the standard weight of the background material to setup the fresnel effect
  46649. * of the mirror.
  46650. * 1 by default.
  46651. */
  46652. groundMirrorFresnelWeight: number;
  46653. /**
  46654. * Specifies the ground mirror Falloff distance.
  46655. * This can helps reducing the size of the reflection.
  46656. * 0 by Default.
  46657. */
  46658. groundMirrorFallOffDistance: number;
  46659. /**
  46660. * Specifies the ground mirror texture type.
  46661. * Unsigned Int by Default.
  46662. */
  46663. groundMirrorTextureType: number;
  46664. /**
  46665. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46666. * the shown objects.
  46667. */
  46668. groundYBias: number;
  46669. /**
  46670. * Specifies wether or not to create a skybox.
  46671. * True by default.
  46672. */
  46673. createSkybox: boolean;
  46674. /**
  46675. * Specifies the skybox size.
  46676. * 20 by default.
  46677. */
  46678. skyboxSize: number;
  46679. /**
  46680. * The texture used on the skybox for the main color.
  46681. * Comes from the BabylonJS CDN by default.
  46682. *
  46683. * Remarks: Can be either a texture or a url.
  46684. */
  46685. skyboxTexture: string | BaseTexture;
  46686. /**
  46687. * The color mixed in the skybox texture by default.
  46688. * BabylonJS clearColor by default.
  46689. */
  46690. skyboxColor: Color3;
  46691. /**
  46692. * The background rotation around the Y axis of the scene.
  46693. * This helps aligning the key lights of your scene with the background.
  46694. * 0 by default.
  46695. */
  46696. backgroundYRotation: number;
  46697. /**
  46698. * Compute automatically the size of the elements to best fit with the scene.
  46699. */
  46700. sizeAuto: boolean;
  46701. /**
  46702. * Default position of the rootMesh if autoSize is not true.
  46703. */
  46704. rootPosition: Vector3;
  46705. /**
  46706. * Sets up the image processing in the scene.
  46707. * true by default.
  46708. */
  46709. setupImageProcessing: boolean;
  46710. /**
  46711. * The texture used as your environment texture in the scene.
  46712. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46713. *
  46714. * Remarks: Can be either a texture or a url.
  46715. */
  46716. environmentTexture: string | BaseTexture;
  46717. /**
  46718. * The value of the exposure to apply to the scene.
  46719. * 0.6 by default if setupImageProcessing is true.
  46720. */
  46721. cameraExposure: number;
  46722. /**
  46723. * The value of the contrast to apply to the scene.
  46724. * 1.6 by default if setupImageProcessing is true.
  46725. */
  46726. cameraContrast: number;
  46727. /**
  46728. * Specifies wether or not tonemapping should be enabled in the scene.
  46729. * true by default if setupImageProcessing is true.
  46730. */
  46731. toneMappingEnabled: boolean;
  46732. }
  46733. /**
  46734. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46735. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46736. * It also helps with the default setup of your imageProcessing configuration.
  46737. */
  46738. export class EnvironmentHelper {
  46739. /**
  46740. * Default ground texture URL.
  46741. */
  46742. private static _groundTextureCDNUrl;
  46743. /**
  46744. * Default skybox texture URL.
  46745. */
  46746. private static _skyboxTextureCDNUrl;
  46747. /**
  46748. * Default environment texture URL.
  46749. */
  46750. private static _environmentTextureCDNUrl;
  46751. /**
  46752. * Creates the default options for the helper.
  46753. */
  46754. private static _getDefaultOptions;
  46755. private _rootMesh;
  46756. /**
  46757. * Gets the root mesh created by the helper.
  46758. */
  46759. readonly rootMesh: Mesh;
  46760. private _skybox;
  46761. /**
  46762. * Gets the skybox created by the helper.
  46763. */
  46764. readonly skybox: Nullable<Mesh>;
  46765. private _skyboxTexture;
  46766. /**
  46767. * Gets the skybox texture created by the helper.
  46768. */
  46769. readonly skyboxTexture: Nullable<BaseTexture>;
  46770. private _skyboxMaterial;
  46771. /**
  46772. * Gets the skybox material created by the helper.
  46773. */
  46774. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46775. private _ground;
  46776. /**
  46777. * Gets the ground mesh created by the helper.
  46778. */
  46779. readonly ground: Nullable<Mesh>;
  46780. private _groundTexture;
  46781. /**
  46782. * Gets the ground texture created by the helper.
  46783. */
  46784. readonly groundTexture: Nullable<BaseTexture>;
  46785. private _groundMirror;
  46786. /**
  46787. * Gets the ground mirror created by the helper.
  46788. */
  46789. readonly groundMirror: Nullable<MirrorTexture>;
  46790. /**
  46791. * Gets the ground mirror render list to helps pushing the meshes
  46792. * you wish in the ground reflection.
  46793. */
  46794. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46795. private _groundMaterial;
  46796. /**
  46797. * Gets the ground material created by the helper.
  46798. */
  46799. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46800. /**
  46801. * Stores the creation options.
  46802. */
  46803. private readonly _scene;
  46804. private _options;
  46805. /**
  46806. * This observable will be notified with any error during the creation of the environment,
  46807. * mainly texture creation errors.
  46808. */
  46809. onErrorObservable: Observable<{
  46810. message?: string;
  46811. exception?: any;
  46812. }>;
  46813. /**
  46814. * constructor
  46815. * @param options Defines the options we want to customize the helper
  46816. * @param scene The scene to add the material to
  46817. */
  46818. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46819. /**
  46820. * Updates the background according to the new options
  46821. * @param options
  46822. */
  46823. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46824. /**
  46825. * Sets the primary color of all the available elements.
  46826. * @param color the main color to affect to the ground and the background
  46827. */
  46828. setMainColor(color: Color3): void;
  46829. /**
  46830. * Setup the image processing according to the specified options.
  46831. */
  46832. private _setupImageProcessing;
  46833. /**
  46834. * Setup the environment texture according to the specified options.
  46835. */
  46836. private _setupEnvironmentTexture;
  46837. /**
  46838. * Setup the background according to the specified options.
  46839. */
  46840. private _setupBackground;
  46841. /**
  46842. * Get the scene sizes according to the setup.
  46843. */
  46844. private _getSceneSize;
  46845. /**
  46846. * Setup the ground according to the specified options.
  46847. */
  46848. private _setupGround;
  46849. /**
  46850. * Setup the ground material according to the specified options.
  46851. */
  46852. private _setupGroundMaterial;
  46853. /**
  46854. * Setup the ground diffuse texture according to the specified options.
  46855. */
  46856. private _setupGroundDiffuseTexture;
  46857. /**
  46858. * Setup the ground mirror texture according to the specified options.
  46859. */
  46860. private _setupGroundMirrorTexture;
  46861. /**
  46862. * Setup the ground to receive the mirror texture.
  46863. */
  46864. private _setupMirrorInGroundMaterial;
  46865. /**
  46866. * Setup the skybox according to the specified options.
  46867. */
  46868. private _setupSkybox;
  46869. /**
  46870. * Setup the skybox material according to the specified options.
  46871. */
  46872. private _setupSkyboxMaterial;
  46873. /**
  46874. * Setup the skybox reflection texture according to the specified options.
  46875. */
  46876. private _setupSkyboxReflectionTexture;
  46877. private _errorHandler;
  46878. /**
  46879. * Dispose all the elements created by the Helper.
  46880. */
  46881. dispose(): void;
  46882. }
  46883. }
  46884. declare module "babylonjs/Helpers/photoDome" {
  46885. import { Observable } from "babylonjs/Misc/observable";
  46886. import { Nullable } from "babylonjs/types";
  46887. import { Scene } from "babylonjs/scene";
  46888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46889. import { Mesh } from "babylonjs/Meshes/mesh";
  46890. import { Texture } from "babylonjs/Materials/Textures/texture";
  46891. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46892. import "babylonjs/Meshes/Builders/sphereBuilder";
  46893. /**
  46894. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46895. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46896. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46897. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46898. */
  46899. export class PhotoDome extends TransformNode {
  46900. /**
  46901. * Define the image as a Monoscopic panoramic 360 image.
  46902. */
  46903. static readonly MODE_MONOSCOPIC: number;
  46904. /**
  46905. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46906. */
  46907. static readonly MODE_TOPBOTTOM: number;
  46908. /**
  46909. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46910. */
  46911. static readonly MODE_SIDEBYSIDE: number;
  46912. private _useDirectMapping;
  46913. /**
  46914. * The texture being displayed on the sphere
  46915. */
  46916. protected _photoTexture: Texture;
  46917. /**
  46918. * Gets or sets the texture being displayed on the sphere
  46919. */
  46920. photoTexture: Texture;
  46921. /**
  46922. * Observable raised when an error occured while loading the 360 image
  46923. */
  46924. onLoadErrorObservable: Observable<string>;
  46925. /**
  46926. * The skybox material
  46927. */
  46928. protected _material: BackgroundMaterial;
  46929. /**
  46930. * The surface used for the skybox
  46931. */
  46932. protected _mesh: Mesh;
  46933. /**
  46934. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46935. * Also see the options.resolution property.
  46936. */
  46937. fovMultiplier: number;
  46938. private _imageMode;
  46939. /**
  46940. * Gets or set the current video mode for the video. It can be:
  46941. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46942. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46943. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46944. */
  46945. imageMode: number;
  46946. /**
  46947. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46948. * @param name Element's name, child elements will append suffixes for their own names.
  46949. * @param urlsOfPhoto defines the url of the photo to display
  46950. * @param options defines an object containing optional or exposed sub element properties
  46951. * @param onError defines a callback called when an error occured while loading the texture
  46952. */
  46953. constructor(name: string, urlOfPhoto: string, options: {
  46954. resolution?: number;
  46955. size?: number;
  46956. useDirectMapping?: boolean;
  46957. faceForward?: boolean;
  46958. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46959. private _onBeforeCameraRenderObserver;
  46960. private _changeImageMode;
  46961. /**
  46962. * Releases resources associated with this node.
  46963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46965. */
  46966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46967. }
  46968. }
  46969. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46970. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46971. /** @hidden */
  46972. export var rgbdDecodePixelShader: {
  46973. name: string;
  46974. shader: string;
  46975. };
  46976. }
  46977. declare module "babylonjs/Misc/brdfTextureTools" {
  46978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46979. import { Scene } from "babylonjs/scene";
  46980. import "babylonjs/Shaders/rgbdDecode.fragment";
  46981. /**
  46982. * Class used to host texture specific utilities
  46983. */
  46984. export class BRDFTextureTools {
  46985. /**
  46986. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46987. * @param texture the texture to expand.
  46988. */
  46989. private static _ExpandDefaultBRDFTexture;
  46990. /**
  46991. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46992. * @param scene defines the hosting scene
  46993. * @returns the environment BRDF texture
  46994. */
  46995. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46996. private static _environmentBRDFBase64Texture;
  46997. }
  46998. }
  46999. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47000. import { Nullable } from "babylonjs/types";
  47001. import { Color3 } from "babylonjs/Maths/math.color";
  47002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47003. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47004. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47006. import { Engine } from "babylonjs/Engines/engine";
  47007. import { Scene } from "babylonjs/scene";
  47008. /**
  47009. * @hidden
  47010. */
  47011. export interface IMaterialClearCoatDefines {
  47012. CLEARCOAT: boolean;
  47013. CLEARCOAT_DEFAULTIOR: boolean;
  47014. CLEARCOAT_TEXTURE: boolean;
  47015. CLEARCOAT_TEXTUREDIRECTUV: number;
  47016. CLEARCOAT_BUMP: boolean;
  47017. CLEARCOAT_BUMPDIRECTUV: number;
  47018. CLEARCOAT_TINT: boolean;
  47019. CLEARCOAT_TINT_TEXTURE: boolean;
  47020. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47021. /** @hidden */
  47022. _areTexturesDirty: boolean;
  47023. }
  47024. /**
  47025. * Define the code related to the clear coat parameters of the pbr material.
  47026. */
  47027. export class PBRClearCoatConfiguration {
  47028. /**
  47029. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47030. * The default fits with a polyurethane material.
  47031. */
  47032. private static readonly _DefaultIndexOfRefraction;
  47033. private _isEnabled;
  47034. /**
  47035. * Defines if the clear coat is enabled in the material.
  47036. */
  47037. isEnabled: boolean;
  47038. /**
  47039. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47040. */
  47041. intensity: number;
  47042. /**
  47043. * Defines the clear coat layer roughness.
  47044. */
  47045. roughness: number;
  47046. private _indexOfRefraction;
  47047. /**
  47048. * Defines the index of refraction of the clear coat.
  47049. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47050. * The default fits with a polyurethane material.
  47051. * Changing the default value is more performance intensive.
  47052. */
  47053. indexOfRefraction: number;
  47054. private _texture;
  47055. /**
  47056. * Stores the clear coat values in a texture.
  47057. */
  47058. texture: Nullable<BaseTexture>;
  47059. private _bumpTexture;
  47060. /**
  47061. * Define the clear coat specific bump texture.
  47062. */
  47063. bumpTexture: Nullable<BaseTexture>;
  47064. private _isTintEnabled;
  47065. /**
  47066. * Defines if the clear coat tint is enabled in the material.
  47067. */
  47068. isTintEnabled: boolean;
  47069. /**
  47070. * Defines the clear coat tint of the material.
  47071. * This is only use if tint is enabled
  47072. */
  47073. tintColor: Color3;
  47074. /**
  47075. * Defines the distance at which the tint color should be found in the
  47076. * clear coat media.
  47077. * This is only use if tint is enabled
  47078. */
  47079. tintColorAtDistance: number;
  47080. /**
  47081. * Defines the clear coat layer thickness.
  47082. * This is only use if tint is enabled
  47083. */
  47084. tintThickness: number;
  47085. private _tintTexture;
  47086. /**
  47087. * Stores the clear tint values in a texture.
  47088. * rgb is tint
  47089. * a is a thickness factor
  47090. */
  47091. tintTexture: Nullable<BaseTexture>;
  47092. /** @hidden */
  47093. private _internalMarkAllSubMeshesAsTexturesDirty;
  47094. /** @hidden */
  47095. _markAllSubMeshesAsTexturesDirty(): void;
  47096. /**
  47097. * Instantiate a new istance of clear coat configuration.
  47098. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47099. */
  47100. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47101. /**
  47102. * Gets wehter the submesh is ready to be used or not.
  47103. * @param defines the list of "defines" to update.
  47104. * @param scene defines the scene the material belongs to.
  47105. * @param engine defines the engine the material belongs to.
  47106. * @param disableBumpMap defines wether the material disables bump or not.
  47107. * @returns - boolean indicating that the submesh is ready or not.
  47108. */
  47109. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47110. /**
  47111. * Checks to see if a texture is used in the material.
  47112. * @param defines the list of "defines" to update.
  47113. * @param scene defines the scene to the material belongs to.
  47114. */
  47115. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47116. /**
  47117. * Binds the material data.
  47118. * @param uniformBuffer defines the Uniform buffer to fill in.
  47119. * @param scene defines the scene the material belongs to.
  47120. * @param engine defines the engine the material belongs to.
  47121. * @param disableBumpMap defines wether the material disables bump or not.
  47122. * @param isFrozen defines wether the material is frozen or not.
  47123. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47124. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47125. */
  47126. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47127. /**
  47128. * Checks to see if a texture is used in the material.
  47129. * @param texture - Base texture to use.
  47130. * @returns - Boolean specifying if a texture is used in the material.
  47131. */
  47132. hasTexture(texture: BaseTexture): boolean;
  47133. /**
  47134. * Returns an array of the actively used textures.
  47135. * @param activeTextures Array of BaseTextures
  47136. */
  47137. getActiveTextures(activeTextures: BaseTexture[]): void;
  47138. /**
  47139. * Returns the animatable textures.
  47140. * @param animatables Array of animatable textures.
  47141. */
  47142. getAnimatables(animatables: IAnimatable[]): void;
  47143. /**
  47144. * Disposes the resources of the material.
  47145. * @param forceDisposeTextures - Forces the disposal of all textures.
  47146. */
  47147. dispose(forceDisposeTextures?: boolean): void;
  47148. /**
  47149. * Get the current class name of the texture useful for serialization or dynamic coding.
  47150. * @returns "PBRClearCoatConfiguration"
  47151. */
  47152. getClassName(): string;
  47153. /**
  47154. * Add fallbacks to the effect fallbacks list.
  47155. * @param defines defines the Base texture to use.
  47156. * @param fallbacks defines the current fallback list.
  47157. * @param currentRank defines the current fallback rank.
  47158. * @returns the new fallback rank.
  47159. */
  47160. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47161. /**
  47162. * Add the required uniforms to the current list.
  47163. * @param uniforms defines the current uniform list.
  47164. */
  47165. static AddUniforms(uniforms: string[]): void;
  47166. /**
  47167. * Add the required samplers to the current list.
  47168. * @param samplers defines the current sampler list.
  47169. */
  47170. static AddSamplers(samplers: string[]): void;
  47171. /**
  47172. * Add the required uniforms to the current buffer.
  47173. * @param uniformBuffer defines the current uniform buffer.
  47174. */
  47175. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47176. /**
  47177. * Makes a duplicate of the current configuration into another one.
  47178. * @param clearCoatConfiguration define the config where to copy the info
  47179. */
  47180. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47181. /**
  47182. * Serializes this clear coat configuration.
  47183. * @returns - An object with the serialized config.
  47184. */
  47185. serialize(): any;
  47186. /**
  47187. * Parses a anisotropy Configuration from a serialized object.
  47188. * @param source - Serialized object.
  47189. * @param scene Defines the scene we are parsing for
  47190. * @param rootUrl Defines the rootUrl to load from
  47191. */
  47192. parse(source: any, scene: Scene, rootUrl: string): void;
  47193. }
  47194. }
  47195. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47196. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47197. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47199. import { Vector2 } from "babylonjs/Maths/math.vector";
  47200. import { Scene } from "babylonjs/scene";
  47201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47202. import { Nullable } from "babylonjs/types";
  47203. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47204. /**
  47205. * @hidden
  47206. */
  47207. export interface IMaterialAnisotropicDefines {
  47208. ANISOTROPIC: boolean;
  47209. ANISOTROPIC_TEXTURE: boolean;
  47210. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47211. MAINUV1: boolean;
  47212. _areTexturesDirty: boolean;
  47213. _needUVs: boolean;
  47214. }
  47215. /**
  47216. * Define the code related to the anisotropic parameters of the pbr material.
  47217. */
  47218. export class PBRAnisotropicConfiguration {
  47219. private _isEnabled;
  47220. /**
  47221. * Defines if the anisotropy is enabled in the material.
  47222. */
  47223. isEnabled: boolean;
  47224. /**
  47225. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47226. */
  47227. intensity: number;
  47228. /**
  47229. * Defines if the effect is along the tangents, bitangents or in between.
  47230. * By default, the effect is "strectching" the highlights along the tangents.
  47231. */
  47232. direction: Vector2;
  47233. private _texture;
  47234. /**
  47235. * Stores the anisotropy values in a texture.
  47236. * rg is direction (like normal from -1 to 1)
  47237. * b is a intensity
  47238. */
  47239. texture: Nullable<BaseTexture>;
  47240. /** @hidden */
  47241. private _internalMarkAllSubMeshesAsTexturesDirty;
  47242. /** @hidden */
  47243. _markAllSubMeshesAsTexturesDirty(): void;
  47244. /**
  47245. * Instantiate a new istance of anisotropy configuration.
  47246. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47247. */
  47248. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47249. /**
  47250. * Specifies that the submesh is ready to be used.
  47251. * @param defines the list of "defines" to update.
  47252. * @param scene defines the scene the material belongs to.
  47253. * @returns - boolean indicating that the submesh is ready or not.
  47254. */
  47255. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47256. /**
  47257. * Checks to see if a texture is used in the material.
  47258. * @param defines the list of "defines" to update.
  47259. * @param mesh the mesh we are preparing the defines for.
  47260. * @param scene defines the scene the material belongs to.
  47261. */
  47262. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47263. /**
  47264. * Binds the material data.
  47265. * @param uniformBuffer defines the Uniform buffer to fill in.
  47266. * @param scene defines the scene the material belongs to.
  47267. * @param isFrozen defines wether the material is frozen or not.
  47268. */
  47269. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47270. /**
  47271. * Checks to see if a texture is used in the material.
  47272. * @param texture - Base texture to use.
  47273. * @returns - Boolean specifying if a texture is used in the material.
  47274. */
  47275. hasTexture(texture: BaseTexture): boolean;
  47276. /**
  47277. * Returns an array of the actively used textures.
  47278. * @param activeTextures Array of BaseTextures
  47279. */
  47280. getActiveTextures(activeTextures: BaseTexture[]): void;
  47281. /**
  47282. * Returns the animatable textures.
  47283. * @param animatables Array of animatable textures.
  47284. */
  47285. getAnimatables(animatables: IAnimatable[]): void;
  47286. /**
  47287. * Disposes the resources of the material.
  47288. * @param forceDisposeTextures - Forces the disposal of all textures.
  47289. */
  47290. dispose(forceDisposeTextures?: boolean): void;
  47291. /**
  47292. * Get the current class name of the texture useful for serialization or dynamic coding.
  47293. * @returns "PBRAnisotropicConfiguration"
  47294. */
  47295. getClassName(): string;
  47296. /**
  47297. * Add fallbacks to the effect fallbacks list.
  47298. * @param defines defines the Base texture to use.
  47299. * @param fallbacks defines the current fallback list.
  47300. * @param currentRank defines the current fallback rank.
  47301. * @returns the new fallback rank.
  47302. */
  47303. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47304. /**
  47305. * Add the required uniforms to the current list.
  47306. * @param uniforms defines the current uniform list.
  47307. */
  47308. static AddUniforms(uniforms: string[]): void;
  47309. /**
  47310. * Add the required uniforms to the current buffer.
  47311. * @param uniformBuffer defines the current uniform buffer.
  47312. */
  47313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47314. /**
  47315. * Add the required samplers to the current list.
  47316. * @param samplers defines the current sampler list.
  47317. */
  47318. static AddSamplers(samplers: string[]): void;
  47319. /**
  47320. * Makes a duplicate of the current configuration into another one.
  47321. * @param anisotropicConfiguration define the config where to copy the info
  47322. */
  47323. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47324. /**
  47325. * Serializes this anisotropy configuration.
  47326. * @returns - An object with the serialized config.
  47327. */
  47328. serialize(): any;
  47329. /**
  47330. * Parses a anisotropy Configuration from a serialized object.
  47331. * @param source - Serialized object.
  47332. * @param scene Defines the scene we are parsing for
  47333. * @param rootUrl Defines the rootUrl to load from
  47334. */
  47335. parse(source: any, scene: Scene, rootUrl: string): void;
  47336. }
  47337. }
  47338. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47339. import { Scene } from "babylonjs/scene";
  47340. /**
  47341. * @hidden
  47342. */
  47343. export interface IMaterialBRDFDefines {
  47344. BRDF_V_HEIGHT_CORRELATED: boolean;
  47345. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47346. SPHERICAL_HARMONICS: boolean;
  47347. /** @hidden */
  47348. _areMiscDirty: boolean;
  47349. }
  47350. /**
  47351. * Define the code related to the BRDF parameters of the pbr material.
  47352. */
  47353. export class PBRBRDFConfiguration {
  47354. /**
  47355. * Default value used for the energy conservation.
  47356. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47357. */
  47358. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47359. /**
  47360. * Default value used for the Smith Visibility Height Correlated mode.
  47361. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47362. */
  47363. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47364. /**
  47365. * Default value used for the IBL diffuse part.
  47366. * This can help switching back to the polynomials mode globally which is a tiny bit
  47367. * less GPU intensive at the drawback of a lower quality.
  47368. */
  47369. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47370. private _useEnergyConservation;
  47371. /**
  47372. * Defines if the material uses energy conservation.
  47373. */
  47374. useEnergyConservation: boolean;
  47375. private _useSmithVisibilityHeightCorrelated;
  47376. /**
  47377. * LEGACY Mode set to false
  47378. * Defines if the material uses height smith correlated visibility term.
  47379. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47380. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47381. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47382. * Not relying on height correlated will also disable energy conservation.
  47383. */
  47384. useSmithVisibilityHeightCorrelated: boolean;
  47385. private _useSphericalHarmonics;
  47386. /**
  47387. * LEGACY Mode set to false
  47388. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47389. * diffuse part of the IBL.
  47390. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47391. * to the ground truth.
  47392. */
  47393. useSphericalHarmonics: boolean;
  47394. /** @hidden */
  47395. private _internalMarkAllSubMeshesAsMiscDirty;
  47396. /** @hidden */
  47397. _markAllSubMeshesAsMiscDirty(): void;
  47398. /**
  47399. * Instantiate a new istance of clear coat configuration.
  47400. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47401. */
  47402. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47403. /**
  47404. * Checks to see if a texture is used in the material.
  47405. * @param defines the list of "defines" to update.
  47406. */
  47407. prepareDefines(defines: IMaterialBRDFDefines): void;
  47408. /**
  47409. * Get the current class name of the texture useful for serialization or dynamic coding.
  47410. * @returns "PBRClearCoatConfiguration"
  47411. */
  47412. getClassName(): string;
  47413. /**
  47414. * Makes a duplicate of the current configuration into another one.
  47415. * @param brdfConfiguration define the config where to copy the info
  47416. */
  47417. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47418. /**
  47419. * Serializes this BRDF configuration.
  47420. * @returns - An object with the serialized config.
  47421. */
  47422. serialize(): any;
  47423. /**
  47424. * Parses a anisotropy Configuration from a serialized object.
  47425. * @param source - Serialized object.
  47426. * @param scene Defines the scene we are parsing for
  47427. * @param rootUrl Defines the rootUrl to load from
  47428. */
  47429. parse(source: any, scene: Scene, rootUrl: string): void;
  47430. }
  47431. }
  47432. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47433. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47434. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47435. import { Color3 } from "babylonjs/Maths/math.color";
  47436. import { Scene } from "babylonjs/scene";
  47437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47438. import { Nullable } from "babylonjs/types";
  47439. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47440. /**
  47441. * @hidden
  47442. */
  47443. export interface IMaterialSheenDefines {
  47444. SHEEN: boolean;
  47445. SHEEN_TEXTURE: boolean;
  47446. SHEEN_TEXTUREDIRECTUV: number;
  47447. SHEEN_LINKWITHALBEDO: boolean;
  47448. /** @hidden */
  47449. _areTexturesDirty: boolean;
  47450. }
  47451. /**
  47452. * Define the code related to the Sheen parameters of the pbr material.
  47453. */
  47454. export class PBRSheenConfiguration {
  47455. private _isEnabled;
  47456. /**
  47457. * Defines if the material uses sheen.
  47458. */
  47459. isEnabled: boolean;
  47460. private _linkSheenWithAlbedo;
  47461. /**
  47462. * Defines if the sheen is linked to the sheen color.
  47463. */
  47464. linkSheenWithAlbedo: boolean;
  47465. /**
  47466. * Defines the sheen intensity.
  47467. */
  47468. intensity: number;
  47469. /**
  47470. * Defines the sheen color.
  47471. */
  47472. color: Color3;
  47473. private _texture;
  47474. /**
  47475. * Stores the sheen tint values in a texture.
  47476. * rgb is tint
  47477. * a is a intensity
  47478. */
  47479. texture: Nullable<BaseTexture>;
  47480. /** @hidden */
  47481. private _internalMarkAllSubMeshesAsTexturesDirty;
  47482. /** @hidden */
  47483. _markAllSubMeshesAsTexturesDirty(): void;
  47484. /**
  47485. * Instantiate a new istance of clear coat configuration.
  47486. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47487. */
  47488. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47489. /**
  47490. * Specifies that the submesh is ready to be used.
  47491. * @param defines the list of "defines" to update.
  47492. * @param scene defines the scene the material belongs to.
  47493. * @returns - boolean indicating that the submesh is ready or not.
  47494. */
  47495. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47496. /**
  47497. * Checks to see if a texture is used in the material.
  47498. * @param defines the list of "defines" to update.
  47499. * @param scene defines the scene the material belongs to.
  47500. */
  47501. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47502. /**
  47503. * Binds the material data.
  47504. * @param uniformBuffer defines the Uniform buffer to fill in.
  47505. * @param scene defines the scene the material belongs to.
  47506. * @param isFrozen defines wether the material is frozen or not.
  47507. */
  47508. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47509. /**
  47510. * Checks to see if a texture is used in the material.
  47511. * @param texture - Base texture to use.
  47512. * @returns - Boolean specifying if a texture is used in the material.
  47513. */
  47514. hasTexture(texture: BaseTexture): boolean;
  47515. /**
  47516. * Returns an array of the actively used textures.
  47517. * @param activeTextures Array of BaseTextures
  47518. */
  47519. getActiveTextures(activeTextures: BaseTexture[]): void;
  47520. /**
  47521. * Returns the animatable textures.
  47522. * @param animatables Array of animatable textures.
  47523. */
  47524. getAnimatables(animatables: IAnimatable[]): void;
  47525. /**
  47526. * Disposes the resources of the material.
  47527. * @param forceDisposeTextures - Forces the disposal of all textures.
  47528. */
  47529. dispose(forceDisposeTextures?: boolean): void;
  47530. /**
  47531. * Get the current class name of the texture useful for serialization or dynamic coding.
  47532. * @returns "PBRSheenConfiguration"
  47533. */
  47534. getClassName(): string;
  47535. /**
  47536. * Add fallbacks to the effect fallbacks list.
  47537. * @param defines defines the Base texture to use.
  47538. * @param fallbacks defines the current fallback list.
  47539. * @param currentRank defines the current fallback rank.
  47540. * @returns the new fallback rank.
  47541. */
  47542. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47543. /**
  47544. * Add the required uniforms to the current list.
  47545. * @param uniforms defines the current uniform list.
  47546. */
  47547. static AddUniforms(uniforms: string[]): void;
  47548. /**
  47549. * Add the required uniforms to the current buffer.
  47550. * @param uniformBuffer defines the current uniform buffer.
  47551. */
  47552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47553. /**
  47554. * Add the required samplers to the current list.
  47555. * @param samplers defines the current sampler list.
  47556. */
  47557. static AddSamplers(samplers: string[]): void;
  47558. /**
  47559. * Makes a duplicate of the current configuration into another one.
  47560. * @param sheenConfiguration define the config where to copy the info
  47561. */
  47562. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47563. /**
  47564. * Serializes this BRDF configuration.
  47565. * @returns - An object with the serialized config.
  47566. */
  47567. serialize(): any;
  47568. /**
  47569. * Parses a anisotropy Configuration from a serialized object.
  47570. * @param source - Serialized object.
  47571. * @param scene Defines the scene we are parsing for
  47572. * @param rootUrl Defines the rootUrl to load from
  47573. */
  47574. parse(source: any, scene: Scene, rootUrl: string): void;
  47575. }
  47576. }
  47577. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47578. import { Nullable } from "babylonjs/types";
  47579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47580. import { Color3 } from "babylonjs/Maths/math.color";
  47581. import { SmartArray } from "babylonjs/Misc/smartArray";
  47582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47584. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47585. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47586. import { Engine } from "babylonjs/Engines/engine";
  47587. import { Scene } from "babylonjs/scene";
  47588. /**
  47589. * @hidden
  47590. */
  47591. export interface IMaterialSubSurfaceDefines {
  47592. SUBSURFACE: boolean;
  47593. SS_REFRACTION: boolean;
  47594. SS_TRANSLUCENCY: boolean;
  47595. SS_SCATERRING: boolean;
  47596. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47597. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47598. SS_REFRACTIONMAP_3D: boolean;
  47599. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47600. SS_LODINREFRACTIONALPHA: boolean;
  47601. SS_GAMMAREFRACTION: boolean;
  47602. SS_RGBDREFRACTION: boolean;
  47603. SS_LINEARSPECULARREFRACTION: boolean;
  47604. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47605. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47606. /** @hidden */
  47607. _areTexturesDirty: boolean;
  47608. }
  47609. /**
  47610. * Define the code related to the sub surface parameters of the pbr material.
  47611. */
  47612. export class PBRSubSurfaceConfiguration {
  47613. private _isRefractionEnabled;
  47614. /**
  47615. * Defines if the refraction is enabled in the material.
  47616. */
  47617. isRefractionEnabled: boolean;
  47618. private _isTranslucencyEnabled;
  47619. /**
  47620. * Defines if the translucency is enabled in the material.
  47621. */
  47622. isTranslucencyEnabled: boolean;
  47623. private _isScatteringEnabled;
  47624. /**
  47625. * Defines the refraction intensity of the material.
  47626. * The refraction when enabled replaces the Diffuse part of the material.
  47627. * The intensity helps transitionning between diffuse and refraction.
  47628. */
  47629. refractionIntensity: number;
  47630. /**
  47631. * Defines the translucency intensity of the material.
  47632. * When translucency has been enabled, this defines how much of the "translucency"
  47633. * is addded to the diffuse part of the material.
  47634. */
  47635. translucencyIntensity: number;
  47636. /**
  47637. * Defines the scattering intensity of the material.
  47638. * When scattering has been enabled, this defines how much of the "scattered light"
  47639. * is addded to the diffuse part of the material.
  47640. */
  47641. scatteringIntensity: number;
  47642. private _thicknessTexture;
  47643. /**
  47644. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47645. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47646. * 0 would mean minimumThickness
  47647. * 1 would mean maximumThickness
  47648. * The other channels might be use as a mask to vary the different effects intensity.
  47649. */
  47650. thicknessTexture: Nullable<BaseTexture>;
  47651. private _refractionTexture;
  47652. /**
  47653. * Defines the texture to use for refraction.
  47654. */
  47655. refractionTexture: Nullable<BaseTexture>;
  47656. private _indexOfRefraction;
  47657. /**
  47658. * Defines the index of refraction used in the material.
  47659. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47660. */
  47661. indexOfRefraction: number;
  47662. private _invertRefractionY;
  47663. /**
  47664. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47665. */
  47666. invertRefractionY: boolean;
  47667. private _linkRefractionWithTransparency;
  47668. /**
  47669. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47670. * Materials half opaque for instance using refraction could benefit from this control.
  47671. */
  47672. linkRefractionWithTransparency: boolean;
  47673. /**
  47674. * Defines the minimum thickness stored in the thickness map.
  47675. * If no thickness map is defined, this value will be used to simulate thickness.
  47676. */
  47677. minimumThickness: number;
  47678. /**
  47679. * Defines the maximum thickness stored in the thickness map.
  47680. */
  47681. maximumThickness: number;
  47682. /**
  47683. * Defines the volume tint of the material.
  47684. * This is used for both translucency and scattering.
  47685. */
  47686. tintColor: Color3;
  47687. /**
  47688. * Defines the distance at which the tint color should be found in the media.
  47689. * This is used for refraction only.
  47690. */
  47691. tintColorAtDistance: number;
  47692. /**
  47693. * Defines how far each channel transmit through the media.
  47694. * It is defined as a color to simplify it selection.
  47695. */
  47696. diffusionDistance: Color3;
  47697. private _useMaskFromThicknessTexture;
  47698. /**
  47699. * Stores the intensity of the different subsurface effects in the thickness texture.
  47700. * * the green channel is the translucency intensity.
  47701. * * the blue channel is the scattering intensity.
  47702. * * the alpha channel is the refraction intensity.
  47703. */
  47704. useMaskFromThicknessTexture: boolean;
  47705. /** @hidden */
  47706. private _internalMarkAllSubMeshesAsTexturesDirty;
  47707. /** @hidden */
  47708. _markAllSubMeshesAsTexturesDirty(): void;
  47709. /**
  47710. * Instantiate a new istance of sub surface configuration.
  47711. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47712. */
  47713. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47714. /**
  47715. * Gets wehter the submesh is ready to be used or not.
  47716. * @param defines the list of "defines" to update.
  47717. * @param scene defines the scene the material belongs to.
  47718. * @returns - boolean indicating that the submesh is ready or not.
  47719. */
  47720. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47721. /**
  47722. * Checks to see if a texture is used in the material.
  47723. * @param defines the list of "defines" to update.
  47724. * @param scene defines the scene to the material belongs to.
  47725. */
  47726. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47727. /**
  47728. * Binds the material data.
  47729. * @param uniformBuffer defines the Uniform buffer to fill in.
  47730. * @param scene defines the scene the material belongs to.
  47731. * @param engine defines the engine the material belongs to.
  47732. * @param isFrozen defines wether the material is frozen or not.
  47733. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47734. */
  47735. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47736. /**
  47737. * Unbinds the material from the mesh.
  47738. * @param activeEffect defines the effect that should be unbound from.
  47739. * @returns true if unbound, otherwise false
  47740. */
  47741. unbind(activeEffect: Effect): boolean;
  47742. /**
  47743. * Returns the texture used for refraction or null if none is used.
  47744. * @param scene defines the scene the material belongs to.
  47745. * @returns - Refraction texture if present. If no refraction texture and refraction
  47746. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47747. */
  47748. private _getRefractionTexture;
  47749. /**
  47750. * Returns true if alpha blending should be disabled.
  47751. */
  47752. readonly disableAlphaBlending: boolean;
  47753. /**
  47754. * Fills the list of render target textures.
  47755. * @param renderTargets the list of render targets to update
  47756. */
  47757. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47758. /**
  47759. * Checks to see if a texture is used in the material.
  47760. * @param texture - Base texture to use.
  47761. * @returns - Boolean specifying if a texture is used in the material.
  47762. */
  47763. hasTexture(texture: BaseTexture): boolean;
  47764. /**
  47765. * Gets a boolean indicating that current material needs to register RTT
  47766. * @returns true if this uses a render target otherwise false.
  47767. */
  47768. hasRenderTargetTextures(): boolean;
  47769. /**
  47770. * Returns an array of the actively used textures.
  47771. * @param activeTextures Array of BaseTextures
  47772. */
  47773. getActiveTextures(activeTextures: BaseTexture[]): void;
  47774. /**
  47775. * Returns the animatable textures.
  47776. * @param animatables Array of animatable textures.
  47777. */
  47778. getAnimatables(animatables: IAnimatable[]): void;
  47779. /**
  47780. * Disposes the resources of the material.
  47781. * @param forceDisposeTextures - Forces the disposal of all textures.
  47782. */
  47783. dispose(forceDisposeTextures?: boolean): void;
  47784. /**
  47785. * Get the current class name of the texture useful for serialization or dynamic coding.
  47786. * @returns "PBRSubSurfaceConfiguration"
  47787. */
  47788. getClassName(): string;
  47789. /**
  47790. * Add fallbacks to the effect fallbacks list.
  47791. * @param defines defines the Base texture to use.
  47792. * @param fallbacks defines the current fallback list.
  47793. * @param currentRank defines the current fallback rank.
  47794. * @returns the new fallback rank.
  47795. */
  47796. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47797. /**
  47798. * Add the required uniforms to the current list.
  47799. * @param uniforms defines the current uniform list.
  47800. */
  47801. static AddUniforms(uniforms: string[]): void;
  47802. /**
  47803. * Add the required samplers to the current list.
  47804. * @param samplers defines the current sampler list.
  47805. */
  47806. static AddSamplers(samplers: string[]): void;
  47807. /**
  47808. * Add the required uniforms to the current buffer.
  47809. * @param uniformBuffer defines the current uniform buffer.
  47810. */
  47811. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47812. /**
  47813. * Makes a duplicate of the current configuration into another one.
  47814. * @param configuration define the config where to copy the info
  47815. */
  47816. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47817. /**
  47818. * Serializes this Sub Surface configuration.
  47819. * @returns - An object with the serialized config.
  47820. */
  47821. serialize(): any;
  47822. /**
  47823. * Parses a anisotropy Configuration from a serialized object.
  47824. * @param source - Serialized object.
  47825. * @param scene Defines the scene we are parsing for
  47826. * @param rootUrl Defines the rootUrl to load from
  47827. */
  47828. parse(source: any, scene: Scene, rootUrl: string): void;
  47829. }
  47830. }
  47831. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47832. /** @hidden */
  47833. export var pbrFragmentDeclaration: {
  47834. name: string;
  47835. shader: string;
  47836. };
  47837. }
  47838. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47839. /** @hidden */
  47840. export var pbrUboDeclaration: {
  47841. name: string;
  47842. shader: string;
  47843. };
  47844. }
  47845. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47846. /** @hidden */
  47847. export var pbrFragmentExtraDeclaration: {
  47848. name: string;
  47849. shader: string;
  47850. };
  47851. }
  47852. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47853. /** @hidden */
  47854. export var pbrFragmentSamplersDeclaration: {
  47855. name: string;
  47856. shader: string;
  47857. };
  47858. }
  47859. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47860. /** @hidden */
  47861. export var pbrHelperFunctions: {
  47862. name: string;
  47863. shader: string;
  47864. };
  47865. }
  47866. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47867. /** @hidden */
  47868. export var harmonicsFunctions: {
  47869. name: string;
  47870. shader: string;
  47871. };
  47872. }
  47873. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47874. /** @hidden */
  47875. export var pbrDirectLightingSetupFunctions: {
  47876. name: string;
  47877. shader: string;
  47878. };
  47879. }
  47880. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47881. /** @hidden */
  47882. export var pbrDirectLightingFalloffFunctions: {
  47883. name: string;
  47884. shader: string;
  47885. };
  47886. }
  47887. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47888. /** @hidden */
  47889. export var pbrBRDFFunctions: {
  47890. name: string;
  47891. shader: string;
  47892. };
  47893. }
  47894. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47895. /** @hidden */
  47896. export var pbrDirectLightingFunctions: {
  47897. name: string;
  47898. shader: string;
  47899. };
  47900. }
  47901. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47902. /** @hidden */
  47903. export var pbrIBLFunctions: {
  47904. name: string;
  47905. shader: string;
  47906. };
  47907. }
  47908. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47909. /** @hidden */
  47910. export var pbrDebug: {
  47911. name: string;
  47912. shader: string;
  47913. };
  47914. }
  47915. declare module "babylonjs/Shaders/pbr.fragment" {
  47916. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47917. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47918. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47919. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47920. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47921. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47924. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47925. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47926. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47927. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47928. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47929. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47930. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47931. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47932. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47933. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47934. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47935. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47936. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47937. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47938. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47939. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47940. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47941. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47942. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47943. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47944. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47945. /** @hidden */
  47946. export var pbrPixelShader: {
  47947. name: string;
  47948. shader: string;
  47949. };
  47950. }
  47951. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47952. /** @hidden */
  47953. export var pbrVertexDeclaration: {
  47954. name: string;
  47955. shader: string;
  47956. };
  47957. }
  47958. declare module "babylonjs/Shaders/pbr.vertex" {
  47959. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47960. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47961. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47962. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47963. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47964. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47965. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47966. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47967. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47968. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47969. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47970. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47971. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47972. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47974. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47975. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47976. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47977. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47978. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47979. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47980. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47981. /** @hidden */
  47982. export var pbrVertexShader: {
  47983. name: string;
  47984. shader: string;
  47985. };
  47986. }
  47987. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47988. import { Nullable } from "babylonjs/types";
  47989. import { Scene } from "babylonjs/scene";
  47990. import { Matrix } from "babylonjs/Maths/math.vector";
  47991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47993. import { Mesh } from "babylonjs/Meshes/mesh";
  47994. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47995. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47996. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47997. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47998. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47999. import { Color3 } from "babylonjs/Maths/math.color";
  48000. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48001. import { Material } from "babylonjs/Materials/material";
  48002. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48003. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48006. import "babylonjs/Shaders/pbr.fragment";
  48007. import "babylonjs/Shaders/pbr.vertex";
  48008. /**
  48009. * Manages the defines for the PBR Material.
  48010. * @hidden
  48011. */
  48012. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48013. PBR: boolean;
  48014. MAINUV1: boolean;
  48015. MAINUV2: boolean;
  48016. UV1: boolean;
  48017. UV2: boolean;
  48018. ALBEDO: boolean;
  48019. ALBEDODIRECTUV: number;
  48020. VERTEXCOLOR: boolean;
  48021. AMBIENT: boolean;
  48022. AMBIENTDIRECTUV: number;
  48023. AMBIENTINGRAYSCALE: boolean;
  48024. OPACITY: boolean;
  48025. VERTEXALPHA: boolean;
  48026. OPACITYDIRECTUV: number;
  48027. OPACITYRGB: boolean;
  48028. ALPHATEST: boolean;
  48029. DEPTHPREPASS: boolean;
  48030. ALPHABLEND: boolean;
  48031. ALPHAFROMALBEDO: boolean;
  48032. ALPHATESTVALUE: string;
  48033. SPECULAROVERALPHA: boolean;
  48034. RADIANCEOVERALPHA: boolean;
  48035. ALPHAFRESNEL: boolean;
  48036. LINEARALPHAFRESNEL: boolean;
  48037. PREMULTIPLYALPHA: boolean;
  48038. EMISSIVE: boolean;
  48039. EMISSIVEDIRECTUV: number;
  48040. REFLECTIVITY: boolean;
  48041. REFLECTIVITYDIRECTUV: number;
  48042. SPECULARTERM: boolean;
  48043. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48044. MICROSURFACEAUTOMATIC: boolean;
  48045. LODBASEDMICROSFURACE: boolean;
  48046. MICROSURFACEMAP: boolean;
  48047. MICROSURFACEMAPDIRECTUV: number;
  48048. METALLICWORKFLOW: boolean;
  48049. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48050. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48051. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48052. AOSTOREINMETALMAPRED: boolean;
  48053. ENVIRONMENTBRDF: boolean;
  48054. ENVIRONMENTBRDF_RGBD: boolean;
  48055. NORMAL: boolean;
  48056. TANGENT: boolean;
  48057. BUMP: boolean;
  48058. BUMPDIRECTUV: number;
  48059. OBJECTSPACE_NORMALMAP: boolean;
  48060. PARALLAX: boolean;
  48061. PARALLAXOCCLUSION: boolean;
  48062. NORMALXYSCALE: boolean;
  48063. LIGHTMAP: boolean;
  48064. LIGHTMAPDIRECTUV: number;
  48065. USELIGHTMAPASSHADOWMAP: boolean;
  48066. GAMMALIGHTMAP: boolean;
  48067. REFLECTION: boolean;
  48068. REFLECTIONMAP_3D: boolean;
  48069. REFLECTIONMAP_SPHERICAL: boolean;
  48070. REFLECTIONMAP_PLANAR: boolean;
  48071. REFLECTIONMAP_CUBIC: boolean;
  48072. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48073. REFLECTIONMAP_PROJECTION: boolean;
  48074. REFLECTIONMAP_SKYBOX: boolean;
  48075. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48076. REFLECTIONMAP_EXPLICIT: boolean;
  48077. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48078. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48079. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48080. INVERTCUBICMAP: boolean;
  48081. USESPHERICALFROMREFLECTIONMAP: boolean;
  48082. USEIRRADIANCEMAP: boolean;
  48083. SPHERICAL_HARMONICS: boolean;
  48084. USESPHERICALINVERTEX: boolean;
  48085. REFLECTIONMAP_OPPOSITEZ: boolean;
  48086. LODINREFLECTIONALPHA: boolean;
  48087. GAMMAREFLECTION: boolean;
  48088. RGBDREFLECTION: boolean;
  48089. LINEARSPECULARREFLECTION: boolean;
  48090. RADIANCEOCCLUSION: boolean;
  48091. HORIZONOCCLUSION: boolean;
  48092. INSTANCES: boolean;
  48093. NUM_BONE_INFLUENCERS: number;
  48094. BonesPerMesh: number;
  48095. BONETEXTURE: boolean;
  48096. NONUNIFORMSCALING: boolean;
  48097. MORPHTARGETS: boolean;
  48098. MORPHTARGETS_NORMAL: boolean;
  48099. MORPHTARGETS_TANGENT: boolean;
  48100. MORPHTARGETS_UV: boolean;
  48101. NUM_MORPH_INFLUENCERS: number;
  48102. IMAGEPROCESSING: boolean;
  48103. VIGNETTE: boolean;
  48104. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48105. VIGNETTEBLENDMODEOPAQUE: boolean;
  48106. TONEMAPPING: boolean;
  48107. TONEMAPPING_ACES: boolean;
  48108. CONTRAST: boolean;
  48109. COLORCURVES: boolean;
  48110. COLORGRADING: boolean;
  48111. COLORGRADING3D: boolean;
  48112. SAMPLER3DGREENDEPTH: boolean;
  48113. SAMPLER3DBGRMAP: boolean;
  48114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48115. EXPOSURE: boolean;
  48116. MULTIVIEW: boolean;
  48117. USEPHYSICALLIGHTFALLOFF: boolean;
  48118. USEGLTFLIGHTFALLOFF: boolean;
  48119. TWOSIDEDLIGHTING: boolean;
  48120. SHADOWFLOAT: boolean;
  48121. CLIPPLANE: boolean;
  48122. CLIPPLANE2: boolean;
  48123. CLIPPLANE3: boolean;
  48124. CLIPPLANE4: boolean;
  48125. POINTSIZE: boolean;
  48126. FOG: boolean;
  48127. LOGARITHMICDEPTH: boolean;
  48128. FORCENORMALFORWARD: boolean;
  48129. SPECULARAA: boolean;
  48130. CLEARCOAT: boolean;
  48131. CLEARCOAT_DEFAULTIOR: boolean;
  48132. CLEARCOAT_TEXTURE: boolean;
  48133. CLEARCOAT_TEXTUREDIRECTUV: number;
  48134. CLEARCOAT_BUMP: boolean;
  48135. CLEARCOAT_BUMPDIRECTUV: number;
  48136. CLEARCOAT_TINT: boolean;
  48137. CLEARCOAT_TINT_TEXTURE: boolean;
  48138. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48139. ANISOTROPIC: boolean;
  48140. ANISOTROPIC_TEXTURE: boolean;
  48141. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48142. BRDF_V_HEIGHT_CORRELATED: boolean;
  48143. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48144. SHEEN: boolean;
  48145. SHEEN_TEXTURE: boolean;
  48146. SHEEN_TEXTUREDIRECTUV: number;
  48147. SHEEN_LINKWITHALBEDO: boolean;
  48148. SUBSURFACE: boolean;
  48149. SS_REFRACTION: boolean;
  48150. SS_TRANSLUCENCY: boolean;
  48151. SS_SCATERRING: boolean;
  48152. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48153. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48154. SS_REFRACTIONMAP_3D: boolean;
  48155. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48156. SS_LODINREFRACTIONALPHA: boolean;
  48157. SS_GAMMAREFRACTION: boolean;
  48158. SS_RGBDREFRACTION: boolean;
  48159. SS_LINEARSPECULARREFRACTION: boolean;
  48160. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48161. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48162. UNLIT: boolean;
  48163. DEBUGMODE: number;
  48164. /**
  48165. * Initializes the PBR Material defines.
  48166. */
  48167. constructor();
  48168. /**
  48169. * Resets the PBR Material defines.
  48170. */
  48171. reset(): void;
  48172. }
  48173. /**
  48174. * The Physically based material base class of BJS.
  48175. *
  48176. * This offers the main features of a standard PBR material.
  48177. * For more information, please refer to the documentation :
  48178. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48179. */
  48180. export abstract class PBRBaseMaterial extends PushMaterial {
  48181. /**
  48182. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48183. */
  48184. static readonly PBRMATERIAL_OPAQUE: number;
  48185. /**
  48186. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48187. */
  48188. static readonly PBRMATERIAL_ALPHATEST: number;
  48189. /**
  48190. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48191. */
  48192. static readonly PBRMATERIAL_ALPHABLEND: number;
  48193. /**
  48194. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48195. * They are also discarded below the alpha cutoff threshold to improve performances.
  48196. */
  48197. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48198. /**
  48199. * Defines the default value of how much AO map is occluding the analytical lights
  48200. * (point spot...).
  48201. */
  48202. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48203. /**
  48204. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48205. */
  48206. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48207. /**
  48208. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48209. * to enhance interoperability with other engines.
  48210. */
  48211. static readonly LIGHTFALLOFF_GLTF: number;
  48212. /**
  48213. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48214. * to enhance interoperability with other materials.
  48215. */
  48216. static readonly LIGHTFALLOFF_STANDARD: number;
  48217. /**
  48218. * Intensity of the direct lights e.g. the four lights available in your scene.
  48219. * This impacts both the direct diffuse and specular highlights.
  48220. */
  48221. protected _directIntensity: number;
  48222. /**
  48223. * Intensity of the emissive part of the material.
  48224. * This helps controlling the emissive effect without modifying the emissive color.
  48225. */
  48226. protected _emissiveIntensity: number;
  48227. /**
  48228. * Intensity of the environment e.g. how much the environment will light the object
  48229. * either through harmonics for rough material or through the refelction for shiny ones.
  48230. */
  48231. protected _environmentIntensity: number;
  48232. /**
  48233. * This is a special control allowing the reduction of the specular highlights coming from the
  48234. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48235. */
  48236. protected _specularIntensity: number;
  48237. /**
  48238. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48239. */
  48240. private _lightingInfos;
  48241. /**
  48242. * Debug Control allowing disabling the bump map on this material.
  48243. */
  48244. protected _disableBumpMap: boolean;
  48245. /**
  48246. * AKA Diffuse Texture in standard nomenclature.
  48247. */
  48248. protected _albedoTexture: Nullable<BaseTexture>;
  48249. /**
  48250. * AKA Occlusion Texture in other nomenclature.
  48251. */
  48252. protected _ambientTexture: Nullable<BaseTexture>;
  48253. /**
  48254. * AKA Occlusion Texture Intensity in other nomenclature.
  48255. */
  48256. protected _ambientTextureStrength: number;
  48257. /**
  48258. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48259. * 1 means it completely occludes it
  48260. * 0 mean it has no impact
  48261. */
  48262. protected _ambientTextureImpactOnAnalyticalLights: number;
  48263. /**
  48264. * Stores the alpha values in a texture.
  48265. */
  48266. protected _opacityTexture: Nullable<BaseTexture>;
  48267. /**
  48268. * Stores the reflection values in a texture.
  48269. */
  48270. protected _reflectionTexture: Nullable<BaseTexture>;
  48271. /**
  48272. * Stores the emissive values in a texture.
  48273. */
  48274. protected _emissiveTexture: Nullable<BaseTexture>;
  48275. /**
  48276. * AKA Specular texture in other nomenclature.
  48277. */
  48278. protected _reflectivityTexture: Nullable<BaseTexture>;
  48279. /**
  48280. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48281. */
  48282. protected _metallicTexture: Nullable<BaseTexture>;
  48283. /**
  48284. * Specifies the metallic scalar of the metallic/roughness workflow.
  48285. * Can also be used to scale the metalness values of the metallic texture.
  48286. */
  48287. protected _metallic: Nullable<number>;
  48288. /**
  48289. * Specifies the roughness scalar of the metallic/roughness workflow.
  48290. * Can also be used to scale the roughness values of the metallic texture.
  48291. */
  48292. protected _roughness: Nullable<number>;
  48293. /**
  48294. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48295. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48296. */
  48297. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48298. /**
  48299. * Stores surface normal data used to displace a mesh in a texture.
  48300. */
  48301. protected _bumpTexture: Nullable<BaseTexture>;
  48302. /**
  48303. * Stores the pre-calculated light information of a mesh in a texture.
  48304. */
  48305. protected _lightmapTexture: Nullable<BaseTexture>;
  48306. /**
  48307. * The color of a material in ambient lighting.
  48308. */
  48309. protected _ambientColor: Color3;
  48310. /**
  48311. * AKA Diffuse Color in other nomenclature.
  48312. */
  48313. protected _albedoColor: Color3;
  48314. /**
  48315. * AKA Specular Color in other nomenclature.
  48316. */
  48317. protected _reflectivityColor: Color3;
  48318. /**
  48319. * The color applied when light is reflected from a material.
  48320. */
  48321. protected _reflectionColor: Color3;
  48322. /**
  48323. * The color applied when light is emitted from a material.
  48324. */
  48325. protected _emissiveColor: Color3;
  48326. /**
  48327. * AKA Glossiness in other nomenclature.
  48328. */
  48329. protected _microSurface: number;
  48330. /**
  48331. * Specifies that the material will use the light map as a show map.
  48332. */
  48333. protected _useLightmapAsShadowmap: boolean;
  48334. /**
  48335. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48336. * makes the reflect vector face the model (under horizon).
  48337. */
  48338. protected _useHorizonOcclusion: boolean;
  48339. /**
  48340. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48341. * too much the area relying on ambient texture to define their ambient occlusion.
  48342. */
  48343. protected _useRadianceOcclusion: boolean;
  48344. /**
  48345. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48346. */
  48347. protected _useAlphaFromAlbedoTexture: boolean;
  48348. /**
  48349. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48350. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48351. */
  48352. protected _useSpecularOverAlpha: boolean;
  48353. /**
  48354. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48355. */
  48356. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48357. /**
  48358. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48359. */
  48360. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48361. /**
  48362. * Specifies if the metallic texture contains the roughness information in its green channel.
  48363. */
  48364. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48365. /**
  48366. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48367. */
  48368. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48369. /**
  48370. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48371. */
  48372. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48373. /**
  48374. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48375. */
  48376. protected _useAmbientInGrayScale: boolean;
  48377. /**
  48378. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48379. * The material will try to infer what glossiness each pixel should be.
  48380. */
  48381. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48382. /**
  48383. * Defines the falloff type used in this material.
  48384. * It by default is Physical.
  48385. */
  48386. protected _lightFalloff: number;
  48387. /**
  48388. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48389. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48390. */
  48391. protected _useRadianceOverAlpha: boolean;
  48392. /**
  48393. * Allows using an object space normal map (instead of tangent space).
  48394. */
  48395. protected _useObjectSpaceNormalMap: boolean;
  48396. /**
  48397. * Allows using the bump map in parallax mode.
  48398. */
  48399. protected _useParallax: boolean;
  48400. /**
  48401. * Allows using the bump map in parallax occlusion mode.
  48402. */
  48403. protected _useParallaxOcclusion: boolean;
  48404. /**
  48405. * Controls the scale bias of the parallax mode.
  48406. */
  48407. protected _parallaxScaleBias: number;
  48408. /**
  48409. * If sets to true, disables all the lights affecting the material.
  48410. */
  48411. protected _disableLighting: boolean;
  48412. /**
  48413. * Number of Simultaneous lights allowed on the material.
  48414. */
  48415. protected _maxSimultaneousLights: number;
  48416. /**
  48417. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48418. */
  48419. protected _invertNormalMapX: boolean;
  48420. /**
  48421. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48422. */
  48423. protected _invertNormalMapY: boolean;
  48424. /**
  48425. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48426. */
  48427. protected _twoSidedLighting: boolean;
  48428. /**
  48429. * Defines the alpha limits in alpha test mode.
  48430. */
  48431. protected _alphaCutOff: number;
  48432. /**
  48433. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48434. */
  48435. protected _forceAlphaTest: boolean;
  48436. /**
  48437. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48438. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48439. */
  48440. protected _useAlphaFresnel: boolean;
  48441. /**
  48442. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48443. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48444. */
  48445. protected _useLinearAlphaFresnel: boolean;
  48446. /**
  48447. * The transparency mode of the material.
  48448. */
  48449. protected _transparencyMode: Nullable<number>;
  48450. /**
  48451. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48452. * from cos thetav and roughness:
  48453. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48454. */
  48455. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48456. /**
  48457. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48458. */
  48459. protected _forceIrradianceInFragment: boolean;
  48460. /**
  48461. * Force normal to face away from face.
  48462. */
  48463. protected _forceNormalForward: boolean;
  48464. /**
  48465. * Enables specular anti aliasing in the PBR shader.
  48466. * It will both interacts on the Geometry for analytical and IBL lighting.
  48467. * It also prefilter the roughness map based on the bump values.
  48468. */
  48469. protected _enableSpecularAntiAliasing: boolean;
  48470. /**
  48471. * Default configuration related to image processing available in the PBR Material.
  48472. */
  48473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48474. /**
  48475. * Keep track of the image processing observer to allow dispose and replace.
  48476. */
  48477. private _imageProcessingObserver;
  48478. /**
  48479. * Attaches a new image processing configuration to the PBR Material.
  48480. * @param configuration
  48481. */
  48482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48483. /**
  48484. * Stores the available render targets.
  48485. */
  48486. private _renderTargets;
  48487. /**
  48488. * Sets the global ambient color for the material used in lighting calculations.
  48489. */
  48490. private _globalAmbientColor;
  48491. /**
  48492. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48493. */
  48494. private _useLogarithmicDepth;
  48495. /**
  48496. * If set to true, no lighting calculations will be applied.
  48497. */
  48498. private _unlit;
  48499. private _debugMode;
  48500. /**
  48501. * @hidden
  48502. * This is reserved for the inspector.
  48503. * Defines the material debug mode.
  48504. * It helps seeing only some components of the material while troubleshooting.
  48505. */
  48506. debugMode: number;
  48507. /**
  48508. * @hidden
  48509. * This is reserved for the inspector.
  48510. * Specify from where on screen the debug mode should start.
  48511. * The value goes from -1 (full screen) to 1 (not visible)
  48512. * It helps with side by side comparison against the final render
  48513. * This defaults to -1
  48514. */
  48515. private debugLimit;
  48516. /**
  48517. * @hidden
  48518. * This is reserved for the inspector.
  48519. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48520. * You can use the factor to better multiply the final value.
  48521. */
  48522. private debugFactor;
  48523. /**
  48524. * Defines the clear coat layer parameters for the material.
  48525. */
  48526. readonly clearCoat: PBRClearCoatConfiguration;
  48527. /**
  48528. * Defines the anisotropic parameters for the material.
  48529. */
  48530. readonly anisotropy: PBRAnisotropicConfiguration;
  48531. /**
  48532. * Defines the BRDF parameters for the material.
  48533. */
  48534. readonly brdf: PBRBRDFConfiguration;
  48535. /**
  48536. * Defines the Sheen parameters for the material.
  48537. */
  48538. readonly sheen: PBRSheenConfiguration;
  48539. /**
  48540. * Defines the SubSurface parameters for the material.
  48541. */
  48542. readonly subSurface: PBRSubSurfaceConfiguration;
  48543. /**
  48544. * Custom callback helping to override the default shader used in the material.
  48545. */
  48546. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48547. /**
  48548. * Instantiates a new PBRMaterial instance.
  48549. *
  48550. * @param name The material name
  48551. * @param scene The scene the material will be use in.
  48552. */
  48553. constructor(name: string, scene: Scene);
  48554. /**
  48555. * Gets a boolean indicating that current material needs to register RTT
  48556. */
  48557. readonly hasRenderTargetTextures: boolean;
  48558. /**
  48559. * Gets the name of the material class.
  48560. */
  48561. getClassName(): string;
  48562. /**
  48563. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48564. */
  48565. /**
  48566. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48567. */
  48568. useLogarithmicDepth: boolean;
  48569. /**
  48570. * Gets the current transparency mode.
  48571. */
  48572. /**
  48573. * Sets the transparency mode of the material.
  48574. *
  48575. * | Value | Type | Description |
  48576. * | ----- | ----------------------------------- | ----------- |
  48577. * | 0 | OPAQUE | |
  48578. * | 1 | ALPHATEST | |
  48579. * | 2 | ALPHABLEND | |
  48580. * | 3 | ALPHATESTANDBLEND | |
  48581. *
  48582. */
  48583. transparencyMode: Nullable<number>;
  48584. /**
  48585. * Returns true if alpha blending should be disabled.
  48586. */
  48587. private readonly _disableAlphaBlending;
  48588. /**
  48589. * Specifies whether or not this material should be rendered in alpha blend mode.
  48590. */
  48591. needAlphaBlending(): boolean;
  48592. /**
  48593. * Specifies if the mesh will require alpha blending.
  48594. * @param mesh - BJS mesh.
  48595. */
  48596. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48597. /**
  48598. * Specifies whether or not this material should be rendered in alpha test mode.
  48599. */
  48600. needAlphaTesting(): boolean;
  48601. /**
  48602. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48603. */
  48604. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48605. /**
  48606. * Gets the texture used for the alpha test.
  48607. */
  48608. getAlphaTestTexture(): Nullable<BaseTexture>;
  48609. /**
  48610. * Specifies that the submesh is ready to be used.
  48611. * @param mesh - BJS mesh.
  48612. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48613. * @param useInstances - Specifies that instances should be used.
  48614. * @returns - boolean indicating that the submesh is ready or not.
  48615. */
  48616. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48617. /**
  48618. * Specifies if the material uses metallic roughness workflow.
  48619. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48620. */
  48621. isMetallicWorkflow(): boolean;
  48622. private _prepareEffect;
  48623. private _prepareDefines;
  48624. /**
  48625. * Force shader compilation
  48626. */
  48627. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48628. clipPlane: boolean;
  48629. }>): void;
  48630. /**
  48631. * Initializes the uniform buffer layout for the shader.
  48632. */
  48633. buildUniformLayout(): void;
  48634. /**
  48635. * Unbinds the material from the mesh
  48636. */
  48637. unbind(): void;
  48638. /**
  48639. * Binds the submesh data.
  48640. * @param world - The world matrix.
  48641. * @param mesh - The BJS mesh.
  48642. * @param subMesh - A submesh of the BJS mesh.
  48643. */
  48644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48645. /**
  48646. * Returns the animatable textures.
  48647. * @returns - Array of animatable textures.
  48648. */
  48649. getAnimatables(): IAnimatable[];
  48650. /**
  48651. * Returns the texture used for reflections.
  48652. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48653. */
  48654. private _getReflectionTexture;
  48655. /**
  48656. * Returns an array of the actively used textures.
  48657. * @returns - Array of BaseTextures
  48658. */
  48659. getActiveTextures(): BaseTexture[];
  48660. /**
  48661. * Checks to see if a texture is used in the material.
  48662. * @param texture - Base texture to use.
  48663. * @returns - Boolean specifying if a texture is used in the material.
  48664. */
  48665. hasTexture(texture: BaseTexture): boolean;
  48666. /**
  48667. * Disposes the resources of the material.
  48668. * @param forceDisposeEffect - Forces the disposal of effects.
  48669. * @param forceDisposeTextures - Forces the disposal of all textures.
  48670. */
  48671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48672. }
  48673. }
  48674. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48675. import { Nullable } from "babylonjs/types";
  48676. import { Scene } from "babylonjs/scene";
  48677. import { Color3 } from "babylonjs/Maths/math.color";
  48678. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48679. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48681. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48682. /**
  48683. * The Physically based material of BJS.
  48684. *
  48685. * This offers the main features of a standard PBR material.
  48686. * For more information, please refer to the documentation :
  48687. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48688. */
  48689. export class PBRMaterial extends PBRBaseMaterial {
  48690. /**
  48691. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48692. */
  48693. static readonly PBRMATERIAL_OPAQUE: number;
  48694. /**
  48695. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48696. */
  48697. static readonly PBRMATERIAL_ALPHATEST: number;
  48698. /**
  48699. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48700. */
  48701. static readonly PBRMATERIAL_ALPHABLEND: number;
  48702. /**
  48703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48704. * They are also discarded below the alpha cutoff threshold to improve performances.
  48705. */
  48706. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48707. /**
  48708. * Defines the default value of how much AO map is occluding the analytical lights
  48709. * (point spot...).
  48710. */
  48711. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48712. /**
  48713. * Intensity of the direct lights e.g. the four lights available in your scene.
  48714. * This impacts both the direct diffuse and specular highlights.
  48715. */
  48716. directIntensity: number;
  48717. /**
  48718. * Intensity of the emissive part of the material.
  48719. * This helps controlling the emissive effect without modifying the emissive color.
  48720. */
  48721. emissiveIntensity: number;
  48722. /**
  48723. * Intensity of the environment e.g. how much the environment will light the object
  48724. * either through harmonics for rough material or through the refelction for shiny ones.
  48725. */
  48726. environmentIntensity: number;
  48727. /**
  48728. * This is a special control allowing the reduction of the specular highlights coming from the
  48729. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48730. */
  48731. specularIntensity: number;
  48732. /**
  48733. * Debug Control allowing disabling the bump map on this material.
  48734. */
  48735. disableBumpMap: boolean;
  48736. /**
  48737. * AKA Diffuse Texture in standard nomenclature.
  48738. */
  48739. albedoTexture: BaseTexture;
  48740. /**
  48741. * AKA Occlusion Texture in other nomenclature.
  48742. */
  48743. ambientTexture: BaseTexture;
  48744. /**
  48745. * AKA Occlusion Texture Intensity in other nomenclature.
  48746. */
  48747. ambientTextureStrength: number;
  48748. /**
  48749. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48750. * 1 means it completely occludes it
  48751. * 0 mean it has no impact
  48752. */
  48753. ambientTextureImpactOnAnalyticalLights: number;
  48754. /**
  48755. * Stores the alpha values in a texture.
  48756. */
  48757. opacityTexture: BaseTexture;
  48758. /**
  48759. * Stores the reflection values in a texture.
  48760. */
  48761. reflectionTexture: Nullable<BaseTexture>;
  48762. /**
  48763. * Stores the emissive values in a texture.
  48764. */
  48765. emissiveTexture: BaseTexture;
  48766. /**
  48767. * AKA Specular texture in other nomenclature.
  48768. */
  48769. reflectivityTexture: BaseTexture;
  48770. /**
  48771. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48772. */
  48773. metallicTexture: BaseTexture;
  48774. /**
  48775. * Specifies the metallic scalar of the metallic/roughness workflow.
  48776. * Can also be used to scale the metalness values of the metallic texture.
  48777. */
  48778. metallic: Nullable<number>;
  48779. /**
  48780. * Specifies the roughness scalar of the metallic/roughness workflow.
  48781. * Can also be used to scale the roughness values of the metallic texture.
  48782. */
  48783. roughness: Nullable<number>;
  48784. /**
  48785. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48786. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48787. */
  48788. microSurfaceTexture: BaseTexture;
  48789. /**
  48790. * Stores surface normal data used to displace a mesh in a texture.
  48791. */
  48792. bumpTexture: BaseTexture;
  48793. /**
  48794. * Stores the pre-calculated light information of a mesh in a texture.
  48795. */
  48796. lightmapTexture: BaseTexture;
  48797. /**
  48798. * Stores the refracted light information in a texture.
  48799. */
  48800. refractionTexture: Nullable<BaseTexture>;
  48801. /**
  48802. * The color of a material in ambient lighting.
  48803. */
  48804. ambientColor: Color3;
  48805. /**
  48806. * AKA Diffuse Color in other nomenclature.
  48807. */
  48808. albedoColor: Color3;
  48809. /**
  48810. * AKA Specular Color in other nomenclature.
  48811. */
  48812. reflectivityColor: Color3;
  48813. /**
  48814. * The color reflected from the material.
  48815. */
  48816. reflectionColor: Color3;
  48817. /**
  48818. * The color emitted from the material.
  48819. */
  48820. emissiveColor: Color3;
  48821. /**
  48822. * AKA Glossiness in other nomenclature.
  48823. */
  48824. microSurface: number;
  48825. /**
  48826. * source material index of refraction (IOR)' / 'destination material IOR.
  48827. */
  48828. indexOfRefraction: number;
  48829. /**
  48830. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48831. */
  48832. invertRefractionY: boolean;
  48833. /**
  48834. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48835. * Materials half opaque for instance using refraction could benefit from this control.
  48836. */
  48837. linkRefractionWithTransparency: boolean;
  48838. /**
  48839. * If true, the light map contains occlusion information instead of lighting info.
  48840. */
  48841. useLightmapAsShadowmap: boolean;
  48842. /**
  48843. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48844. */
  48845. useAlphaFromAlbedoTexture: boolean;
  48846. /**
  48847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48848. */
  48849. forceAlphaTest: boolean;
  48850. /**
  48851. * Defines the alpha limits in alpha test mode.
  48852. */
  48853. alphaCutOff: number;
  48854. /**
  48855. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48856. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48857. */
  48858. useSpecularOverAlpha: boolean;
  48859. /**
  48860. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48861. */
  48862. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48863. /**
  48864. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48865. */
  48866. useRoughnessFromMetallicTextureAlpha: boolean;
  48867. /**
  48868. * Specifies if the metallic texture contains the roughness information in its green channel.
  48869. */
  48870. useRoughnessFromMetallicTextureGreen: boolean;
  48871. /**
  48872. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48873. */
  48874. useMetallnessFromMetallicTextureBlue: boolean;
  48875. /**
  48876. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48877. */
  48878. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48879. /**
  48880. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48881. */
  48882. useAmbientInGrayScale: boolean;
  48883. /**
  48884. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48885. * The material will try to infer what glossiness each pixel should be.
  48886. */
  48887. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48888. /**
  48889. * BJS is using an harcoded light falloff based on a manually sets up range.
  48890. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48891. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48892. */
  48893. /**
  48894. * BJS is using an harcoded light falloff based on a manually sets up range.
  48895. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48896. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48897. */
  48898. usePhysicalLightFalloff: boolean;
  48899. /**
  48900. * In order to support the falloff compatibility with gltf, a special mode has been added
  48901. * to reproduce the gltf light falloff.
  48902. */
  48903. /**
  48904. * In order to support the falloff compatibility with gltf, a special mode has been added
  48905. * to reproduce the gltf light falloff.
  48906. */
  48907. useGLTFLightFalloff: boolean;
  48908. /**
  48909. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48910. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48911. */
  48912. useRadianceOverAlpha: boolean;
  48913. /**
  48914. * Allows using an object space normal map (instead of tangent space).
  48915. */
  48916. useObjectSpaceNormalMap: boolean;
  48917. /**
  48918. * Allows using the bump map in parallax mode.
  48919. */
  48920. useParallax: boolean;
  48921. /**
  48922. * Allows using the bump map in parallax occlusion mode.
  48923. */
  48924. useParallaxOcclusion: boolean;
  48925. /**
  48926. * Controls the scale bias of the parallax mode.
  48927. */
  48928. parallaxScaleBias: number;
  48929. /**
  48930. * If sets to true, disables all the lights affecting the material.
  48931. */
  48932. disableLighting: boolean;
  48933. /**
  48934. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48935. */
  48936. forceIrradianceInFragment: boolean;
  48937. /**
  48938. * Number of Simultaneous lights allowed on the material.
  48939. */
  48940. maxSimultaneousLights: number;
  48941. /**
  48942. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48943. */
  48944. invertNormalMapX: boolean;
  48945. /**
  48946. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48947. */
  48948. invertNormalMapY: boolean;
  48949. /**
  48950. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48951. */
  48952. twoSidedLighting: boolean;
  48953. /**
  48954. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48955. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48956. */
  48957. useAlphaFresnel: boolean;
  48958. /**
  48959. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48960. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48961. */
  48962. useLinearAlphaFresnel: boolean;
  48963. /**
  48964. * Let user defines the brdf lookup texture used for IBL.
  48965. * A default 8bit version is embedded but you could point at :
  48966. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48967. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48968. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48969. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48970. */
  48971. environmentBRDFTexture: Nullable<BaseTexture>;
  48972. /**
  48973. * Force normal to face away from face.
  48974. */
  48975. forceNormalForward: boolean;
  48976. /**
  48977. * Enables specular anti aliasing in the PBR shader.
  48978. * It will both interacts on the Geometry for analytical and IBL lighting.
  48979. * It also prefilter the roughness map based on the bump values.
  48980. */
  48981. enableSpecularAntiAliasing: boolean;
  48982. /**
  48983. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48984. * makes the reflect vector face the model (under horizon).
  48985. */
  48986. useHorizonOcclusion: boolean;
  48987. /**
  48988. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48989. * too much the area relying on ambient texture to define their ambient occlusion.
  48990. */
  48991. useRadianceOcclusion: boolean;
  48992. /**
  48993. * If set to true, no lighting calculations will be applied.
  48994. */
  48995. unlit: boolean;
  48996. /**
  48997. * Gets the image processing configuration used either in this material.
  48998. */
  48999. /**
  49000. * Sets the Default image processing configuration used either in the this material.
  49001. *
  49002. * If sets to null, the scene one is in use.
  49003. */
  49004. imageProcessingConfiguration: ImageProcessingConfiguration;
  49005. /**
  49006. * Gets wether the color curves effect is enabled.
  49007. */
  49008. /**
  49009. * Sets wether the color curves effect is enabled.
  49010. */
  49011. cameraColorCurvesEnabled: boolean;
  49012. /**
  49013. * Gets wether the color grading effect is enabled.
  49014. */
  49015. /**
  49016. * Gets wether the color grading effect is enabled.
  49017. */
  49018. cameraColorGradingEnabled: boolean;
  49019. /**
  49020. * Gets wether tonemapping is enabled or not.
  49021. */
  49022. /**
  49023. * Sets wether tonemapping is enabled or not
  49024. */
  49025. cameraToneMappingEnabled: boolean;
  49026. /**
  49027. * The camera exposure used on this material.
  49028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49029. * This corresponds to a photographic exposure.
  49030. */
  49031. /**
  49032. * The camera exposure used on this material.
  49033. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49034. * This corresponds to a photographic exposure.
  49035. */
  49036. cameraExposure: number;
  49037. /**
  49038. * Gets The camera contrast used on this material.
  49039. */
  49040. /**
  49041. * Sets The camera contrast used on this material.
  49042. */
  49043. cameraContrast: number;
  49044. /**
  49045. * Gets the Color Grading 2D Lookup Texture.
  49046. */
  49047. /**
  49048. * Sets the Color Grading 2D Lookup Texture.
  49049. */
  49050. cameraColorGradingTexture: Nullable<BaseTexture>;
  49051. /**
  49052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49054. * 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;
  49055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49056. */
  49057. /**
  49058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49060. * 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;
  49061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49062. */
  49063. cameraColorCurves: Nullable<ColorCurves>;
  49064. /**
  49065. * Instantiates a new PBRMaterial instance.
  49066. *
  49067. * @param name The material name
  49068. * @param scene The scene the material will be use in.
  49069. */
  49070. constructor(name: string, scene: Scene);
  49071. /**
  49072. * Returns the name of this material class.
  49073. */
  49074. getClassName(): string;
  49075. /**
  49076. * Makes a duplicate of the current material.
  49077. * @param name - name to use for the new material.
  49078. */
  49079. clone(name: string): PBRMaterial;
  49080. /**
  49081. * Serializes this PBR Material.
  49082. * @returns - An object with the serialized material.
  49083. */
  49084. serialize(): any;
  49085. /**
  49086. * Parses a PBR Material from a serialized object.
  49087. * @param source - Serialized object.
  49088. * @param scene - BJS scene instance.
  49089. * @param rootUrl - url for the scene object
  49090. * @returns - PBRMaterial
  49091. */
  49092. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49093. }
  49094. }
  49095. declare module "babylonjs/Misc/dds" {
  49096. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49097. import { Engine } from "babylonjs/Engines/engine";
  49098. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49099. import { Nullable } from "babylonjs/types";
  49100. import { Scene } from "babylonjs/scene";
  49101. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49102. /**
  49103. * Direct draw surface info
  49104. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49105. */
  49106. export interface DDSInfo {
  49107. /**
  49108. * Width of the texture
  49109. */
  49110. width: number;
  49111. /**
  49112. * Width of the texture
  49113. */
  49114. height: number;
  49115. /**
  49116. * Number of Mipmaps for the texture
  49117. * @see https://en.wikipedia.org/wiki/Mipmap
  49118. */
  49119. mipmapCount: number;
  49120. /**
  49121. * If the textures format is a known fourCC format
  49122. * @see https://www.fourcc.org/
  49123. */
  49124. isFourCC: boolean;
  49125. /**
  49126. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49127. */
  49128. isRGB: boolean;
  49129. /**
  49130. * If the texture is a lumincance format
  49131. */
  49132. isLuminance: boolean;
  49133. /**
  49134. * If this is a cube texture
  49135. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49136. */
  49137. isCube: boolean;
  49138. /**
  49139. * If the texture is a compressed format eg. FOURCC_DXT1
  49140. */
  49141. isCompressed: boolean;
  49142. /**
  49143. * The dxgiFormat of the texture
  49144. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49145. */
  49146. dxgiFormat: number;
  49147. /**
  49148. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49149. */
  49150. textureType: number;
  49151. /**
  49152. * Sphericle polynomial created for the dds texture
  49153. */
  49154. sphericalPolynomial?: SphericalPolynomial;
  49155. }
  49156. /**
  49157. * Class used to provide DDS decompression tools
  49158. */
  49159. export class DDSTools {
  49160. /**
  49161. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49162. */
  49163. static StoreLODInAlphaChannel: boolean;
  49164. /**
  49165. * Gets DDS information from an array buffer
  49166. * @param arrayBuffer defines the array buffer to read data from
  49167. * @returns the DDS information
  49168. */
  49169. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49170. private static _FloatView;
  49171. private static _Int32View;
  49172. private static _ToHalfFloat;
  49173. private static _FromHalfFloat;
  49174. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49175. private static _GetHalfFloatRGBAArrayBuffer;
  49176. private static _GetFloatRGBAArrayBuffer;
  49177. private static _GetFloatAsUIntRGBAArrayBuffer;
  49178. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49179. private static _GetRGBAArrayBuffer;
  49180. private static _ExtractLongWordOrder;
  49181. private static _GetRGBArrayBuffer;
  49182. private static _GetLuminanceArrayBuffer;
  49183. /**
  49184. * Uploads DDS Levels to a Babylon Texture
  49185. * @hidden
  49186. */
  49187. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49188. }
  49189. module "babylonjs/Engines/engine" {
  49190. interface Engine {
  49191. /**
  49192. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49193. * @param rootUrl defines the url where the file to load is located
  49194. * @param scene defines the current scene
  49195. * @param lodScale defines scale to apply to the mip map selection
  49196. * @param lodOffset defines offset to apply to the mip map selection
  49197. * @param onLoad defines an optional callback raised when the texture is loaded
  49198. * @param onError defines an optional callback raised if there is an issue to load the texture
  49199. * @param format defines the format of the data
  49200. * @param forcedExtension defines the extension to use to pick the right loader
  49201. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49202. * @returns the cube texture as an InternalTexture
  49203. */
  49204. 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;
  49205. }
  49206. }
  49207. }
  49208. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49209. import { Nullable } from "babylonjs/types";
  49210. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49211. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49212. /**
  49213. * Implementation of the DDS Texture Loader.
  49214. * @hidden
  49215. */
  49216. export class _DDSTextureLoader implements IInternalTextureLoader {
  49217. /**
  49218. * Defines wether the loader supports cascade loading the different faces.
  49219. */
  49220. readonly supportCascades: boolean;
  49221. /**
  49222. * This returns if the loader support the current file information.
  49223. * @param extension defines the file extension of the file being loaded
  49224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49225. * @param fallback defines the fallback internal texture if any
  49226. * @param isBase64 defines whether the texture is encoded as a base64
  49227. * @param isBuffer defines whether the texture data are stored as a buffer
  49228. * @returns true if the loader can load the specified file
  49229. */
  49230. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49231. /**
  49232. * Transform the url before loading if required.
  49233. * @param rootUrl the url of the texture
  49234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49235. * @returns the transformed texture
  49236. */
  49237. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49238. /**
  49239. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49240. * @param rootUrl the url of the texture
  49241. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49242. * @returns the fallback texture
  49243. */
  49244. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49245. /**
  49246. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49247. * @param data contains the texture data
  49248. * @param texture defines the BabylonJS internal texture
  49249. * @param createPolynomials will be true if polynomials have been requested
  49250. * @param onLoad defines the callback to trigger once the texture is ready
  49251. * @param onError defines the callback to trigger in case of error
  49252. */
  49253. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49254. /**
  49255. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49256. * @param data contains the texture data
  49257. * @param texture defines the BabylonJS internal texture
  49258. * @param callback defines the method to call once ready to upload
  49259. */
  49260. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49261. }
  49262. }
  49263. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49264. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49265. /** @hidden */
  49266. export var rgbdEncodePixelShader: {
  49267. name: string;
  49268. shader: string;
  49269. };
  49270. }
  49271. declare module "babylonjs/Misc/environmentTextureTools" {
  49272. import { Nullable } from "babylonjs/types";
  49273. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49274. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49275. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49276. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49277. import "babylonjs/Shaders/rgbdEncode.fragment";
  49278. import "babylonjs/Shaders/rgbdDecode.fragment";
  49279. /**
  49280. * Raw texture data and descriptor sufficient for WebGL texture upload
  49281. */
  49282. export interface EnvironmentTextureInfo {
  49283. /**
  49284. * Version of the environment map
  49285. */
  49286. version: number;
  49287. /**
  49288. * Width of image
  49289. */
  49290. width: number;
  49291. /**
  49292. * Irradiance information stored in the file.
  49293. */
  49294. irradiance: any;
  49295. /**
  49296. * Specular information stored in the file.
  49297. */
  49298. specular: any;
  49299. }
  49300. /**
  49301. * Sets of helpers addressing the serialization and deserialization of environment texture
  49302. * stored in a BabylonJS env file.
  49303. * Those files are usually stored as .env files.
  49304. */
  49305. export class EnvironmentTextureTools {
  49306. /**
  49307. * Magic number identifying the env file.
  49308. */
  49309. private static _MagicBytes;
  49310. /**
  49311. * Gets the environment info from an env file.
  49312. * @param data The array buffer containing the .env bytes.
  49313. * @returns the environment file info (the json header) if successfully parsed.
  49314. */
  49315. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49316. /**
  49317. * Creates an environment texture from a loaded cube texture.
  49318. * @param texture defines the cube texture to convert in env file
  49319. * @return a promise containing the environment data if succesfull.
  49320. */
  49321. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49322. /**
  49323. * Creates a JSON representation of the spherical data.
  49324. * @param texture defines the texture containing the polynomials
  49325. * @return the JSON representation of the spherical info
  49326. */
  49327. private static _CreateEnvTextureIrradiance;
  49328. /**
  49329. * Uploads the texture info contained in the env file to the GPU.
  49330. * @param texture defines the internal texture to upload to
  49331. * @param arrayBuffer defines the buffer cotaining the data to load
  49332. * @param info defines the texture info retrieved through the GetEnvInfo method
  49333. * @returns a promise
  49334. */
  49335. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49336. /**
  49337. * Uploads the levels of image data to the GPU.
  49338. * @param texture defines the internal texture to upload to
  49339. * @param imageData defines the array buffer views of image data [mipmap][face]
  49340. * @returns a promise
  49341. */
  49342. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49343. /**
  49344. * Uploads spherical polynomials information to the texture.
  49345. * @param texture defines the texture we are trying to upload the information to
  49346. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49347. */
  49348. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49349. /** @hidden */
  49350. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49351. }
  49352. }
  49353. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49354. import { Nullable } from "babylonjs/types";
  49355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49356. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49357. /**
  49358. * Implementation of the ENV Texture Loader.
  49359. * @hidden
  49360. */
  49361. export class _ENVTextureLoader implements IInternalTextureLoader {
  49362. /**
  49363. * Defines wether the loader supports cascade loading the different faces.
  49364. */
  49365. readonly supportCascades: boolean;
  49366. /**
  49367. * This returns if the loader support the current file information.
  49368. * @param extension defines the file extension of the file being loaded
  49369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49370. * @param fallback defines the fallback internal texture if any
  49371. * @param isBase64 defines whether the texture is encoded as a base64
  49372. * @param isBuffer defines whether the texture data are stored as a buffer
  49373. * @returns true if the loader can load the specified file
  49374. */
  49375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49376. /**
  49377. * Transform the url before loading if required.
  49378. * @param rootUrl the url of the texture
  49379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49380. * @returns the transformed texture
  49381. */
  49382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49383. /**
  49384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49385. * @param rootUrl the url of the texture
  49386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49387. * @returns the fallback texture
  49388. */
  49389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49390. /**
  49391. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49392. * @param data contains the texture data
  49393. * @param texture defines the BabylonJS internal texture
  49394. * @param createPolynomials will be true if polynomials have been requested
  49395. * @param onLoad defines the callback to trigger once the texture is ready
  49396. * @param onError defines the callback to trigger in case of error
  49397. */
  49398. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49399. /**
  49400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49401. * @param data contains the texture data
  49402. * @param texture defines the BabylonJS internal texture
  49403. * @param callback defines the method to call once ready to upload
  49404. */
  49405. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49406. }
  49407. }
  49408. declare module "babylonjs/Misc/khronosTextureContainer" {
  49409. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49410. /**
  49411. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49412. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49413. */
  49414. export class KhronosTextureContainer {
  49415. /** contents of the KTX container file */
  49416. arrayBuffer: any;
  49417. private static HEADER_LEN;
  49418. private static COMPRESSED_2D;
  49419. private static COMPRESSED_3D;
  49420. private static TEX_2D;
  49421. private static TEX_3D;
  49422. /**
  49423. * Gets the openGL type
  49424. */
  49425. glType: number;
  49426. /**
  49427. * Gets the openGL type size
  49428. */
  49429. glTypeSize: number;
  49430. /**
  49431. * Gets the openGL format
  49432. */
  49433. glFormat: number;
  49434. /**
  49435. * Gets the openGL internal format
  49436. */
  49437. glInternalFormat: number;
  49438. /**
  49439. * Gets the base internal format
  49440. */
  49441. glBaseInternalFormat: number;
  49442. /**
  49443. * Gets image width in pixel
  49444. */
  49445. pixelWidth: number;
  49446. /**
  49447. * Gets image height in pixel
  49448. */
  49449. pixelHeight: number;
  49450. /**
  49451. * Gets image depth in pixels
  49452. */
  49453. pixelDepth: number;
  49454. /**
  49455. * Gets the number of array elements
  49456. */
  49457. numberOfArrayElements: number;
  49458. /**
  49459. * Gets the number of faces
  49460. */
  49461. numberOfFaces: number;
  49462. /**
  49463. * Gets the number of mipmap levels
  49464. */
  49465. numberOfMipmapLevels: number;
  49466. /**
  49467. * Gets the bytes of key value data
  49468. */
  49469. bytesOfKeyValueData: number;
  49470. /**
  49471. * Gets the load type
  49472. */
  49473. loadType: number;
  49474. /**
  49475. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49476. */
  49477. isInvalid: boolean;
  49478. /**
  49479. * Creates a new KhronosTextureContainer
  49480. * @param arrayBuffer contents of the KTX container file
  49481. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49482. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49483. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49484. */
  49485. constructor(
  49486. /** contents of the KTX container file */
  49487. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49488. /**
  49489. * Uploads KTX content to a Babylon Texture.
  49490. * It is assumed that the texture has already been created & is currently bound
  49491. * @hidden
  49492. */
  49493. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49494. private _upload2DCompressedLevels;
  49495. }
  49496. }
  49497. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49498. import { Nullable } from "babylonjs/types";
  49499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49500. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49501. /**
  49502. * Implementation of the KTX Texture Loader.
  49503. * @hidden
  49504. */
  49505. export class _KTXTextureLoader implements IInternalTextureLoader {
  49506. /**
  49507. * Defines wether the loader supports cascade loading the different faces.
  49508. */
  49509. readonly supportCascades: boolean;
  49510. /**
  49511. * This returns if the loader support the current file information.
  49512. * @param extension defines the file extension of the file being loaded
  49513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49514. * @param fallback defines the fallback internal texture if any
  49515. * @param isBase64 defines whether the texture is encoded as a base64
  49516. * @param isBuffer defines whether the texture data are stored as a buffer
  49517. * @returns true if the loader can load the specified file
  49518. */
  49519. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49520. /**
  49521. * Transform the url before loading if required.
  49522. * @param rootUrl the url of the texture
  49523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49524. * @returns the transformed texture
  49525. */
  49526. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49527. /**
  49528. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49529. * @param rootUrl the url of the texture
  49530. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49531. * @returns the fallback texture
  49532. */
  49533. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49534. /**
  49535. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49536. * @param data contains the texture data
  49537. * @param texture defines the BabylonJS internal texture
  49538. * @param createPolynomials will be true if polynomials have been requested
  49539. * @param onLoad defines the callback to trigger once the texture is ready
  49540. * @param onError defines the callback to trigger in case of error
  49541. */
  49542. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49543. /**
  49544. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49545. * @param data contains the texture data
  49546. * @param texture defines the BabylonJS internal texture
  49547. * @param callback defines the method to call once ready to upload
  49548. */
  49549. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49550. }
  49551. }
  49552. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49553. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49554. import { Scene } from "babylonjs/scene";
  49555. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49556. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49557. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49558. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49559. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49560. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49562. /**
  49563. * Options for the default xr helper
  49564. */
  49565. export class WebXRDefaultExperienceOptions {
  49566. /**
  49567. * Floor meshes that should be used for teleporting
  49568. */
  49569. floorMeshes: Array<AbstractMesh>;
  49570. }
  49571. /**
  49572. * Default experience which provides a similar setup to the previous webVRExperience
  49573. */
  49574. export class WebXRDefaultExperience {
  49575. /**
  49576. * Base experience
  49577. */
  49578. baseExperience: WebXRExperienceHelper;
  49579. /**
  49580. * Input experience extension
  49581. */
  49582. input: WebXRInput;
  49583. /**
  49584. * Loads the controller models
  49585. */
  49586. controllerModelLoader: WebXRControllerModelLoader;
  49587. /**
  49588. * Enables laser pointer and selection
  49589. */
  49590. pointerSelection: WebXRControllerPointerSelection;
  49591. /**
  49592. * Enables teleportation
  49593. */
  49594. teleportation: WebXRControllerTeleportation;
  49595. /**
  49596. * Enables ui for enetering/exiting xr
  49597. */
  49598. enterExitUI: WebXREnterExitUI;
  49599. /**
  49600. * Default output canvas xr should render to
  49601. */
  49602. outputCanvas: WebXRManagedOutputCanvas;
  49603. /**
  49604. * Creates the default xr experience
  49605. * @param scene scene
  49606. * @param options options for basic configuration
  49607. * @returns resulting WebXRDefaultExperience
  49608. */
  49609. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49610. private constructor();
  49611. /**
  49612. * DIsposes of the experience helper
  49613. */
  49614. dispose(): void;
  49615. }
  49616. }
  49617. declare module "babylonjs/Helpers/sceneHelpers" {
  49618. import { Nullable } from "babylonjs/types";
  49619. import { Mesh } from "babylonjs/Meshes/mesh";
  49620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49621. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49622. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49623. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49624. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49625. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49626. import "babylonjs/Meshes/Builders/boxBuilder";
  49627. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49628. /** @hidden */
  49629. export var _forceSceneHelpersToBundle: boolean;
  49630. module "babylonjs/scene" {
  49631. interface Scene {
  49632. /**
  49633. * Creates a default light for the scene.
  49634. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49635. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49636. */
  49637. createDefaultLight(replace?: boolean): void;
  49638. /**
  49639. * Creates a default camera for the scene.
  49640. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49641. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49642. * @param replace has default false, when true replaces the active camera in the scene
  49643. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49644. */
  49645. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49646. /**
  49647. * Creates a default camera and a default light.
  49648. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49649. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49650. * @param replace has the default false, when true replaces the active camera/light in the scene
  49651. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49652. */
  49653. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49654. /**
  49655. * Creates a new sky box
  49656. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49657. * @param environmentTexture defines the texture to use as environment texture
  49658. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49659. * @param scale defines the overall scale of the skybox
  49660. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49661. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49662. * @returns a new mesh holding the sky box
  49663. */
  49664. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49665. /**
  49666. * Creates a new environment
  49667. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49668. * @param options defines the options you can use to configure the environment
  49669. * @returns the new EnvironmentHelper
  49670. */
  49671. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49672. /**
  49673. * Creates a new VREXperienceHelper
  49674. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49675. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49676. * @returns a new VREXperienceHelper
  49677. */
  49678. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49679. /**
  49680. * Creates a new WebXRDefaultExperience
  49681. * @see http://doc.babylonjs.com/how_to/webxr
  49682. * @param options experience options
  49683. * @returns a promise for a new WebXRDefaultExperience
  49684. */
  49685. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49686. }
  49687. }
  49688. }
  49689. declare module "babylonjs/Helpers/videoDome" {
  49690. import { Scene } from "babylonjs/scene";
  49691. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49692. import { Mesh } from "babylonjs/Meshes/mesh";
  49693. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49694. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49695. import "babylonjs/Meshes/Builders/sphereBuilder";
  49696. /**
  49697. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49698. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49699. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49700. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49701. */
  49702. export class VideoDome extends TransformNode {
  49703. /**
  49704. * Define the video source as a Monoscopic panoramic 360 video.
  49705. */
  49706. static readonly MODE_MONOSCOPIC: number;
  49707. /**
  49708. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49709. */
  49710. static readonly MODE_TOPBOTTOM: number;
  49711. /**
  49712. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49713. */
  49714. static readonly MODE_SIDEBYSIDE: number;
  49715. private _useDirectMapping;
  49716. /**
  49717. * The video texture being displayed on the sphere
  49718. */
  49719. protected _videoTexture: VideoTexture;
  49720. /**
  49721. * Gets the video texture being displayed on the sphere
  49722. */
  49723. readonly videoTexture: VideoTexture;
  49724. /**
  49725. * The skybox material
  49726. */
  49727. protected _material: BackgroundMaterial;
  49728. /**
  49729. * The surface used for the skybox
  49730. */
  49731. protected _mesh: Mesh;
  49732. /**
  49733. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49734. * Also see the options.resolution property.
  49735. */
  49736. fovMultiplier: number;
  49737. private _videoMode;
  49738. /**
  49739. * Gets or set the current video mode for the video. It can be:
  49740. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49741. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49742. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49743. */
  49744. videoMode: number;
  49745. /**
  49746. * Oberserver used in Stereoscopic VR Mode.
  49747. */
  49748. private _onBeforeCameraRenderObserver;
  49749. /**
  49750. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49751. * @param name Element's name, child elements will append suffixes for their own names.
  49752. * @param urlsOrVideo defines the url(s) or the video element to use
  49753. * @param options An object containing optional or exposed sub element properties
  49754. */
  49755. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49756. resolution?: number;
  49757. clickToPlay?: boolean;
  49758. autoPlay?: boolean;
  49759. loop?: boolean;
  49760. size?: number;
  49761. poster?: string;
  49762. faceForward?: boolean;
  49763. useDirectMapping?: boolean;
  49764. }, scene: Scene);
  49765. private _changeVideoMode;
  49766. /**
  49767. * Releases resources associated with this node.
  49768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49770. */
  49771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49772. }
  49773. }
  49774. declare module "babylonjs/Helpers/index" {
  49775. export * from "babylonjs/Helpers/environmentHelper";
  49776. export * from "babylonjs/Helpers/photoDome";
  49777. export * from "babylonjs/Helpers/sceneHelpers";
  49778. export * from "babylonjs/Helpers/videoDome";
  49779. }
  49780. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49781. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49782. import { IDisposable } from "babylonjs/scene";
  49783. import { Engine } from "babylonjs/Engines/engine";
  49784. /**
  49785. * This class can be used to get instrumentation data from a Babylon engine
  49786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49787. */
  49788. export class EngineInstrumentation implements IDisposable {
  49789. /**
  49790. * Define the instrumented engine.
  49791. */
  49792. engine: Engine;
  49793. private _captureGPUFrameTime;
  49794. private _gpuFrameTimeToken;
  49795. private _gpuFrameTime;
  49796. private _captureShaderCompilationTime;
  49797. private _shaderCompilationTime;
  49798. private _onBeginFrameObserver;
  49799. private _onEndFrameObserver;
  49800. private _onBeforeShaderCompilationObserver;
  49801. private _onAfterShaderCompilationObserver;
  49802. /**
  49803. * Gets the perf counter used for GPU frame time
  49804. */
  49805. readonly gpuFrameTimeCounter: PerfCounter;
  49806. /**
  49807. * Gets the GPU frame time capture status
  49808. */
  49809. /**
  49810. * Enable or disable the GPU frame time capture
  49811. */
  49812. captureGPUFrameTime: boolean;
  49813. /**
  49814. * Gets the perf counter used for shader compilation time
  49815. */
  49816. readonly shaderCompilationTimeCounter: PerfCounter;
  49817. /**
  49818. * Gets the shader compilation time capture status
  49819. */
  49820. /**
  49821. * Enable or disable the shader compilation time capture
  49822. */
  49823. captureShaderCompilationTime: boolean;
  49824. /**
  49825. * Instantiates a new engine instrumentation.
  49826. * This class can be used to get instrumentation data from a Babylon engine
  49827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49828. * @param engine Defines the engine to instrument
  49829. */
  49830. constructor(
  49831. /**
  49832. * Define the instrumented engine.
  49833. */
  49834. engine: Engine);
  49835. /**
  49836. * Dispose and release associated resources.
  49837. */
  49838. dispose(): void;
  49839. }
  49840. }
  49841. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49842. import { Scene, IDisposable } from "babylonjs/scene";
  49843. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49844. /**
  49845. * This class can be used to get instrumentation data from a Babylon engine
  49846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49847. */
  49848. export class SceneInstrumentation implements IDisposable {
  49849. /**
  49850. * Defines the scene to instrument
  49851. */
  49852. scene: Scene;
  49853. private _captureActiveMeshesEvaluationTime;
  49854. private _activeMeshesEvaluationTime;
  49855. private _captureRenderTargetsRenderTime;
  49856. private _renderTargetsRenderTime;
  49857. private _captureFrameTime;
  49858. private _frameTime;
  49859. private _captureRenderTime;
  49860. private _renderTime;
  49861. private _captureInterFrameTime;
  49862. private _interFrameTime;
  49863. private _captureParticlesRenderTime;
  49864. private _particlesRenderTime;
  49865. private _captureSpritesRenderTime;
  49866. private _spritesRenderTime;
  49867. private _capturePhysicsTime;
  49868. private _physicsTime;
  49869. private _captureAnimationsTime;
  49870. private _animationsTime;
  49871. private _captureCameraRenderTime;
  49872. private _cameraRenderTime;
  49873. private _onBeforeActiveMeshesEvaluationObserver;
  49874. private _onAfterActiveMeshesEvaluationObserver;
  49875. private _onBeforeRenderTargetsRenderObserver;
  49876. private _onAfterRenderTargetsRenderObserver;
  49877. private _onAfterRenderObserver;
  49878. private _onBeforeDrawPhaseObserver;
  49879. private _onAfterDrawPhaseObserver;
  49880. private _onBeforeAnimationsObserver;
  49881. private _onBeforeParticlesRenderingObserver;
  49882. private _onAfterParticlesRenderingObserver;
  49883. private _onBeforeSpritesRenderingObserver;
  49884. private _onAfterSpritesRenderingObserver;
  49885. private _onBeforePhysicsObserver;
  49886. private _onAfterPhysicsObserver;
  49887. private _onAfterAnimationsObserver;
  49888. private _onBeforeCameraRenderObserver;
  49889. private _onAfterCameraRenderObserver;
  49890. /**
  49891. * Gets the perf counter used for active meshes evaluation time
  49892. */
  49893. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49894. /**
  49895. * Gets the active meshes evaluation time capture status
  49896. */
  49897. /**
  49898. * Enable or disable the active meshes evaluation time capture
  49899. */
  49900. captureActiveMeshesEvaluationTime: boolean;
  49901. /**
  49902. * Gets the perf counter used for render targets render time
  49903. */
  49904. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49905. /**
  49906. * Gets the render targets render time capture status
  49907. */
  49908. /**
  49909. * Enable or disable the render targets render time capture
  49910. */
  49911. captureRenderTargetsRenderTime: boolean;
  49912. /**
  49913. * Gets the perf counter used for particles render time
  49914. */
  49915. readonly particlesRenderTimeCounter: PerfCounter;
  49916. /**
  49917. * Gets the particles render time capture status
  49918. */
  49919. /**
  49920. * Enable or disable the particles render time capture
  49921. */
  49922. captureParticlesRenderTime: boolean;
  49923. /**
  49924. * Gets the perf counter used for sprites render time
  49925. */
  49926. readonly spritesRenderTimeCounter: PerfCounter;
  49927. /**
  49928. * Gets the sprites render time capture status
  49929. */
  49930. /**
  49931. * Enable or disable the sprites render time capture
  49932. */
  49933. captureSpritesRenderTime: boolean;
  49934. /**
  49935. * Gets the perf counter used for physics time
  49936. */
  49937. readonly physicsTimeCounter: PerfCounter;
  49938. /**
  49939. * Gets the physics time capture status
  49940. */
  49941. /**
  49942. * Enable or disable the physics time capture
  49943. */
  49944. capturePhysicsTime: boolean;
  49945. /**
  49946. * Gets the perf counter used for animations time
  49947. */
  49948. readonly animationsTimeCounter: PerfCounter;
  49949. /**
  49950. * Gets the animations time capture status
  49951. */
  49952. /**
  49953. * Enable or disable the animations time capture
  49954. */
  49955. captureAnimationsTime: boolean;
  49956. /**
  49957. * Gets the perf counter used for frame time capture
  49958. */
  49959. readonly frameTimeCounter: PerfCounter;
  49960. /**
  49961. * Gets the frame time capture status
  49962. */
  49963. /**
  49964. * Enable or disable the frame time capture
  49965. */
  49966. captureFrameTime: boolean;
  49967. /**
  49968. * Gets the perf counter used for inter-frames time capture
  49969. */
  49970. readonly interFrameTimeCounter: PerfCounter;
  49971. /**
  49972. * Gets the inter-frames time capture status
  49973. */
  49974. /**
  49975. * Enable or disable the inter-frames time capture
  49976. */
  49977. captureInterFrameTime: boolean;
  49978. /**
  49979. * Gets the perf counter used for render time capture
  49980. */
  49981. readonly renderTimeCounter: PerfCounter;
  49982. /**
  49983. * Gets the render time capture status
  49984. */
  49985. /**
  49986. * Enable or disable the render time capture
  49987. */
  49988. captureRenderTime: boolean;
  49989. /**
  49990. * Gets the perf counter used for camera render time capture
  49991. */
  49992. readonly cameraRenderTimeCounter: PerfCounter;
  49993. /**
  49994. * Gets the camera render time capture status
  49995. */
  49996. /**
  49997. * Enable or disable the camera render time capture
  49998. */
  49999. captureCameraRenderTime: boolean;
  50000. /**
  50001. * Gets the perf counter used for draw calls
  50002. */
  50003. readonly drawCallsCounter: PerfCounter;
  50004. /**
  50005. * Instantiates a new scene instrumentation.
  50006. * This class can be used to get instrumentation data from a Babylon engine
  50007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50008. * @param scene Defines the scene to instrument
  50009. */
  50010. constructor(
  50011. /**
  50012. * Defines the scene to instrument
  50013. */
  50014. scene: Scene);
  50015. /**
  50016. * Dispose and release associated resources.
  50017. */
  50018. dispose(): void;
  50019. }
  50020. }
  50021. declare module "babylonjs/Instrumentation/index" {
  50022. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50023. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50024. export * from "babylonjs/Instrumentation/timeToken";
  50025. }
  50026. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50027. /** @hidden */
  50028. export var glowMapGenerationPixelShader: {
  50029. name: string;
  50030. shader: string;
  50031. };
  50032. }
  50033. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50034. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50037. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50038. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50039. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50040. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50041. /** @hidden */
  50042. export var glowMapGenerationVertexShader: {
  50043. name: string;
  50044. shader: string;
  50045. };
  50046. }
  50047. declare module "babylonjs/Layers/effectLayer" {
  50048. import { Observable } from "babylonjs/Misc/observable";
  50049. import { Nullable } from "babylonjs/types";
  50050. import { Camera } from "babylonjs/Cameras/camera";
  50051. import { Scene } from "babylonjs/scene";
  50052. import { ISize } from "babylonjs/Maths/math.size";
  50053. import { Color4 } from "babylonjs/Maths/math.color";
  50054. import { Engine } from "babylonjs/Engines/engine";
  50055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50057. import { Mesh } from "babylonjs/Meshes/mesh";
  50058. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50061. import { Effect } from "babylonjs/Materials/effect";
  50062. import { Material } from "babylonjs/Materials/material";
  50063. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50064. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50065. /**
  50066. * Effect layer options. This helps customizing the behaviour
  50067. * of the effect layer.
  50068. */
  50069. export interface IEffectLayerOptions {
  50070. /**
  50071. * Multiplication factor apply to the canvas size to compute the render target size
  50072. * used to generated the objects (the smaller the faster).
  50073. */
  50074. mainTextureRatio: number;
  50075. /**
  50076. * Enforces a fixed size texture to ensure effect stability across devices.
  50077. */
  50078. mainTextureFixedSize?: number;
  50079. /**
  50080. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50081. */
  50082. alphaBlendingMode: number;
  50083. /**
  50084. * The camera attached to the layer.
  50085. */
  50086. camera: Nullable<Camera>;
  50087. /**
  50088. * The rendering group to draw the layer in.
  50089. */
  50090. renderingGroupId: number;
  50091. }
  50092. /**
  50093. * The effect layer Helps adding post process effect blended with the main pass.
  50094. *
  50095. * This can be for instance use to generate glow or higlight effects on the scene.
  50096. *
  50097. * The effect layer class can not be used directly and is intented to inherited from to be
  50098. * customized per effects.
  50099. */
  50100. export abstract class EffectLayer {
  50101. private _vertexBuffers;
  50102. private _indexBuffer;
  50103. private _cachedDefines;
  50104. private _effectLayerMapGenerationEffect;
  50105. private _effectLayerOptions;
  50106. private _mergeEffect;
  50107. protected _scene: Scene;
  50108. protected _engine: Engine;
  50109. protected _maxSize: number;
  50110. protected _mainTextureDesiredSize: ISize;
  50111. protected _mainTexture: RenderTargetTexture;
  50112. protected _shouldRender: boolean;
  50113. protected _postProcesses: PostProcess[];
  50114. protected _textures: BaseTexture[];
  50115. protected _emissiveTextureAndColor: {
  50116. texture: Nullable<BaseTexture>;
  50117. color: Color4;
  50118. };
  50119. /**
  50120. * The name of the layer
  50121. */
  50122. name: string;
  50123. /**
  50124. * The clear color of the texture used to generate the glow map.
  50125. */
  50126. neutralColor: Color4;
  50127. /**
  50128. * Specifies wether the highlight layer is enabled or not.
  50129. */
  50130. isEnabled: boolean;
  50131. /**
  50132. * Gets the camera attached to the layer.
  50133. */
  50134. readonly camera: Nullable<Camera>;
  50135. /**
  50136. * Gets the rendering group id the layer should render in.
  50137. */
  50138. renderingGroupId: number;
  50139. /**
  50140. * An event triggered when the effect layer has been disposed.
  50141. */
  50142. onDisposeObservable: Observable<EffectLayer>;
  50143. /**
  50144. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50145. */
  50146. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50147. /**
  50148. * An event triggered when the generated texture is being merged in the scene.
  50149. */
  50150. onBeforeComposeObservable: Observable<EffectLayer>;
  50151. /**
  50152. * An event triggered when the generated texture has been merged in the scene.
  50153. */
  50154. onAfterComposeObservable: Observable<EffectLayer>;
  50155. /**
  50156. * An event triggered when the efffect layer changes its size.
  50157. */
  50158. onSizeChangedObservable: Observable<EffectLayer>;
  50159. /** @hidden */
  50160. static _SceneComponentInitialization: (scene: Scene) => void;
  50161. /**
  50162. * Instantiates a new effect Layer and references it in the scene.
  50163. * @param name The name of the layer
  50164. * @param scene The scene to use the layer in
  50165. */
  50166. constructor(
  50167. /** The Friendly of the effect in the scene */
  50168. name: string, scene: Scene);
  50169. /**
  50170. * Get the effect name of the layer.
  50171. * @return The effect name
  50172. */
  50173. abstract getEffectName(): string;
  50174. /**
  50175. * Checks for the readiness of the element composing the layer.
  50176. * @param subMesh the mesh to check for
  50177. * @param useInstances specify wether or not to use instances to render the mesh
  50178. * @return true if ready otherwise, false
  50179. */
  50180. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50181. /**
  50182. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50183. * @returns true if the effect requires stencil during the main canvas render pass.
  50184. */
  50185. abstract needStencil(): boolean;
  50186. /**
  50187. * Create the merge effect. This is the shader use to blit the information back
  50188. * to the main canvas at the end of the scene rendering.
  50189. * @returns The effect containing the shader used to merge the effect on the main canvas
  50190. */
  50191. protected abstract _createMergeEffect(): Effect;
  50192. /**
  50193. * Creates the render target textures and post processes used in the effect layer.
  50194. */
  50195. protected abstract _createTextureAndPostProcesses(): void;
  50196. /**
  50197. * Implementation specific of rendering the generating effect on the main canvas.
  50198. * @param effect The effect used to render through
  50199. */
  50200. protected abstract _internalRender(effect: Effect): void;
  50201. /**
  50202. * Sets the required values for both the emissive texture and and the main color.
  50203. */
  50204. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50205. /**
  50206. * Free any resources and references associated to a mesh.
  50207. * Internal use
  50208. * @param mesh The mesh to free.
  50209. */
  50210. abstract _disposeMesh(mesh: Mesh): void;
  50211. /**
  50212. * Serializes this layer (Glow or Highlight for example)
  50213. * @returns a serialized layer object
  50214. */
  50215. abstract serialize?(): any;
  50216. /**
  50217. * Initializes the effect layer with the required options.
  50218. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50219. */
  50220. protected _init(options: Partial<IEffectLayerOptions>): void;
  50221. /**
  50222. * Generates the index buffer of the full screen quad blending to the main canvas.
  50223. */
  50224. private _generateIndexBuffer;
  50225. /**
  50226. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50227. */
  50228. private _generateVertexBuffer;
  50229. /**
  50230. * Sets the main texture desired size which is the closest power of two
  50231. * of the engine canvas size.
  50232. */
  50233. private _setMainTextureSize;
  50234. /**
  50235. * Creates the main texture for the effect layer.
  50236. */
  50237. protected _createMainTexture(): void;
  50238. /**
  50239. * Adds specific effects defines.
  50240. * @param defines The defines to add specifics to.
  50241. */
  50242. protected _addCustomEffectDefines(defines: string[]): void;
  50243. /**
  50244. * Checks for the readiness of the element composing the layer.
  50245. * @param subMesh the mesh to check for
  50246. * @param useInstances specify wether or not to use instances to render the mesh
  50247. * @param emissiveTexture the associated emissive texture used to generate the glow
  50248. * @return true if ready otherwise, false
  50249. */
  50250. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50251. /**
  50252. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50253. */
  50254. render(): void;
  50255. /**
  50256. * Determine if a given mesh will be used in the current effect.
  50257. * @param mesh mesh to test
  50258. * @returns true if the mesh will be used
  50259. */
  50260. hasMesh(mesh: AbstractMesh): boolean;
  50261. /**
  50262. * Returns true if the layer contains information to display, otherwise false.
  50263. * @returns true if the glow layer should be rendered
  50264. */
  50265. shouldRender(): boolean;
  50266. /**
  50267. * Returns true if the mesh should render, otherwise false.
  50268. * @param mesh The mesh to render
  50269. * @returns true if it should render otherwise false
  50270. */
  50271. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50272. /**
  50273. * Returns true if the mesh can be rendered, otherwise false.
  50274. * @param mesh The mesh to render
  50275. * @param material The material used on the mesh
  50276. * @returns true if it can be rendered otherwise false
  50277. */
  50278. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50279. /**
  50280. * Returns true if the mesh should render, otherwise false.
  50281. * @param mesh The mesh to render
  50282. * @returns true if it should render otherwise false
  50283. */
  50284. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50285. /**
  50286. * Renders the submesh passed in parameter to the generation map.
  50287. */
  50288. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50289. /**
  50290. * Rebuild the required buffers.
  50291. * @hidden Internal use only.
  50292. */
  50293. _rebuild(): void;
  50294. /**
  50295. * Dispose only the render target textures and post process.
  50296. */
  50297. private _disposeTextureAndPostProcesses;
  50298. /**
  50299. * Dispose the highlight layer and free resources.
  50300. */
  50301. dispose(): void;
  50302. /**
  50303. * Gets the class name of the effect layer
  50304. * @returns the string with the class name of the effect layer
  50305. */
  50306. getClassName(): string;
  50307. /**
  50308. * Creates an effect layer from parsed effect layer data
  50309. * @param parsedEffectLayer defines effect layer data
  50310. * @param scene defines the current scene
  50311. * @param rootUrl defines the root URL containing the effect layer information
  50312. * @returns a parsed effect Layer
  50313. */
  50314. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50315. }
  50316. }
  50317. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50318. import { Scene } from "babylonjs/scene";
  50319. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50320. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50321. import { AbstractScene } from "babylonjs/abstractScene";
  50322. module "babylonjs/abstractScene" {
  50323. interface AbstractScene {
  50324. /**
  50325. * The list of effect layers (highlights/glow) added to the scene
  50326. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50327. * @see http://doc.babylonjs.com/how_to/glow_layer
  50328. */
  50329. effectLayers: Array<EffectLayer>;
  50330. /**
  50331. * Removes the given effect layer from this scene.
  50332. * @param toRemove defines the effect layer to remove
  50333. * @returns the index of the removed effect layer
  50334. */
  50335. removeEffectLayer(toRemove: EffectLayer): number;
  50336. /**
  50337. * Adds the given effect layer to this scene
  50338. * @param newEffectLayer defines the effect layer to add
  50339. */
  50340. addEffectLayer(newEffectLayer: EffectLayer): void;
  50341. }
  50342. }
  50343. /**
  50344. * Defines the layer scene component responsible to manage any effect layers
  50345. * in a given scene.
  50346. */
  50347. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50348. /**
  50349. * The component name helpfull to identify the component in the list of scene components.
  50350. */
  50351. readonly name: string;
  50352. /**
  50353. * The scene the component belongs to.
  50354. */
  50355. scene: Scene;
  50356. private _engine;
  50357. private _renderEffects;
  50358. private _needStencil;
  50359. private _previousStencilState;
  50360. /**
  50361. * Creates a new instance of the component for the given scene
  50362. * @param scene Defines the scene to register the component in
  50363. */
  50364. constructor(scene: Scene);
  50365. /**
  50366. * Registers the component in a given scene
  50367. */
  50368. register(): void;
  50369. /**
  50370. * Rebuilds the elements related to this component in case of
  50371. * context lost for instance.
  50372. */
  50373. rebuild(): void;
  50374. /**
  50375. * Serializes the component data to the specified json object
  50376. * @param serializationObject The object to serialize to
  50377. */
  50378. serialize(serializationObject: any): void;
  50379. /**
  50380. * Adds all the elements from the container to the scene
  50381. * @param container the container holding the elements
  50382. */
  50383. addFromContainer(container: AbstractScene): void;
  50384. /**
  50385. * Removes all the elements in the container from the scene
  50386. * @param container contains the elements to remove
  50387. * @param dispose if the removed element should be disposed (default: false)
  50388. */
  50389. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50390. /**
  50391. * Disposes the component and the associated ressources.
  50392. */
  50393. dispose(): void;
  50394. private _isReadyForMesh;
  50395. private _renderMainTexture;
  50396. private _setStencil;
  50397. private _setStencilBack;
  50398. private _draw;
  50399. private _drawCamera;
  50400. private _drawRenderingGroup;
  50401. }
  50402. }
  50403. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50404. /** @hidden */
  50405. export var glowMapMergePixelShader: {
  50406. name: string;
  50407. shader: string;
  50408. };
  50409. }
  50410. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50411. /** @hidden */
  50412. export var glowMapMergeVertexShader: {
  50413. name: string;
  50414. shader: string;
  50415. };
  50416. }
  50417. declare module "babylonjs/Layers/glowLayer" {
  50418. import { Nullable } from "babylonjs/types";
  50419. import { Camera } from "babylonjs/Cameras/camera";
  50420. import { Scene } from "babylonjs/scene";
  50421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50423. import { Mesh } from "babylonjs/Meshes/mesh";
  50424. import { Texture } from "babylonjs/Materials/Textures/texture";
  50425. import { Effect } from "babylonjs/Materials/effect";
  50426. import { Material } from "babylonjs/Materials/material";
  50427. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50428. import { Color4 } from "babylonjs/Maths/math.color";
  50429. import "babylonjs/Shaders/glowMapMerge.fragment";
  50430. import "babylonjs/Shaders/glowMapMerge.vertex";
  50431. import "babylonjs/Layers/effectLayerSceneComponent";
  50432. module "babylonjs/abstractScene" {
  50433. interface AbstractScene {
  50434. /**
  50435. * Return a the first highlight layer of the scene with a given name.
  50436. * @param name The name of the highlight layer to look for.
  50437. * @return The highlight layer if found otherwise null.
  50438. */
  50439. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50440. }
  50441. }
  50442. /**
  50443. * Glow layer options. This helps customizing the behaviour
  50444. * of the glow layer.
  50445. */
  50446. export interface IGlowLayerOptions {
  50447. /**
  50448. * Multiplication factor apply to the canvas size to compute the render target size
  50449. * used to generated the glowing objects (the smaller the faster).
  50450. */
  50451. mainTextureRatio: number;
  50452. /**
  50453. * Enforces a fixed size texture to ensure resize independant blur.
  50454. */
  50455. mainTextureFixedSize?: number;
  50456. /**
  50457. * How big is the kernel of the blur texture.
  50458. */
  50459. blurKernelSize: number;
  50460. /**
  50461. * The camera attached to the layer.
  50462. */
  50463. camera: Nullable<Camera>;
  50464. /**
  50465. * Enable MSAA by chosing the number of samples.
  50466. */
  50467. mainTextureSamples?: number;
  50468. /**
  50469. * The rendering group to draw the layer in.
  50470. */
  50471. renderingGroupId: number;
  50472. }
  50473. /**
  50474. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50475. *
  50476. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50477. * glowy meshes to your scene.
  50478. *
  50479. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50480. */
  50481. export class GlowLayer extends EffectLayer {
  50482. /**
  50483. * Effect Name of the layer.
  50484. */
  50485. static readonly EffectName: string;
  50486. /**
  50487. * The default blur kernel size used for the glow.
  50488. */
  50489. static DefaultBlurKernelSize: number;
  50490. /**
  50491. * The default texture size ratio used for the glow.
  50492. */
  50493. static DefaultTextureRatio: number;
  50494. /**
  50495. * Sets the kernel size of the blur.
  50496. */
  50497. /**
  50498. * Gets the kernel size of the blur.
  50499. */
  50500. blurKernelSize: number;
  50501. /**
  50502. * Sets the glow intensity.
  50503. */
  50504. /**
  50505. * Gets the glow intensity.
  50506. */
  50507. intensity: number;
  50508. private _options;
  50509. private _intensity;
  50510. private _horizontalBlurPostprocess1;
  50511. private _verticalBlurPostprocess1;
  50512. private _horizontalBlurPostprocess2;
  50513. private _verticalBlurPostprocess2;
  50514. private _blurTexture1;
  50515. private _blurTexture2;
  50516. private _postProcesses1;
  50517. private _postProcesses2;
  50518. private _includedOnlyMeshes;
  50519. private _excludedMeshes;
  50520. /**
  50521. * Callback used to let the user override the color selection on a per mesh basis
  50522. */
  50523. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50524. /**
  50525. * Callback used to let the user override the texture selection on a per mesh basis
  50526. */
  50527. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50528. /**
  50529. * Instantiates a new glow Layer and references it to the scene.
  50530. * @param name The name of the layer
  50531. * @param scene The scene to use the layer in
  50532. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50533. */
  50534. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50535. /**
  50536. * Get the effect name of the layer.
  50537. * @return The effect name
  50538. */
  50539. getEffectName(): string;
  50540. /**
  50541. * Create the merge effect. This is the shader use to blit the information back
  50542. * to the main canvas at the end of the scene rendering.
  50543. */
  50544. protected _createMergeEffect(): Effect;
  50545. /**
  50546. * Creates the render target textures and post processes used in the glow layer.
  50547. */
  50548. protected _createTextureAndPostProcesses(): void;
  50549. /**
  50550. * Checks for the readiness of the element composing the layer.
  50551. * @param subMesh the mesh to check for
  50552. * @param useInstances specify wether or not to use instances to render the mesh
  50553. * @param emissiveTexture the associated emissive texture used to generate the glow
  50554. * @return true if ready otherwise, false
  50555. */
  50556. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50557. /**
  50558. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50559. */
  50560. needStencil(): boolean;
  50561. /**
  50562. * Returns true if the mesh can be rendered, otherwise false.
  50563. * @param mesh The mesh to render
  50564. * @param material The material used on the mesh
  50565. * @returns true if it can be rendered otherwise false
  50566. */
  50567. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50568. /**
  50569. * Implementation specific of rendering the generating effect on the main canvas.
  50570. * @param effect The effect used to render through
  50571. */
  50572. protected _internalRender(effect: Effect): void;
  50573. /**
  50574. * Sets the required values for both the emissive texture and and the main color.
  50575. */
  50576. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50577. /**
  50578. * Returns true if the mesh should render, otherwise false.
  50579. * @param mesh The mesh to render
  50580. * @returns true if it should render otherwise false
  50581. */
  50582. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50583. /**
  50584. * Adds specific effects defines.
  50585. * @param defines The defines to add specifics to.
  50586. */
  50587. protected _addCustomEffectDefines(defines: string[]): void;
  50588. /**
  50589. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50590. * @param mesh The mesh to exclude from the glow layer
  50591. */
  50592. addExcludedMesh(mesh: Mesh): void;
  50593. /**
  50594. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50595. * @param mesh The mesh to remove
  50596. */
  50597. removeExcludedMesh(mesh: Mesh): void;
  50598. /**
  50599. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50600. * @param mesh The mesh to include in the glow layer
  50601. */
  50602. addIncludedOnlyMesh(mesh: Mesh): void;
  50603. /**
  50604. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50605. * @param mesh The mesh to remove
  50606. */
  50607. removeIncludedOnlyMesh(mesh: Mesh): void;
  50608. /**
  50609. * Determine if a given mesh will be used in the glow layer
  50610. * @param mesh The mesh to test
  50611. * @returns true if the mesh will be highlighted by the current glow layer
  50612. */
  50613. hasMesh(mesh: AbstractMesh): boolean;
  50614. /**
  50615. * Free any resources and references associated to a mesh.
  50616. * Internal use
  50617. * @param mesh The mesh to free.
  50618. * @hidden
  50619. */
  50620. _disposeMesh(mesh: Mesh): void;
  50621. /**
  50622. * Gets the class name of the effect layer
  50623. * @returns the string with the class name of the effect layer
  50624. */
  50625. getClassName(): string;
  50626. /**
  50627. * Serializes this glow layer
  50628. * @returns a serialized glow layer object
  50629. */
  50630. serialize(): any;
  50631. /**
  50632. * Creates a Glow Layer from parsed glow layer data
  50633. * @param parsedGlowLayer defines glow layer data
  50634. * @param scene defines the current scene
  50635. * @param rootUrl defines the root URL containing the glow layer information
  50636. * @returns a parsed Glow Layer
  50637. */
  50638. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50639. }
  50640. }
  50641. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50642. /** @hidden */
  50643. export var glowBlurPostProcessPixelShader: {
  50644. name: string;
  50645. shader: string;
  50646. };
  50647. }
  50648. declare module "babylonjs/Layers/highlightLayer" {
  50649. import { Observable } from "babylonjs/Misc/observable";
  50650. import { Nullable } from "babylonjs/types";
  50651. import { Camera } from "babylonjs/Cameras/camera";
  50652. import { Scene } from "babylonjs/scene";
  50653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50655. import { Mesh } from "babylonjs/Meshes/mesh";
  50656. import { Effect } from "babylonjs/Materials/effect";
  50657. import { Material } from "babylonjs/Materials/material";
  50658. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50659. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50660. import "babylonjs/Shaders/glowMapMerge.fragment";
  50661. import "babylonjs/Shaders/glowMapMerge.vertex";
  50662. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50663. module "babylonjs/abstractScene" {
  50664. interface AbstractScene {
  50665. /**
  50666. * Return a the first highlight layer of the scene with a given name.
  50667. * @param name The name of the highlight layer to look for.
  50668. * @return The highlight layer if found otherwise null.
  50669. */
  50670. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50671. }
  50672. }
  50673. /**
  50674. * Highlight layer options. This helps customizing the behaviour
  50675. * of the highlight layer.
  50676. */
  50677. export interface IHighlightLayerOptions {
  50678. /**
  50679. * Multiplication factor apply to the canvas size to compute the render target size
  50680. * used to generated the glowing objects (the smaller the faster).
  50681. */
  50682. mainTextureRatio: number;
  50683. /**
  50684. * Enforces a fixed size texture to ensure resize independant blur.
  50685. */
  50686. mainTextureFixedSize?: number;
  50687. /**
  50688. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50689. * of the picture to blur (the smaller the faster).
  50690. */
  50691. blurTextureSizeRatio: number;
  50692. /**
  50693. * How big in texel of the blur texture is the vertical blur.
  50694. */
  50695. blurVerticalSize: number;
  50696. /**
  50697. * How big in texel of the blur texture is the horizontal blur.
  50698. */
  50699. blurHorizontalSize: number;
  50700. /**
  50701. * Alpha blending mode used to apply the blur. Default is combine.
  50702. */
  50703. alphaBlendingMode: number;
  50704. /**
  50705. * The camera attached to the layer.
  50706. */
  50707. camera: Nullable<Camera>;
  50708. /**
  50709. * Should we display highlight as a solid stroke?
  50710. */
  50711. isStroke?: boolean;
  50712. /**
  50713. * The rendering group to draw the layer in.
  50714. */
  50715. renderingGroupId: number;
  50716. }
  50717. /**
  50718. * The highlight layer Helps adding a glow effect around a mesh.
  50719. *
  50720. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50721. * glowy meshes to your scene.
  50722. *
  50723. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50724. */
  50725. export class HighlightLayer extends EffectLayer {
  50726. name: string;
  50727. /**
  50728. * Effect Name of the highlight layer.
  50729. */
  50730. static readonly EffectName: string;
  50731. /**
  50732. * The neutral color used during the preparation of the glow effect.
  50733. * This is black by default as the blend operation is a blend operation.
  50734. */
  50735. static NeutralColor: Color4;
  50736. /**
  50737. * Stencil value used for glowing meshes.
  50738. */
  50739. static GlowingMeshStencilReference: number;
  50740. /**
  50741. * Stencil value used for the other meshes in the scene.
  50742. */
  50743. static NormalMeshStencilReference: number;
  50744. /**
  50745. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50746. */
  50747. innerGlow: boolean;
  50748. /**
  50749. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50750. */
  50751. outerGlow: boolean;
  50752. /**
  50753. * Specifies the horizontal size of the blur.
  50754. */
  50755. /**
  50756. * Gets the horizontal size of the blur.
  50757. */
  50758. blurHorizontalSize: number;
  50759. /**
  50760. * Specifies the vertical size of the blur.
  50761. */
  50762. /**
  50763. * Gets the vertical size of the blur.
  50764. */
  50765. blurVerticalSize: number;
  50766. /**
  50767. * An event triggered when the highlight layer is being blurred.
  50768. */
  50769. onBeforeBlurObservable: Observable<HighlightLayer>;
  50770. /**
  50771. * An event triggered when the highlight layer has been blurred.
  50772. */
  50773. onAfterBlurObservable: Observable<HighlightLayer>;
  50774. private _instanceGlowingMeshStencilReference;
  50775. private _options;
  50776. private _downSamplePostprocess;
  50777. private _horizontalBlurPostprocess;
  50778. private _verticalBlurPostprocess;
  50779. private _blurTexture;
  50780. private _meshes;
  50781. private _excludedMeshes;
  50782. /**
  50783. * Instantiates a new highlight Layer and references it to the scene..
  50784. * @param name The name of the layer
  50785. * @param scene The scene to use the layer in
  50786. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50787. */
  50788. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50789. /**
  50790. * Get the effect name of the layer.
  50791. * @return The effect name
  50792. */
  50793. getEffectName(): string;
  50794. /**
  50795. * Create the merge effect. This is the shader use to blit the information back
  50796. * to the main canvas at the end of the scene rendering.
  50797. */
  50798. protected _createMergeEffect(): Effect;
  50799. /**
  50800. * Creates the render target textures and post processes used in the highlight layer.
  50801. */
  50802. protected _createTextureAndPostProcesses(): void;
  50803. /**
  50804. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50805. */
  50806. needStencil(): boolean;
  50807. /**
  50808. * Checks for the readiness of the element composing the layer.
  50809. * @param subMesh the mesh to check for
  50810. * @param useInstances specify wether or not to use instances to render the mesh
  50811. * @param emissiveTexture the associated emissive texture used to generate the glow
  50812. * @return true if ready otherwise, false
  50813. */
  50814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50815. /**
  50816. * Implementation specific of rendering the generating effect on the main canvas.
  50817. * @param effect The effect used to render through
  50818. */
  50819. protected _internalRender(effect: Effect): void;
  50820. /**
  50821. * Returns true if the layer contains information to display, otherwise false.
  50822. */
  50823. shouldRender(): boolean;
  50824. /**
  50825. * Returns true if the mesh should render, otherwise false.
  50826. * @param mesh The mesh to render
  50827. * @returns true if it should render otherwise false
  50828. */
  50829. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50830. /**
  50831. * Sets the required values for both the emissive texture and and the main color.
  50832. */
  50833. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50834. /**
  50835. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50836. * @param mesh The mesh to exclude from the highlight layer
  50837. */
  50838. addExcludedMesh(mesh: Mesh): void;
  50839. /**
  50840. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50841. * @param mesh The mesh to highlight
  50842. */
  50843. removeExcludedMesh(mesh: Mesh): void;
  50844. /**
  50845. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50846. * @param mesh mesh to test
  50847. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50848. */
  50849. hasMesh(mesh: AbstractMesh): boolean;
  50850. /**
  50851. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50852. * @param mesh The mesh to highlight
  50853. * @param color The color of the highlight
  50854. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50855. */
  50856. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50857. /**
  50858. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50859. * @param mesh The mesh to highlight
  50860. */
  50861. removeMesh(mesh: Mesh): void;
  50862. /**
  50863. * Force the stencil to the normal expected value for none glowing parts
  50864. */
  50865. private _defaultStencilReference;
  50866. /**
  50867. * Free any resources and references associated to a mesh.
  50868. * Internal use
  50869. * @param mesh The mesh to free.
  50870. * @hidden
  50871. */
  50872. _disposeMesh(mesh: Mesh): void;
  50873. /**
  50874. * Dispose the highlight layer and free resources.
  50875. */
  50876. dispose(): void;
  50877. /**
  50878. * Gets the class name of the effect layer
  50879. * @returns the string with the class name of the effect layer
  50880. */
  50881. getClassName(): string;
  50882. /**
  50883. * Serializes this Highlight layer
  50884. * @returns a serialized Highlight layer object
  50885. */
  50886. serialize(): any;
  50887. /**
  50888. * Creates a Highlight layer from parsed Highlight layer data
  50889. * @param parsedHightlightLayer defines the Highlight layer data
  50890. * @param scene defines the current scene
  50891. * @param rootUrl defines the root URL containing the Highlight layer information
  50892. * @returns a parsed Highlight layer
  50893. */
  50894. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50895. }
  50896. }
  50897. declare module "babylonjs/Layers/layerSceneComponent" {
  50898. import { Scene } from "babylonjs/scene";
  50899. import { ISceneComponent } from "babylonjs/sceneComponent";
  50900. import { Layer } from "babylonjs/Layers/layer";
  50901. import { AbstractScene } from "babylonjs/abstractScene";
  50902. module "babylonjs/abstractScene" {
  50903. interface AbstractScene {
  50904. /**
  50905. * The list of layers (background and foreground) of the scene
  50906. */
  50907. layers: Array<Layer>;
  50908. }
  50909. }
  50910. /**
  50911. * Defines the layer scene component responsible to manage any layers
  50912. * in a given scene.
  50913. */
  50914. export class LayerSceneComponent implements ISceneComponent {
  50915. /**
  50916. * The component name helpfull to identify the component in the list of scene components.
  50917. */
  50918. readonly name: string;
  50919. /**
  50920. * The scene the component belongs to.
  50921. */
  50922. scene: Scene;
  50923. private _engine;
  50924. /**
  50925. * Creates a new instance of the component for the given scene
  50926. * @param scene Defines the scene to register the component in
  50927. */
  50928. constructor(scene: Scene);
  50929. /**
  50930. * Registers the component in a given scene
  50931. */
  50932. register(): void;
  50933. /**
  50934. * Rebuilds the elements related to this component in case of
  50935. * context lost for instance.
  50936. */
  50937. rebuild(): void;
  50938. /**
  50939. * Disposes the component and the associated ressources.
  50940. */
  50941. dispose(): void;
  50942. private _draw;
  50943. private _drawCameraPredicate;
  50944. private _drawCameraBackground;
  50945. private _drawCameraForeground;
  50946. private _drawRenderTargetPredicate;
  50947. private _drawRenderTargetBackground;
  50948. private _drawRenderTargetForeground;
  50949. /**
  50950. * Adds all the elements from the container to the scene
  50951. * @param container the container holding the elements
  50952. */
  50953. addFromContainer(container: AbstractScene): void;
  50954. /**
  50955. * Removes all the elements in the container from the scene
  50956. * @param container contains the elements to remove
  50957. * @param dispose if the removed element should be disposed (default: false)
  50958. */
  50959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50960. }
  50961. }
  50962. declare module "babylonjs/Shaders/layer.fragment" {
  50963. /** @hidden */
  50964. export var layerPixelShader: {
  50965. name: string;
  50966. shader: string;
  50967. };
  50968. }
  50969. declare module "babylonjs/Shaders/layer.vertex" {
  50970. /** @hidden */
  50971. export var layerVertexShader: {
  50972. name: string;
  50973. shader: string;
  50974. };
  50975. }
  50976. declare module "babylonjs/Layers/layer" {
  50977. import { Observable } from "babylonjs/Misc/observable";
  50978. import { Nullable } from "babylonjs/types";
  50979. import { Scene } from "babylonjs/scene";
  50980. import { Vector2 } from "babylonjs/Maths/math.vector";
  50981. import { Color4 } from "babylonjs/Maths/math.color";
  50982. import { Texture } from "babylonjs/Materials/Textures/texture";
  50983. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50984. import "babylonjs/Shaders/layer.fragment";
  50985. import "babylonjs/Shaders/layer.vertex";
  50986. /**
  50987. * This represents a full screen 2d layer.
  50988. * This can be useful to display a picture in the background of your scene for instance.
  50989. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50990. */
  50991. export class Layer {
  50992. /**
  50993. * Define the name of the layer.
  50994. */
  50995. name: string;
  50996. /**
  50997. * Define the texture the layer should display.
  50998. */
  50999. texture: Nullable<Texture>;
  51000. /**
  51001. * Is the layer in background or foreground.
  51002. */
  51003. isBackground: boolean;
  51004. /**
  51005. * Define the color of the layer (instead of texture).
  51006. */
  51007. color: Color4;
  51008. /**
  51009. * Define the scale of the layer in order to zoom in out of the texture.
  51010. */
  51011. scale: Vector2;
  51012. /**
  51013. * Define an offset for the layer in order to shift the texture.
  51014. */
  51015. offset: Vector2;
  51016. /**
  51017. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51018. */
  51019. alphaBlendingMode: number;
  51020. /**
  51021. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51022. * Alpha test will not mix with the background color in case of transparency.
  51023. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51024. */
  51025. alphaTest: boolean;
  51026. /**
  51027. * Define a mask to restrict the layer to only some of the scene cameras.
  51028. */
  51029. layerMask: number;
  51030. /**
  51031. * Define the list of render target the layer is visible into.
  51032. */
  51033. renderTargetTextures: RenderTargetTexture[];
  51034. /**
  51035. * Define if the layer is only used in renderTarget or if it also
  51036. * renders in the main frame buffer of the canvas.
  51037. */
  51038. renderOnlyInRenderTargetTextures: boolean;
  51039. private _scene;
  51040. private _vertexBuffers;
  51041. private _indexBuffer;
  51042. private _effect;
  51043. private _alphaTestEffect;
  51044. /**
  51045. * An event triggered when the layer is disposed.
  51046. */
  51047. onDisposeObservable: Observable<Layer>;
  51048. private _onDisposeObserver;
  51049. /**
  51050. * Back compatibility with callback before the onDisposeObservable existed.
  51051. * The set callback will be triggered when the layer has been disposed.
  51052. */
  51053. onDispose: () => void;
  51054. /**
  51055. * An event triggered before rendering the scene
  51056. */
  51057. onBeforeRenderObservable: Observable<Layer>;
  51058. private _onBeforeRenderObserver;
  51059. /**
  51060. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51061. * The set callback will be triggered just before rendering the layer.
  51062. */
  51063. onBeforeRender: () => void;
  51064. /**
  51065. * An event triggered after rendering the scene
  51066. */
  51067. onAfterRenderObservable: Observable<Layer>;
  51068. private _onAfterRenderObserver;
  51069. /**
  51070. * Back compatibility with callback before the onAfterRenderObservable existed.
  51071. * The set callback will be triggered just after rendering the layer.
  51072. */
  51073. onAfterRender: () => void;
  51074. /**
  51075. * Instantiates a new layer.
  51076. * This represents a full screen 2d layer.
  51077. * This can be useful to display a picture in the background of your scene for instance.
  51078. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51079. * @param name Define the name of the layer in the scene
  51080. * @param imgUrl Define the url of the texture to display in the layer
  51081. * @param scene Define the scene the layer belongs to
  51082. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51083. * @param color Defines a color for the layer
  51084. */
  51085. constructor(
  51086. /**
  51087. * Define the name of the layer.
  51088. */
  51089. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51090. private _createIndexBuffer;
  51091. /** @hidden */
  51092. _rebuild(): void;
  51093. /**
  51094. * Renders the layer in the scene.
  51095. */
  51096. render(): void;
  51097. /**
  51098. * Disposes and releases the associated ressources.
  51099. */
  51100. dispose(): void;
  51101. }
  51102. }
  51103. declare module "babylonjs/Layers/index" {
  51104. export * from "babylonjs/Layers/effectLayer";
  51105. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51106. export * from "babylonjs/Layers/glowLayer";
  51107. export * from "babylonjs/Layers/highlightLayer";
  51108. export * from "babylonjs/Layers/layer";
  51109. export * from "babylonjs/Layers/layerSceneComponent";
  51110. }
  51111. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51112. /** @hidden */
  51113. export var lensFlarePixelShader: {
  51114. name: string;
  51115. shader: string;
  51116. };
  51117. }
  51118. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51119. /** @hidden */
  51120. export var lensFlareVertexShader: {
  51121. name: string;
  51122. shader: string;
  51123. };
  51124. }
  51125. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51126. import { Scene } from "babylonjs/scene";
  51127. import { Vector3 } from "babylonjs/Maths/math.vector";
  51128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51129. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51130. import "babylonjs/Shaders/lensFlare.fragment";
  51131. import "babylonjs/Shaders/lensFlare.vertex";
  51132. import { Viewport } from "babylonjs/Maths/math.viewport";
  51133. /**
  51134. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51135. * It is usually composed of several `lensFlare`.
  51136. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51137. */
  51138. export class LensFlareSystem {
  51139. /**
  51140. * Define the name of the lens flare system
  51141. */
  51142. name: string;
  51143. /**
  51144. * List of lens flares used in this system.
  51145. */
  51146. lensFlares: LensFlare[];
  51147. /**
  51148. * Define a limit from the border the lens flare can be visible.
  51149. */
  51150. borderLimit: number;
  51151. /**
  51152. * Define a viewport border we do not want to see the lens flare in.
  51153. */
  51154. viewportBorder: number;
  51155. /**
  51156. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51157. */
  51158. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51159. /**
  51160. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51161. */
  51162. layerMask: number;
  51163. /**
  51164. * Define the id of the lens flare system in the scene.
  51165. * (equal to name by default)
  51166. */
  51167. id: string;
  51168. private _scene;
  51169. private _emitter;
  51170. private _vertexBuffers;
  51171. private _indexBuffer;
  51172. private _effect;
  51173. private _positionX;
  51174. private _positionY;
  51175. private _isEnabled;
  51176. /** @hidden */
  51177. static _SceneComponentInitialization: (scene: Scene) => void;
  51178. /**
  51179. * Instantiates a lens flare system.
  51180. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51181. * It is usually composed of several `lensFlare`.
  51182. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51183. * @param name Define the name of the lens flare system in the scene
  51184. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51185. * @param scene Define the scene the lens flare system belongs to
  51186. */
  51187. constructor(
  51188. /**
  51189. * Define the name of the lens flare system
  51190. */
  51191. name: string, emitter: any, scene: Scene);
  51192. /**
  51193. * Define if the lens flare system is enabled.
  51194. */
  51195. isEnabled: boolean;
  51196. /**
  51197. * Get the scene the effects belongs to.
  51198. * @returns the scene holding the lens flare system
  51199. */
  51200. getScene(): Scene;
  51201. /**
  51202. * Get the emitter of the lens flare system.
  51203. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51204. * @returns the emitter of the lens flare system
  51205. */
  51206. getEmitter(): any;
  51207. /**
  51208. * Set the emitter of the lens flare system.
  51209. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51210. * @param newEmitter Define the new emitter of the system
  51211. */
  51212. setEmitter(newEmitter: any): void;
  51213. /**
  51214. * Get the lens flare system emitter position.
  51215. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51216. * @returns the position
  51217. */
  51218. getEmitterPosition(): Vector3;
  51219. /**
  51220. * @hidden
  51221. */
  51222. computeEffectivePosition(globalViewport: Viewport): boolean;
  51223. /** @hidden */
  51224. _isVisible(): boolean;
  51225. /**
  51226. * @hidden
  51227. */
  51228. render(): boolean;
  51229. /**
  51230. * Dispose and release the lens flare with its associated resources.
  51231. */
  51232. dispose(): void;
  51233. /**
  51234. * Parse a lens flare system from a JSON repressentation
  51235. * @param parsedLensFlareSystem Define the JSON to parse
  51236. * @param scene Define the scene the parsed system should be instantiated in
  51237. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51238. * @returns the parsed system
  51239. */
  51240. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51241. /**
  51242. * Serialize the current Lens Flare System into a JSON representation.
  51243. * @returns the serialized JSON
  51244. */
  51245. serialize(): any;
  51246. }
  51247. }
  51248. declare module "babylonjs/LensFlares/lensFlare" {
  51249. import { Nullable } from "babylonjs/types";
  51250. import { Color3 } from "babylonjs/Maths/math.color";
  51251. import { Texture } from "babylonjs/Materials/Textures/texture";
  51252. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51253. /**
  51254. * This represents one of the lens effect in a `lensFlareSystem`.
  51255. * It controls one of the indiviual texture used in the effect.
  51256. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51257. */
  51258. export class LensFlare {
  51259. /**
  51260. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51261. */
  51262. size: number;
  51263. /**
  51264. * 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.
  51265. */
  51266. position: number;
  51267. /**
  51268. * Define the lens color.
  51269. */
  51270. color: Color3;
  51271. /**
  51272. * Define the lens texture.
  51273. */
  51274. texture: Nullable<Texture>;
  51275. /**
  51276. * Define the alpha mode to render this particular lens.
  51277. */
  51278. alphaMode: number;
  51279. private _system;
  51280. /**
  51281. * Creates a new Lens Flare.
  51282. * This represents one of the lens effect in a `lensFlareSystem`.
  51283. * It controls one of the indiviual texture used in the effect.
  51284. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51285. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51286. * @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.
  51287. * @param color Define the lens color
  51288. * @param imgUrl Define the lens texture url
  51289. * @param system Define the `lensFlareSystem` this flare is part of
  51290. * @returns The newly created Lens Flare
  51291. */
  51292. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51293. /**
  51294. * Instantiates a new Lens Flare.
  51295. * This represents one of the lens effect in a `lensFlareSystem`.
  51296. * It controls one of the indiviual texture used in the effect.
  51297. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51298. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51299. * @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.
  51300. * @param color Define the lens color
  51301. * @param imgUrl Define the lens texture url
  51302. * @param system Define the `lensFlareSystem` this flare is part of
  51303. */
  51304. constructor(
  51305. /**
  51306. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51307. */
  51308. size: number,
  51309. /**
  51310. * 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.
  51311. */
  51312. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51313. /**
  51314. * Dispose and release the lens flare with its associated resources.
  51315. */
  51316. dispose(): void;
  51317. }
  51318. }
  51319. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51320. import { Nullable } from "babylonjs/types";
  51321. import { Scene } from "babylonjs/scene";
  51322. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51323. import { AbstractScene } from "babylonjs/abstractScene";
  51324. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51325. module "babylonjs/abstractScene" {
  51326. interface AbstractScene {
  51327. /**
  51328. * The list of lens flare system added to the scene
  51329. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51330. */
  51331. lensFlareSystems: Array<LensFlareSystem>;
  51332. /**
  51333. * Removes the given lens flare system from this scene.
  51334. * @param toRemove The lens flare system to remove
  51335. * @returns The index of the removed lens flare system
  51336. */
  51337. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51338. /**
  51339. * Adds the given lens flare system to this scene
  51340. * @param newLensFlareSystem The lens flare system to add
  51341. */
  51342. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51343. /**
  51344. * Gets a lens flare system using its name
  51345. * @param name defines the name to look for
  51346. * @returns the lens flare system or null if not found
  51347. */
  51348. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51349. /**
  51350. * Gets a lens flare system using its id
  51351. * @param id defines the id to look for
  51352. * @returns the lens flare system or null if not found
  51353. */
  51354. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51355. }
  51356. }
  51357. /**
  51358. * Defines the lens flare scene component responsible to manage any lens flares
  51359. * in a given scene.
  51360. */
  51361. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51362. /**
  51363. * The component name helpfull to identify the component in the list of scene components.
  51364. */
  51365. readonly name: string;
  51366. /**
  51367. * The scene the component belongs to.
  51368. */
  51369. scene: Scene;
  51370. /**
  51371. * Creates a new instance of the component for the given scene
  51372. * @param scene Defines the scene to register the component in
  51373. */
  51374. constructor(scene: Scene);
  51375. /**
  51376. * Registers the component in a given scene
  51377. */
  51378. register(): void;
  51379. /**
  51380. * Rebuilds the elements related to this component in case of
  51381. * context lost for instance.
  51382. */
  51383. rebuild(): void;
  51384. /**
  51385. * Adds all the elements from the container to the scene
  51386. * @param container the container holding the elements
  51387. */
  51388. addFromContainer(container: AbstractScene): void;
  51389. /**
  51390. * Removes all the elements in the container from the scene
  51391. * @param container contains the elements to remove
  51392. * @param dispose if the removed element should be disposed (default: false)
  51393. */
  51394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51395. /**
  51396. * Serializes the component data to the specified json object
  51397. * @param serializationObject The object to serialize to
  51398. */
  51399. serialize(serializationObject: any): void;
  51400. /**
  51401. * Disposes the component and the associated ressources.
  51402. */
  51403. dispose(): void;
  51404. private _draw;
  51405. }
  51406. }
  51407. declare module "babylonjs/LensFlares/index" {
  51408. export * from "babylonjs/LensFlares/lensFlare";
  51409. export * from "babylonjs/LensFlares/lensFlareSystem";
  51410. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51411. }
  51412. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51413. import { Scene } from "babylonjs/scene";
  51414. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51415. import { AbstractScene } from "babylonjs/abstractScene";
  51416. /**
  51417. * Defines the shadow generator component responsible to manage any shadow generators
  51418. * in a given scene.
  51419. */
  51420. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51421. /**
  51422. * The component name helpfull to identify the component in the list of scene components.
  51423. */
  51424. readonly name: string;
  51425. /**
  51426. * The scene the component belongs to.
  51427. */
  51428. scene: Scene;
  51429. /**
  51430. * Creates a new instance of the component for the given scene
  51431. * @param scene Defines the scene to register the component in
  51432. */
  51433. constructor(scene: Scene);
  51434. /**
  51435. * Registers the component in a given scene
  51436. */
  51437. register(): void;
  51438. /**
  51439. * Rebuilds the elements related to this component in case of
  51440. * context lost for instance.
  51441. */
  51442. rebuild(): void;
  51443. /**
  51444. * Serializes the component data to the specified json object
  51445. * @param serializationObject The object to serialize to
  51446. */
  51447. serialize(serializationObject: any): void;
  51448. /**
  51449. * Adds all the elements from the container to the scene
  51450. * @param container the container holding the elements
  51451. */
  51452. addFromContainer(container: AbstractScene): void;
  51453. /**
  51454. * Removes all the elements in the container from the scene
  51455. * @param container contains the elements to remove
  51456. * @param dispose if the removed element should be disposed (default: false)
  51457. */
  51458. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51459. /**
  51460. * Rebuilds the elements related to this component in case of
  51461. * context lost for instance.
  51462. */
  51463. dispose(): void;
  51464. private _gatherRenderTargets;
  51465. }
  51466. }
  51467. declare module "babylonjs/Lights/Shadows/index" {
  51468. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51469. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51470. }
  51471. declare module "babylonjs/Lights/pointLight" {
  51472. import { Scene } from "babylonjs/scene";
  51473. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51475. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51476. import { Effect } from "babylonjs/Materials/effect";
  51477. /**
  51478. * A point light is a light defined by an unique point in world space.
  51479. * The light is emitted in every direction from this point.
  51480. * A good example of a point light is a standard light bulb.
  51481. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51482. */
  51483. export class PointLight extends ShadowLight {
  51484. private _shadowAngle;
  51485. /**
  51486. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51487. * This specifies what angle the shadow will use to be created.
  51488. *
  51489. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51490. */
  51491. /**
  51492. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51493. * This specifies what angle the shadow will use to be created.
  51494. *
  51495. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51496. */
  51497. shadowAngle: number;
  51498. /**
  51499. * Gets the direction if it has been set.
  51500. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51501. */
  51502. /**
  51503. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51504. */
  51505. direction: Vector3;
  51506. /**
  51507. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51508. * A PointLight emits the light in every direction.
  51509. * It can cast shadows.
  51510. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51511. * ```javascript
  51512. * var pointLight = new PointLight("pl", camera.position, scene);
  51513. * ```
  51514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51515. * @param name The light friendly name
  51516. * @param position The position of the point light in the scene
  51517. * @param scene The scene the lights belongs to
  51518. */
  51519. constructor(name: string, position: Vector3, scene: Scene);
  51520. /**
  51521. * Returns the string "PointLight"
  51522. * @returns the class name
  51523. */
  51524. getClassName(): string;
  51525. /**
  51526. * Returns the integer 0.
  51527. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51528. */
  51529. getTypeID(): number;
  51530. /**
  51531. * Specifies wether or not the shadowmap should be a cube texture.
  51532. * @returns true if the shadowmap needs to be a cube texture.
  51533. */
  51534. needCube(): boolean;
  51535. /**
  51536. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51537. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51538. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51539. */
  51540. getShadowDirection(faceIndex?: number): Vector3;
  51541. /**
  51542. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51543. * - fov = PI / 2
  51544. * - aspect ratio : 1.0
  51545. * - z-near and far equal to the active camera minZ and maxZ.
  51546. * Returns the PointLight.
  51547. */
  51548. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51549. protected _buildUniformLayout(): void;
  51550. /**
  51551. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51552. * @param effect The effect to update
  51553. * @param lightIndex The index of the light in the effect to update
  51554. * @returns The point light
  51555. */
  51556. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51557. /**
  51558. * Prepares the list of defines specific to the light type.
  51559. * @param defines the list of defines
  51560. * @param lightIndex defines the index of the light for the effect
  51561. */
  51562. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51563. }
  51564. }
  51565. declare module "babylonjs/Lights/index" {
  51566. export * from "babylonjs/Lights/light";
  51567. export * from "babylonjs/Lights/shadowLight";
  51568. export * from "babylonjs/Lights/Shadows/index";
  51569. export * from "babylonjs/Lights/directionalLight";
  51570. export * from "babylonjs/Lights/hemisphericLight";
  51571. export * from "babylonjs/Lights/pointLight";
  51572. export * from "babylonjs/Lights/spotLight";
  51573. }
  51574. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51575. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51576. /**
  51577. * Header information of HDR texture files.
  51578. */
  51579. export interface HDRInfo {
  51580. /**
  51581. * The height of the texture in pixels.
  51582. */
  51583. height: number;
  51584. /**
  51585. * The width of the texture in pixels.
  51586. */
  51587. width: number;
  51588. /**
  51589. * The index of the beginning of the data in the binary file.
  51590. */
  51591. dataPosition: number;
  51592. }
  51593. /**
  51594. * This groups tools to convert HDR texture to native colors array.
  51595. */
  51596. export class HDRTools {
  51597. private static Ldexp;
  51598. private static Rgbe2float;
  51599. private static readStringLine;
  51600. /**
  51601. * Reads header information from an RGBE texture stored in a native array.
  51602. * More information on this format are available here:
  51603. * https://en.wikipedia.org/wiki/RGBE_image_format
  51604. *
  51605. * @param uint8array The binary file stored in native array.
  51606. * @return The header information.
  51607. */
  51608. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51609. /**
  51610. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51611. * This RGBE texture needs to store the information as a panorama.
  51612. *
  51613. * More information on this format are available here:
  51614. * https://en.wikipedia.org/wiki/RGBE_image_format
  51615. *
  51616. * @param buffer The binary file stored in an array buffer.
  51617. * @param size The expected size of the extracted cubemap.
  51618. * @return The Cube Map information.
  51619. */
  51620. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51621. /**
  51622. * Returns the pixels data extracted from an RGBE texture.
  51623. * This pixels will be stored left to right up to down in the R G B order in one array.
  51624. *
  51625. * More information on this format are available here:
  51626. * https://en.wikipedia.org/wiki/RGBE_image_format
  51627. *
  51628. * @param uint8array The binary file stored in an array buffer.
  51629. * @param hdrInfo The header information of the file.
  51630. * @return The pixels data in RGB right to left up to down order.
  51631. */
  51632. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51633. private static RGBE_ReadPixels_RLE;
  51634. }
  51635. }
  51636. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51637. import { Nullable } from "babylonjs/types";
  51638. import { Scene } from "babylonjs/scene";
  51639. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51640. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51641. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51642. /**
  51643. * This represents a texture coming from an HDR input.
  51644. *
  51645. * The only supported format is currently panorama picture stored in RGBE format.
  51646. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51647. */
  51648. export class HDRCubeTexture extends BaseTexture {
  51649. private static _facesMapping;
  51650. private _generateHarmonics;
  51651. private _noMipmap;
  51652. private _textureMatrix;
  51653. private _size;
  51654. private _onLoad;
  51655. private _onError;
  51656. /**
  51657. * The texture URL.
  51658. */
  51659. url: string;
  51660. /**
  51661. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51662. */
  51663. coordinatesMode: number;
  51664. protected _isBlocking: boolean;
  51665. /**
  51666. * Sets wether or not the texture is blocking during loading.
  51667. */
  51668. /**
  51669. * Gets wether or not the texture is blocking during loading.
  51670. */
  51671. isBlocking: boolean;
  51672. protected _rotationY: number;
  51673. /**
  51674. * Sets texture matrix rotation angle around Y axis in radians.
  51675. */
  51676. /**
  51677. * Gets texture matrix rotation angle around Y axis radians.
  51678. */
  51679. rotationY: number;
  51680. /**
  51681. * Gets or sets the center of the bounding box associated with the cube texture
  51682. * It must define where the camera used to render the texture was set
  51683. */
  51684. boundingBoxPosition: Vector3;
  51685. private _boundingBoxSize;
  51686. /**
  51687. * Gets or sets the size of the bounding box associated with the cube texture
  51688. * When defined, the cubemap will switch to local mode
  51689. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51690. * @example https://www.babylonjs-playground.com/#RNASML
  51691. */
  51692. boundingBoxSize: Vector3;
  51693. /**
  51694. * Instantiates an HDRTexture from the following parameters.
  51695. *
  51696. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51697. * @param scene The scene the texture will be used in
  51698. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51699. * @param noMipmap Forces to not generate the mipmap if true
  51700. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51701. * @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)
  51702. * @param reserved Reserved flag for internal use.
  51703. */
  51704. 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>);
  51705. /**
  51706. * Get the current class name of the texture useful for serialization or dynamic coding.
  51707. * @returns "HDRCubeTexture"
  51708. */
  51709. getClassName(): string;
  51710. /**
  51711. * Occurs when the file is raw .hdr file.
  51712. */
  51713. private loadTexture;
  51714. clone(): HDRCubeTexture;
  51715. delayLoad(): void;
  51716. /**
  51717. * Get the texture reflection matrix used to rotate/transform the reflection.
  51718. * @returns the reflection matrix
  51719. */
  51720. getReflectionTextureMatrix(): Matrix;
  51721. /**
  51722. * Set the texture reflection matrix used to rotate/transform the reflection.
  51723. * @param value Define the reflection matrix to set
  51724. */
  51725. setReflectionTextureMatrix(value: Matrix): void;
  51726. /**
  51727. * Parses a JSON representation of an HDR Texture in order to create the texture
  51728. * @param parsedTexture Define the JSON representation
  51729. * @param scene Define the scene the texture should be created in
  51730. * @param rootUrl Define the root url in case we need to load relative dependencies
  51731. * @returns the newly created texture after parsing
  51732. */
  51733. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51734. serialize(): any;
  51735. }
  51736. }
  51737. declare module "babylonjs/Physics/physicsEngine" {
  51738. import { Nullable } from "babylonjs/types";
  51739. import { Vector3 } from "babylonjs/Maths/math.vector";
  51740. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51741. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51742. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51743. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51744. /**
  51745. * Class used to control physics engine
  51746. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51747. */
  51748. export class PhysicsEngine implements IPhysicsEngine {
  51749. private _physicsPlugin;
  51750. /**
  51751. * Global value used to control the smallest number supported by the simulation
  51752. */
  51753. static Epsilon: number;
  51754. private _impostors;
  51755. private _joints;
  51756. /**
  51757. * Gets the gravity vector used by the simulation
  51758. */
  51759. gravity: Vector3;
  51760. /**
  51761. * Factory used to create the default physics plugin.
  51762. * @returns The default physics plugin
  51763. */
  51764. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51765. /**
  51766. * Creates a new Physics Engine
  51767. * @param gravity defines the gravity vector used by the simulation
  51768. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51769. */
  51770. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51771. /**
  51772. * Sets the gravity vector used by the simulation
  51773. * @param gravity defines the gravity vector to use
  51774. */
  51775. setGravity(gravity: Vector3): void;
  51776. /**
  51777. * Set the time step of the physics engine.
  51778. * Default is 1/60.
  51779. * To slow it down, enter 1/600 for example.
  51780. * To speed it up, 1/30
  51781. * @param newTimeStep defines the new timestep to apply to this world.
  51782. */
  51783. setTimeStep(newTimeStep?: number): void;
  51784. /**
  51785. * Get the time step of the physics engine.
  51786. * @returns the current time step
  51787. */
  51788. getTimeStep(): number;
  51789. /**
  51790. * Release all resources
  51791. */
  51792. dispose(): void;
  51793. /**
  51794. * Gets the name of the current physics plugin
  51795. * @returns the name of the plugin
  51796. */
  51797. getPhysicsPluginName(): string;
  51798. /**
  51799. * Adding a new impostor for the impostor tracking.
  51800. * This will be done by the impostor itself.
  51801. * @param impostor the impostor to add
  51802. */
  51803. addImpostor(impostor: PhysicsImpostor): void;
  51804. /**
  51805. * Remove an impostor from the engine.
  51806. * This impostor and its mesh will not longer be updated by the physics engine.
  51807. * @param impostor the impostor to remove
  51808. */
  51809. removeImpostor(impostor: PhysicsImpostor): void;
  51810. /**
  51811. * Add a joint to the physics engine
  51812. * @param mainImpostor defines the main impostor to which the joint is added.
  51813. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51814. * @param joint defines the joint that will connect both impostors.
  51815. */
  51816. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51817. /**
  51818. * Removes a joint from the simulation
  51819. * @param mainImpostor defines the impostor used with the joint
  51820. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51821. * @param joint defines the joint to remove
  51822. */
  51823. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51824. /**
  51825. * Called by the scene. No need to call it.
  51826. * @param delta defines the timespam between frames
  51827. */
  51828. _step(delta: number): void;
  51829. /**
  51830. * Gets the current plugin used to run the simulation
  51831. * @returns current plugin
  51832. */
  51833. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51834. /**
  51835. * Gets the list of physic impostors
  51836. * @returns an array of PhysicsImpostor
  51837. */
  51838. getImpostors(): Array<PhysicsImpostor>;
  51839. /**
  51840. * Gets the impostor for a physics enabled object
  51841. * @param object defines the object impersonated by the impostor
  51842. * @returns the PhysicsImpostor or null if not found
  51843. */
  51844. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51845. /**
  51846. * Gets the impostor for a physics body object
  51847. * @param body defines physics body used by the impostor
  51848. * @returns the PhysicsImpostor or null if not found
  51849. */
  51850. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51851. /**
  51852. * Does a raycast in the physics world
  51853. * @param from when should the ray start?
  51854. * @param to when should the ray end?
  51855. * @returns PhysicsRaycastResult
  51856. */
  51857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51858. }
  51859. }
  51860. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51861. import { Nullable } from "babylonjs/types";
  51862. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51864. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51865. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51866. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51867. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51868. /** @hidden */
  51869. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51870. private _useDeltaForWorldStep;
  51871. world: any;
  51872. name: string;
  51873. private _physicsMaterials;
  51874. private _fixedTimeStep;
  51875. private _cannonRaycastResult;
  51876. private _raycastResult;
  51877. private _physicsBodysToRemoveAfterStep;
  51878. BJSCANNON: any;
  51879. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51880. setGravity(gravity: Vector3): void;
  51881. setTimeStep(timeStep: number): void;
  51882. getTimeStep(): number;
  51883. executeStep(delta: number): void;
  51884. private _removeMarkedPhysicsBodiesFromWorld;
  51885. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51888. private _processChildMeshes;
  51889. removePhysicsBody(impostor: PhysicsImpostor): void;
  51890. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51891. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51892. private _addMaterial;
  51893. private _checkWithEpsilon;
  51894. private _createShape;
  51895. private _createHeightmap;
  51896. private _minus90X;
  51897. private _plus90X;
  51898. private _tmpPosition;
  51899. private _tmpDeltaPosition;
  51900. private _tmpUnityRotation;
  51901. private _updatePhysicsBodyTransformation;
  51902. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51903. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51904. isSupported(): boolean;
  51905. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51906. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51907. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51908. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51909. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51910. getBodyMass(impostor: PhysicsImpostor): number;
  51911. getBodyFriction(impostor: PhysicsImpostor): number;
  51912. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51913. getBodyRestitution(impostor: PhysicsImpostor): number;
  51914. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51915. sleepBody(impostor: PhysicsImpostor): void;
  51916. wakeUpBody(impostor: PhysicsImpostor): void;
  51917. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51918. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51919. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51920. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51921. getRadius(impostor: PhysicsImpostor): number;
  51922. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51923. dispose(): void;
  51924. private _extendNamespace;
  51925. /**
  51926. * Does a raycast in the physics world
  51927. * @param from when should the ray start?
  51928. * @param to when should the ray end?
  51929. * @returns PhysicsRaycastResult
  51930. */
  51931. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51932. }
  51933. }
  51934. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51935. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51936. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51937. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51939. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51940. import { Nullable } from "babylonjs/types";
  51941. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51942. /** @hidden */
  51943. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51944. world: any;
  51945. name: string;
  51946. BJSOIMO: any;
  51947. private _raycastResult;
  51948. constructor(iterations?: number, oimoInjection?: any);
  51949. setGravity(gravity: Vector3): void;
  51950. setTimeStep(timeStep: number): void;
  51951. getTimeStep(): number;
  51952. private _tmpImpostorsArray;
  51953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51956. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51957. private _tmpPositionVector;
  51958. removePhysicsBody(impostor: PhysicsImpostor): void;
  51959. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51960. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51961. isSupported(): boolean;
  51962. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51964. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51965. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51966. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51967. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51968. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51969. getBodyMass(impostor: PhysicsImpostor): number;
  51970. getBodyFriction(impostor: PhysicsImpostor): number;
  51971. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51972. getBodyRestitution(impostor: PhysicsImpostor): number;
  51973. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51974. sleepBody(impostor: PhysicsImpostor): void;
  51975. wakeUpBody(impostor: PhysicsImpostor): void;
  51976. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51977. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51978. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51979. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51980. getRadius(impostor: PhysicsImpostor): number;
  51981. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51982. dispose(): void;
  51983. /**
  51984. * Does a raycast in the physics world
  51985. * @param from when should the ray start?
  51986. * @param to when should the ray end?
  51987. * @returns PhysicsRaycastResult
  51988. */
  51989. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51990. }
  51991. }
  51992. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51993. import { Nullable } from "babylonjs/types";
  51994. import { Scene } from "babylonjs/scene";
  51995. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51996. import { Color4 } from "babylonjs/Maths/math.color";
  51997. import { Mesh } from "babylonjs/Meshes/mesh";
  51998. /**
  51999. * Class containing static functions to help procedurally build meshes
  52000. */
  52001. export class RibbonBuilder {
  52002. /**
  52003. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52004. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52005. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52006. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52007. * * 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
  52008. * * 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
  52009. * * 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
  52010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52013. * * 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
  52014. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52015. * * 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
  52016. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52018. * @param name defines the name of the mesh
  52019. * @param options defines the options used to create the mesh
  52020. * @param scene defines the hosting scene
  52021. * @returns the ribbon mesh
  52022. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52024. */
  52025. static CreateRibbon(name: string, options: {
  52026. pathArray: Vector3[][];
  52027. closeArray?: boolean;
  52028. closePath?: boolean;
  52029. offset?: number;
  52030. updatable?: boolean;
  52031. sideOrientation?: number;
  52032. frontUVs?: Vector4;
  52033. backUVs?: Vector4;
  52034. instance?: Mesh;
  52035. invertUV?: boolean;
  52036. uvs?: Vector2[];
  52037. colors?: Color4[];
  52038. }, scene?: Nullable<Scene>): Mesh;
  52039. }
  52040. }
  52041. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52042. import { Nullable } from "babylonjs/types";
  52043. import { Scene } from "babylonjs/scene";
  52044. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52045. import { Mesh } from "babylonjs/Meshes/mesh";
  52046. /**
  52047. * Class containing static functions to help procedurally build meshes
  52048. */
  52049. export class ShapeBuilder {
  52050. /**
  52051. * 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.
  52052. * * 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.
  52053. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52054. * * 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.
  52055. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52056. * * 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
  52057. * * 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
  52058. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52063. * @param name defines the name of the mesh
  52064. * @param options defines the options used to create the mesh
  52065. * @param scene defines the hosting scene
  52066. * @returns the extruded shape mesh
  52067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52069. */
  52070. static ExtrudeShape(name: string, options: {
  52071. shape: Vector3[];
  52072. path: Vector3[];
  52073. scale?: number;
  52074. rotation?: number;
  52075. cap?: number;
  52076. updatable?: boolean;
  52077. sideOrientation?: number;
  52078. frontUVs?: Vector4;
  52079. backUVs?: Vector4;
  52080. instance?: Mesh;
  52081. invertUV?: boolean;
  52082. }, scene?: Nullable<Scene>): Mesh;
  52083. /**
  52084. * Creates an custom extruded shape mesh.
  52085. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52086. * * 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.
  52087. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52088. * * 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
  52089. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52090. * * 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
  52091. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52092. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52093. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52094. * * 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
  52095. * * 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
  52096. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52101. * @param name defines the name of the mesh
  52102. * @param options defines the options used to create the mesh
  52103. * @param scene defines the hosting scene
  52104. * @returns the custom extruded shape mesh
  52105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52108. */
  52109. static ExtrudeShapeCustom(name: string, options: {
  52110. shape: Vector3[];
  52111. path: Vector3[];
  52112. scaleFunction?: any;
  52113. rotationFunction?: any;
  52114. ribbonCloseArray?: boolean;
  52115. ribbonClosePath?: boolean;
  52116. cap?: number;
  52117. updatable?: boolean;
  52118. sideOrientation?: number;
  52119. frontUVs?: Vector4;
  52120. backUVs?: Vector4;
  52121. instance?: Mesh;
  52122. invertUV?: boolean;
  52123. }, scene?: Nullable<Scene>): Mesh;
  52124. private static _ExtrudeShapeGeneric;
  52125. }
  52126. }
  52127. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52128. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52129. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52130. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52131. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52132. import { Nullable } from "babylonjs/types";
  52133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52134. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52135. /**
  52136. * AmmoJS Physics plugin
  52137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52138. * @see https://github.com/kripken/ammo.js/
  52139. */
  52140. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52141. private _useDeltaForWorldStep;
  52142. /**
  52143. * Reference to the Ammo library
  52144. */
  52145. bjsAMMO: any;
  52146. /**
  52147. * Created ammoJS world which physics bodies are added to
  52148. */
  52149. world: any;
  52150. /**
  52151. * Name of the plugin
  52152. */
  52153. name: string;
  52154. private _timeStep;
  52155. private _fixedTimeStep;
  52156. private _maxSteps;
  52157. private _tmpQuaternion;
  52158. private _tmpAmmoTransform;
  52159. private _tmpAmmoQuaternion;
  52160. private _tmpAmmoConcreteContactResultCallback;
  52161. private _collisionConfiguration;
  52162. private _dispatcher;
  52163. private _overlappingPairCache;
  52164. private _solver;
  52165. private _softBodySolver;
  52166. private _tmpAmmoVectorA;
  52167. private _tmpAmmoVectorB;
  52168. private _tmpAmmoVectorC;
  52169. private _tmpAmmoVectorD;
  52170. private _tmpContactCallbackResult;
  52171. private _tmpAmmoVectorRCA;
  52172. private _tmpAmmoVectorRCB;
  52173. private _raycastResult;
  52174. private static readonly DISABLE_COLLISION_FLAG;
  52175. private static readonly KINEMATIC_FLAG;
  52176. private static readonly DISABLE_DEACTIVATION_FLAG;
  52177. /**
  52178. * Initializes the ammoJS plugin
  52179. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52180. * @param ammoInjection can be used to inject your own ammo reference
  52181. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52182. */
  52183. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52184. /**
  52185. * Sets the gravity of the physics world (m/(s^2))
  52186. * @param gravity Gravity to set
  52187. */
  52188. setGravity(gravity: Vector3): void;
  52189. /**
  52190. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52191. * @param timeStep timestep to use in seconds
  52192. */
  52193. setTimeStep(timeStep: number): void;
  52194. /**
  52195. * 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)
  52196. * @param fixedTimeStep fixedTimeStep to use in seconds
  52197. */
  52198. setFixedTimeStep(fixedTimeStep: number): void;
  52199. /**
  52200. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52201. * @param maxSteps the maximum number of steps by the physics engine per frame
  52202. */
  52203. setMaxSteps(maxSteps: number): void;
  52204. /**
  52205. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52206. * @returns the current timestep in seconds
  52207. */
  52208. getTimeStep(): number;
  52209. private _isImpostorInContact;
  52210. private _isImpostorPairInContact;
  52211. private _stepSimulation;
  52212. /**
  52213. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52214. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52215. * After the step the babylon meshes are set to the position of the physics imposters
  52216. * @param delta amount of time to step forward
  52217. * @param impostors array of imposters to update before/after the step
  52218. */
  52219. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52220. /**
  52221. * Update babylon mesh to match physics world object
  52222. * @param impostor imposter to match
  52223. */
  52224. private _afterSoftStep;
  52225. /**
  52226. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52227. * @param impostor imposter to match
  52228. */
  52229. private _ropeStep;
  52230. /**
  52231. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52232. * @param impostor imposter to match
  52233. */
  52234. private _softbodyOrClothStep;
  52235. private _tmpVector;
  52236. private _tmpMatrix;
  52237. /**
  52238. * Applies an impulse on the imposter
  52239. * @param impostor imposter to apply impulse to
  52240. * @param force amount of force to be applied to the imposter
  52241. * @param contactPoint the location to apply the impulse on the imposter
  52242. */
  52243. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52244. /**
  52245. * Applies a force on the imposter
  52246. * @param impostor imposter to apply force
  52247. * @param force amount of force to be applied to the imposter
  52248. * @param contactPoint the location to apply the force on the imposter
  52249. */
  52250. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52251. /**
  52252. * Creates a physics body using the plugin
  52253. * @param impostor the imposter to create the physics body on
  52254. */
  52255. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52256. /**
  52257. * Removes the physics body from the imposter and disposes of the body's memory
  52258. * @param impostor imposter to remove the physics body from
  52259. */
  52260. removePhysicsBody(impostor: PhysicsImpostor): void;
  52261. /**
  52262. * Generates a joint
  52263. * @param impostorJoint the imposter joint to create the joint with
  52264. */
  52265. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52266. /**
  52267. * Removes a joint
  52268. * @param impostorJoint the imposter joint to remove the joint from
  52269. */
  52270. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52271. private _addMeshVerts;
  52272. /**
  52273. * Initialise the soft body vertices to match its object's (mesh) vertices
  52274. * Softbody vertices (nodes) are in world space and to match this
  52275. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52276. * @param impostor to create the softbody for
  52277. */
  52278. private _softVertexData;
  52279. /**
  52280. * Create an impostor's soft body
  52281. * @param impostor to create the softbody for
  52282. */
  52283. private _createSoftbody;
  52284. /**
  52285. * Create cloth for an impostor
  52286. * @param impostor to create the softbody for
  52287. */
  52288. private _createCloth;
  52289. /**
  52290. * Create rope for an impostor
  52291. * @param impostor to create the softbody for
  52292. */
  52293. private _createRope;
  52294. private _addHullVerts;
  52295. private _createShape;
  52296. /**
  52297. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52298. * @param impostor imposter containing the physics body and babylon object
  52299. */
  52300. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52301. /**
  52302. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52303. * @param impostor imposter containing the physics body and babylon object
  52304. * @param newPosition new position
  52305. * @param newRotation new rotation
  52306. */
  52307. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52308. /**
  52309. * If this plugin is supported
  52310. * @returns true if its supported
  52311. */
  52312. isSupported(): boolean;
  52313. /**
  52314. * Sets the linear velocity of the physics body
  52315. * @param impostor imposter to set the velocity on
  52316. * @param velocity velocity to set
  52317. */
  52318. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52319. /**
  52320. * Sets the angular velocity of the physics body
  52321. * @param impostor imposter to set the velocity on
  52322. * @param velocity velocity to set
  52323. */
  52324. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52325. /**
  52326. * gets the linear velocity
  52327. * @param impostor imposter to get linear velocity from
  52328. * @returns linear velocity
  52329. */
  52330. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52331. /**
  52332. * gets the angular velocity
  52333. * @param impostor imposter to get angular velocity from
  52334. * @returns angular velocity
  52335. */
  52336. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52337. /**
  52338. * Sets the mass of physics body
  52339. * @param impostor imposter to set the mass on
  52340. * @param mass mass to set
  52341. */
  52342. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52343. /**
  52344. * Gets the mass of the physics body
  52345. * @param impostor imposter to get the mass from
  52346. * @returns mass
  52347. */
  52348. getBodyMass(impostor: PhysicsImpostor): number;
  52349. /**
  52350. * Gets friction of the impostor
  52351. * @param impostor impostor to get friction from
  52352. * @returns friction value
  52353. */
  52354. getBodyFriction(impostor: PhysicsImpostor): number;
  52355. /**
  52356. * Sets friction of the impostor
  52357. * @param impostor impostor to set friction on
  52358. * @param friction friction value
  52359. */
  52360. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52361. /**
  52362. * Gets restitution of the impostor
  52363. * @param impostor impostor to get restitution from
  52364. * @returns restitution value
  52365. */
  52366. getBodyRestitution(impostor: PhysicsImpostor): number;
  52367. /**
  52368. * Sets resitution of the impostor
  52369. * @param impostor impostor to set resitution on
  52370. * @param restitution resitution value
  52371. */
  52372. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52373. /**
  52374. * Gets pressure inside the impostor
  52375. * @param impostor impostor to get pressure from
  52376. * @returns pressure value
  52377. */
  52378. getBodyPressure(impostor: PhysicsImpostor): number;
  52379. /**
  52380. * Sets pressure inside a soft body impostor
  52381. * Cloth and rope must remain 0 pressure
  52382. * @param impostor impostor to set pressure on
  52383. * @param pressure pressure value
  52384. */
  52385. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52386. /**
  52387. * Gets stiffness of the impostor
  52388. * @param impostor impostor to get stiffness from
  52389. * @returns pressure value
  52390. */
  52391. getBodyStiffness(impostor: PhysicsImpostor): number;
  52392. /**
  52393. * Sets stiffness of the impostor
  52394. * @param impostor impostor to set stiffness on
  52395. * @param stiffness stiffness value from 0 to 1
  52396. */
  52397. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52398. /**
  52399. * Gets velocityIterations of the impostor
  52400. * @param impostor impostor to get velocity iterations from
  52401. * @returns velocityIterations value
  52402. */
  52403. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52404. /**
  52405. * Sets velocityIterations of the impostor
  52406. * @param impostor impostor to set velocity iterations on
  52407. * @param velocityIterations velocityIterations value
  52408. */
  52409. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52410. /**
  52411. * Gets positionIterations of the impostor
  52412. * @param impostor impostor to get position iterations from
  52413. * @returns positionIterations value
  52414. */
  52415. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52416. /**
  52417. * Sets positionIterations of the impostor
  52418. * @param impostor impostor to set position on
  52419. * @param positionIterations positionIterations value
  52420. */
  52421. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52422. /**
  52423. * Append an anchor to a cloth object
  52424. * @param impostor is the cloth impostor to add anchor to
  52425. * @param otherImpostor is the rigid impostor to anchor to
  52426. * @param width ratio across width from 0 to 1
  52427. * @param height ratio up height from 0 to 1
  52428. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52429. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52430. */
  52431. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52432. /**
  52433. * Append an hook to a rope object
  52434. * @param impostor is the rope impostor to add hook to
  52435. * @param otherImpostor is the rigid impostor to hook to
  52436. * @param length ratio along the rope from 0 to 1
  52437. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52438. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52439. */
  52440. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52441. /**
  52442. * Sleeps the physics body and stops it from being active
  52443. * @param impostor impostor to sleep
  52444. */
  52445. sleepBody(impostor: PhysicsImpostor): void;
  52446. /**
  52447. * Activates the physics body
  52448. * @param impostor impostor to activate
  52449. */
  52450. wakeUpBody(impostor: PhysicsImpostor): void;
  52451. /**
  52452. * Updates the distance parameters of the joint
  52453. * @param joint joint to update
  52454. * @param maxDistance maximum distance of the joint
  52455. * @param minDistance minimum distance of the joint
  52456. */
  52457. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52458. /**
  52459. * Sets a motor on the joint
  52460. * @param joint joint to set motor on
  52461. * @param speed speed of the motor
  52462. * @param maxForce maximum force of the motor
  52463. * @param motorIndex index of the motor
  52464. */
  52465. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52466. /**
  52467. * Sets the motors limit
  52468. * @param joint joint to set limit on
  52469. * @param upperLimit upper limit
  52470. * @param lowerLimit lower limit
  52471. */
  52472. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52473. /**
  52474. * Syncs the position and rotation of a mesh with the impostor
  52475. * @param mesh mesh to sync
  52476. * @param impostor impostor to update the mesh with
  52477. */
  52478. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52479. /**
  52480. * Gets the radius of the impostor
  52481. * @param impostor impostor to get radius from
  52482. * @returns the radius
  52483. */
  52484. getRadius(impostor: PhysicsImpostor): number;
  52485. /**
  52486. * Gets the box size of the impostor
  52487. * @param impostor impostor to get box size from
  52488. * @param result the resulting box size
  52489. */
  52490. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52491. /**
  52492. * Disposes of the impostor
  52493. */
  52494. dispose(): void;
  52495. /**
  52496. * Does a raycast in the physics world
  52497. * @param from when should the ray start?
  52498. * @param to when should the ray end?
  52499. * @returns PhysicsRaycastResult
  52500. */
  52501. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52502. }
  52503. }
  52504. declare module "babylonjs/Probes/reflectionProbe" {
  52505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52506. import { Vector3 } from "babylonjs/Maths/math.vector";
  52507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52508. import { Nullable } from "babylonjs/types";
  52509. import { Scene } from "babylonjs/scene";
  52510. module "babylonjs/abstractScene" {
  52511. interface AbstractScene {
  52512. /**
  52513. * The list of reflection probes added to the scene
  52514. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52515. */
  52516. reflectionProbes: Array<ReflectionProbe>;
  52517. /**
  52518. * Removes the given reflection probe from this scene.
  52519. * @param toRemove The reflection probe to remove
  52520. * @returns The index of the removed reflection probe
  52521. */
  52522. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52523. /**
  52524. * Adds the given reflection probe to this scene.
  52525. * @param newReflectionProbe The reflection probe to add
  52526. */
  52527. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52528. }
  52529. }
  52530. /**
  52531. * Class used to generate realtime reflection / refraction cube textures
  52532. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52533. */
  52534. export class ReflectionProbe {
  52535. /** defines the name of the probe */
  52536. name: string;
  52537. private _scene;
  52538. private _renderTargetTexture;
  52539. private _projectionMatrix;
  52540. private _viewMatrix;
  52541. private _target;
  52542. private _add;
  52543. private _attachedMesh;
  52544. private _invertYAxis;
  52545. /** Gets or sets probe position (center of the cube map) */
  52546. position: Vector3;
  52547. /**
  52548. * Creates a new reflection probe
  52549. * @param name defines the name of the probe
  52550. * @param size defines the texture resolution (for each face)
  52551. * @param scene defines the hosting scene
  52552. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52553. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52554. */
  52555. constructor(
  52556. /** defines the name of the probe */
  52557. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52558. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52559. samples: number;
  52560. /** Gets or sets the refresh rate to use (on every frame by default) */
  52561. refreshRate: number;
  52562. /**
  52563. * Gets the hosting scene
  52564. * @returns a Scene
  52565. */
  52566. getScene(): Scene;
  52567. /** Gets the internal CubeTexture used to render to */
  52568. readonly cubeTexture: RenderTargetTexture;
  52569. /** Gets the list of meshes to render */
  52570. readonly renderList: Nullable<AbstractMesh[]>;
  52571. /**
  52572. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52573. * @param mesh defines the mesh to attach to
  52574. */
  52575. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52576. /**
  52577. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52578. * @param renderingGroupId The rendering group id corresponding to its index
  52579. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52580. */
  52581. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52582. /**
  52583. * Clean all associated resources
  52584. */
  52585. dispose(): void;
  52586. /**
  52587. * Converts the reflection probe information to a readable string for debug purpose.
  52588. * @param fullDetails Supports for multiple levels of logging within scene loading
  52589. * @returns the human readable reflection probe info
  52590. */
  52591. toString(fullDetails?: boolean): string;
  52592. /**
  52593. * Get the class name of the relfection probe.
  52594. * @returns "ReflectionProbe"
  52595. */
  52596. getClassName(): string;
  52597. /**
  52598. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52599. * @returns The JSON representation of the texture
  52600. */
  52601. serialize(): any;
  52602. /**
  52603. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52604. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52605. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52606. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52607. * @returns The parsed reflection probe if successful
  52608. */
  52609. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52610. }
  52611. }
  52612. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52613. /** @hidden */
  52614. export var _BabylonLoaderRegistered: boolean;
  52615. }
  52616. declare module "babylonjs/Loading/Plugins/index" {
  52617. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52618. }
  52619. declare module "babylonjs/Loading/index" {
  52620. export * from "babylonjs/Loading/loadingScreen";
  52621. export * from "babylonjs/Loading/Plugins/index";
  52622. export * from "babylonjs/Loading/sceneLoader";
  52623. export * from "babylonjs/Loading/sceneLoaderFlags";
  52624. }
  52625. declare module "babylonjs/Materials/Background/index" {
  52626. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52627. }
  52628. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52629. import { Scene } from "babylonjs/scene";
  52630. import { Color3 } from "babylonjs/Maths/math.color";
  52631. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52633. /**
  52634. * The Physically based simple base material of BJS.
  52635. *
  52636. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52637. * It is used as the base class for both the specGloss and metalRough conventions.
  52638. */
  52639. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52640. /**
  52641. * Number of Simultaneous lights allowed on the material.
  52642. */
  52643. maxSimultaneousLights: number;
  52644. /**
  52645. * If sets to true, disables all the lights affecting the material.
  52646. */
  52647. disableLighting: boolean;
  52648. /**
  52649. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52650. */
  52651. environmentTexture: BaseTexture;
  52652. /**
  52653. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52654. */
  52655. invertNormalMapX: boolean;
  52656. /**
  52657. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52658. */
  52659. invertNormalMapY: boolean;
  52660. /**
  52661. * Normal map used in the model.
  52662. */
  52663. normalTexture: BaseTexture;
  52664. /**
  52665. * Emissivie color used to self-illuminate the model.
  52666. */
  52667. emissiveColor: Color3;
  52668. /**
  52669. * Emissivie texture used to self-illuminate the model.
  52670. */
  52671. emissiveTexture: BaseTexture;
  52672. /**
  52673. * Occlusion Channel Strenght.
  52674. */
  52675. occlusionStrength: number;
  52676. /**
  52677. * Occlusion Texture of the material (adding extra occlusion effects).
  52678. */
  52679. occlusionTexture: BaseTexture;
  52680. /**
  52681. * Defines the alpha limits in alpha test mode.
  52682. */
  52683. alphaCutOff: number;
  52684. /**
  52685. * Gets the current double sided mode.
  52686. */
  52687. /**
  52688. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52689. */
  52690. doubleSided: boolean;
  52691. /**
  52692. * Stores the pre-calculated light information of a mesh in a texture.
  52693. */
  52694. lightmapTexture: BaseTexture;
  52695. /**
  52696. * If true, the light map contains occlusion information instead of lighting info.
  52697. */
  52698. useLightmapAsShadowmap: boolean;
  52699. /**
  52700. * Instantiates a new PBRMaterial instance.
  52701. *
  52702. * @param name The material name
  52703. * @param scene The scene the material will be use in.
  52704. */
  52705. constructor(name: string, scene: Scene);
  52706. getClassName(): string;
  52707. }
  52708. }
  52709. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52710. import { Scene } from "babylonjs/scene";
  52711. import { Color3 } from "babylonjs/Maths/math.color";
  52712. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52713. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52714. /**
  52715. * The PBR material of BJS following the metal roughness convention.
  52716. *
  52717. * This fits to the PBR convention in the GLTF definition:
  52718. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52719. */
  52720. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52721. /**
  52722. * The base color has two different interpretations depending on the value of metalness.
  52723. * When the material is a metal, the base color is the specific measured reflectance value
  52724. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52725. * of the material.
  52726. */
  52727. baseColor: Color3;
  52728. /**
  52729. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52730. * well as opacity information in the alpha channel.
  52731. */
  52732. baseTexture: BaseTexture;
  52733. /**
  52734. * Specifies the metallic scalar value of the material.
  52735. * Can also be used to scale the metalness values of the metallic texture.
  52736. */
  52737. metallic: number;
  52738. /**
  52739. * Specifies the roughness scalar value of the material.
  52740. * Can also be used to scale the roughness values of the metallic texture.
  52741. */
  52742. roughness: number;
  52743. /**
  52744. * Texture containing both the metallic value in the B channel and the
  52745. * roughness value in the G channel to keep better precision.
  52746. */
  52747. metallicRoughnessTexture: BaseTexture;
  52748. /**
  52749. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52750. *
  52751. * @param name The material name
  52752. * @param scene The scene the material will be use in.
  52753. */
  52754. constructor(name: string, scene: Scene);
  52755. /**
  52756. * Return the currrent class name of the material.
  52757. */
  52758. getClassName(): string;
  52759. /**
  52760. * Makes a duplicate of the current material.
  52761. * @param name - name to use for the new material.
  52762. */
  52763. clone(name: string): PBRMetallicRoughnessMaterial;
  52764. /**
  52765. * Serialize the material to a parsable JSON object.
  52766. */
  52767. serialize(): any;
  52768. /**
  52769. * Parses a JSON object correponding to the serialize function.
  52770. */
  52771. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52772. }
  52773. }
  52774. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52775. import { Scene } from "babylonjs/scene";
  52776. import { Color3 } from "babylonjs/Maths/math.color";
  52777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52778. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52779. /**
  52780. * The PBR material of BJS following the specular glossiness convention.
  52781. *
  52782. * This fits to the PBR convention in the GLTF definition:
  52783. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52784. */
  52785. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52786. /**
  52787. * Specifies the diffuse color of the material.
  52788. */
  52789. diffuseColor: Color3;
  52790. /**
  52791. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52792. * channel.
  52793. */
  52794. diffuseTexture: BaseTexture;
  52795. /**
  52796. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52797. */
  52798. specularColor: Color3;
  52799. /**
  52800. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52801. */
  52802. glossiness: number;
  52803. /**
  52804. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52805. */
  52806. specularGlossinessTexture: BaseTexture;
  52807. /**
  52808. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52809. *
  52810. * @param name The material name
  52811. * @param scene The scene the material will be use in.
  52812. */
  52813. constructor(name: string, scene: Scene);
  52814. /**
  52815. * Return the currrent class name of the material.
  52816. */
  52817. getClassName(): string;
  52818. /**
  52819. * Makes a duplicate of the current material.
  52820. * @param name - name to use for the new material.
  52821. */
  52822. clone(name: string): PBRSpecularGlossinessMaterial;
  52823. /**
  52824. * Serialize the material to a parsable JSON object.
  52825. */
  52826. serialize(): any;
  52827. /**
  52828. * Parses a JSON object correponding to the serialize function.
  52829. */
  52830. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52831. }
  52832. }
  52833. declare module "babylonjs/Materials/PBR/index" {
  52834. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52835. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52836. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52837. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52838. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52839. }
  52840. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52841. import { Nullable } from "babylonjs/types";
  52842. import { Scene } from "babylonjs/scene";
  52843. import { Matrix } from "babylonjs/Maths/math.vector";
  52844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52845. /**
  52846. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52847. * It can help converting any input color in a desired output one. This can then be used to create effects
  52848. * from sepia, black and white to sixties or futuristic rendering...
  52849. *
  52850. * The only supported format is currently 3dl.
  52851. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52852. */
  52853. export class ColorGradingTexture extends BaseTexture {
  52854. /**
  52855. * The current texture matrix. (will always be identity in color grading texture)
  52856. */
  52857. private _textureMatrix;
  52858. /**
  52859. * The texture URL.
  52860. */
  52861. url: string;
  52862. /**
  52863. * Empty line regex stored for GC.
  52864. */
  52865. private static _noneEmptyLineRegex;
  52866. private _engine;
  52867. /**
  52868. * Instantiates a ColorGradingTexture from the following parameters.
  52869. *
  52870. * @param url The location of the color gradind data (currently only supporting 3dl)
  52871. * @param scene The scene the texture will be used in
  52872. */
  52873. constructor(url: string, scene: Scene);
  52874. /**
  52875. * Returns the texture matrix used in most of the material.
  52876. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52877. */
  52878. getTextureMatrix(): Matrix;
  52879. /**
  52880. * Occurs when the file being loaded is a .3dl LUT file.
  52881. */
  52882. private load3dlTexture;
  52883. /**
  52884. * Starts the loading process of the texture.
  52885. */
  52886. private loadTexture;
  52887. /**
  52888. * Clones the color gradind texture.
  52889. */
  52890. clone(): ColorGradingTexture;
  52891. /**
  52892. * Called during delayed load for textures.
  52893. */
  52894. delayLoad(): void;
  52895. /**
  52896. * Parses a color grading texture serialized by Babylon.
  52897. * @param parsedTexture The texture information being parsedTexture
  52898. * @param scene The scene to load the texture in
  52899. * @param rootUrl The root url of the data assets to load
  52900. * @return A color gradind texture
  52901. */
  52902. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52903. /**
  52904. * Serializes the LUT texture to json format.
  52905. */
  52906. serialize(): any;
  52907. }
  52908. }
  52909. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52910. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52911. import { Scene } from "babylonjs/scene";
  52912. import { Nullable } from "babylonjs/types";
  52913. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52914. /**
  52915. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52916. */
  52917. export class EquiRectangularCubeTexture extends BaseTexture {
  52918. /** The six faces of the cube. */
  52919. private static _FacesMapping;
  52920. private _noMipmap;
  52921. private _onLoad;
  52922. private _onError;
  52923. /** The size of the cubemap. */
  52924. private _size;
  52925. /** The buffer of the image. */
  52926. private _buffer;
  52927. /** The width of the input image. */
  52928. private _width;
  52929. /** The height of the input image. */
  52930. private _height;
  52931. /** The URL to the image. */
  52932. url: string;
  52933. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52934. coordinatesMode: number;
  52935. /**
  52936. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52937. * @param url The location of the image
  52938. * @param scene The scene the texture will be used in
  52939. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52940. * @param noMipmap Forces to not generate the mipmap if true
  52941. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52942. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52943. * @param onLoad — defines a callback called when texture is loaded
  52944. * @param onError — defines a callback called if there is an error
  52945. */
  52946. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52947. /**
  52948. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52949. */
  52950. private loadImage;
  52951. /**
  52952. * Convert the image buffer into a cubemap and create a CubeTexture.
  52953. */
  52954. private loadTexture;
  52955. /**
  52956. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52957. * @param buffer The ArrayBuffer that should be converted.
  52958. * @returns The buffer as Float32Array.
  52959. */
  52960. private getFloat32ArrayFromArrayBuffer;
  52961. /**
  52962. * Get the current class name of the texture useful for serialization or dynamic coding.
  52963. * @returns "EquiRectangularCubeTexture"
  52964. */
  52965. getClassName(): string;
  52966. /**
  52967. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52968. * @returns A clone of the current EquiRectangularCubeTexture.
  52969. */
  52970. clone(): EquiRectangularCubeTexture;
  52971. }
  52972. }
  52973. declare module "babylonjs/Misc/tga" {
  52974. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52975. /**
  52976. * Based on jsTGALoader - Javascript loader for TGA file
  52977. * By Vincent Thibault
  52978. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52979. */
  52980. export class TGATools {
  52981. private static _TYPE_INDEXED;
  52982. private static _TYPE_RGB;
  52983. private static _TYPE_GREY;
  52984. private static _TYPE_RLE_INDEXED;
  52985. private static _TYPE_RLE_RGB;
  52986. private static _TYPE_RLE_GREY;
  52987. private static _ORIGIN_MASK;
  52988. private static _ORIGIN_SHIFT;
  52989. private static _ORIGIN_BL;
  52990. private static _ORIGIN_BR;
  52991. private static _ORIGIN_UL;
  52992. private static _ORIGIN_UR;
  52993. /**
  52994. * Gets the header of a TGA file
  52995. * @param data defines the TGA data
  52996. * @returns the header
  52997. */
  52998. static GetTGAHeader(data: Uint8Array): any;
  52999. /**
  53000. * Uploads TGA content to a Babylon Texture
  53001. * @hidden
  53002. */
  53003. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53004. /** @hidden */
  53005. 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;
  53006. /** @hidden */
  53007. 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;
  53008. /** @hidden */
  53009. 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;
  53010. /** @hidden */
  53011. 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;
  53012. /** @hidden */
  53013. 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;
  53014. /** @hidden */
  53015. 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;
  53016. }
  53017. }
  53018. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53019. import { Nullable } from "babylonjs/types";
  53020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53021. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53022. /**
  53023. * Implementation of the TGA Texture Loader.
  53024. * @hidden
  53025. */
  53026. export class _TGATextureLoader implements IInternalTextureLoader {
  53027. /**
  53028. * Defines wether the loader supports cascade loading the different faces.
  53029. */
  53030. readonly supportCascades: boolean;
  53031. /**
  53032. * This returns if the loader support the current file information.
  53033. * @param extension defines the file extension of the file being loaded
  53034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53035. * @param fallback defines the fallback internal texture if any
  53036. * @param isBase64 defines whether the texture is encoded as a base64
  53037. * @param isBuffer defines whether the texture data are stored as a buffer
  53038. * @returns true if the loader can load the specified file
  53039. */
  53040. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53041. /**
  53042. * Transform the url before loading if required.
  53043. * @param rootUrl the url of the texture
  53044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53045. * @returns the transformed texture
  53046. */
  53047. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53048. /**
  53049. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53050. * @param rootUrl the url of the texture
  53051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53052. * @returns the fallback texture
  53053. */
  53054. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53055. /**
  53056. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53057. * @param data contains the texture data
  53058. * @param texture defines the BabylonJS internal texture
  53059. * @param createPolynomials will be true if polynomials have been requested
  53060. * @param onLoad defines the callback to trigger once the texture is ready
  53061. * @param onError defines the callback to trigger in case of error
  53062. */
  53063. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53064. /**
  53065. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53066. * @param data contains the texture data
  53067. * @param texture defines the BabylonJS internal texture
  53068. * @param callback defines the method to call once ready to upload
  53069. */
  53070. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53071. }
  53072. }
  53073. declare module "babylonjs/Misc/basis" {
  53074. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53075. /**
  53076. * Info about the .basis files
  53077. */
  53078. class BasisFileInfo {
  53079. /**
  53080. * If the file has alpha
  53081. */
  53082. hasAlpha: boolean;
  53083. /**
  53084. * Info about each image of the basis file
  53085. */
  53086. images: Array<{
  53087. levels: Array<{
  53088. width: number;
  53089. height: number;
  53090. transcodedPixels: ArrayBufferView;
  53091. }>;
  53092. }>;
  53093. }
  53094. /**
  53095. * Result of transcoding a basis file
  53096. */
  53097. class TranscodeResult {
  53098. /**
  53099. * Info about the .basis file
  53100. */
  53101. fileInfo: BasisFileInfo;
  53102. /**
  53103. * Format to use when loading the file
  53104. */
  53105. format: number;
  53106. }
  53107. /**
  53108. * Configuration options for the Basis transcoder
  53109. */
  53110. export class BasisTranscodeConfiguration {
  53111. /**
  53112. * Supported compression formats used to determine the supported output format of the transcoder
  53113. */
  53114. supportedCompressionFormats?: {
  53115. /**
  53116. * etc1 compression format
  53117. */
  53118. etc1?: boolean;
  53119. /**
  53120. * s3tc compression format
  53121. */
  53122. s3tc?: boolean;
  53123. /**
  53124. * pvrtc compression format
  53125. */
  53126. pvrtc?: boolean;
  53127. /**
  53128. * etc2 compression format
  53129. */
  53130. etc2?: boolean;
  53131. };
  53132. /**
  53133. * If mipmap levels should be loaded for transcoded images (Default: true)
  53134. */
  53135. loadMipmapLevels?: boolean;
  53136. /**
  53137. * Index of a single image to load (Default: all images)
  53138. */
  53139. loadSingleImage?: number;
  53140. }
  53141. /**
  53142. * Used to load .Basis files
  53143. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53144. */
  53145. export class BasisTools {
  53146. private static _IgnoreSupportedFormats;
  53147. /**
  53148. * URL to use when loading the basis transcoder
  53149. */
  53150. static JSModuleURL: string;
  53151. /**
  53152. * URL to use when loading the wasm module for the transcoder
  53153. */
  53154. static WasmModuleURL: string;
  53155. /**
  53156. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53157. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53158. * @returns internal format corresponding to the Basis format
  53159. */
  53160. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53161. private static _WorkerPromise;
  53162. private static _Worker;
  53163. private static _actionId;
  53164. private static _CreateWorkerAsync;
  53165. /**
  53166. * Transcodes a loaded image file to compressed pixel data
  53167. * @param imageData image data to transcode
  53168. * @param config configuration options for the transcoding
  53169. * @returns a promise resulting in the transcoded image
  53170. */
  53171. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53172. /**
  53173. * Loads a texture from the transcode result
  53174. * @param texture texture load to
  53175. * @param transcodeResult the result of transcoding the basis file to load from
  53176. */
  53177. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53178. }
  53179. }
  53180. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53181. import { Nullable } from "babylonjs/types";
  53182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53183. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53184. /**
  53185. * Loader for .basis file format
  53186. */
  53187. export class _BasisTextureLoader implements IInternalTextureLoader {
  53188. /**
  53189. * Defines whether the loader supports cascade loading the different faces.
  53190. */
  53191. readonly supportCascades: boolean;
  53192. /**
  53193. * This returns if the loader support the current file information.
  53194. * @param extension defines the file extension of the file being loaded
  53195. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53196. * @param fallback defines the fallback internal texture if any
  53197. * @param isBase64 defines whether the texture is encoded as a base64
  53198. * @param isBuffer defines whether the texture data are stored as a buffer
  53199. * @returns true if the loader can load the specified file
  53200. */
  53201. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53202. /**
  53203. * Transform the url before loading if required.
  53204. * @param rootUrl the url of the texture
  53205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53206. * @returns the transformed texture
  53207. */
  53208. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53209. /**
  53210. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53211. * @param rootUrl the url of the texture
  53212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53213. * @returns the fallback texture
  53214. */
  53215. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53216. /**
  53217. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53218. * @param data contains the texture data
  53219. * @param texture defines the BabylonJS internal texture
  53220. * @param createPolynomials will be true if polynomials have been requested
  53221. * @param onLoad defines the callback to trigger once the texture is ready
  53222. * @param onError defines the callback to trigger in case of error
  53223. */
  53224. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53225. /**
  53226. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53227. * @param data contains the texture data
  53228. * @param texture defines the BabylonJS internal texture
  53229. * @param callback defines the method to call once ready to upload
  53230. */
  53231. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53232. }
  53233. }
  53234. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53235. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53236. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53237. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53238. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53239. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53240. }
  53241. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53242. import { Scene } from "babylonjs/scene";
  53243. import { Texture } from "babylonjs/Materials/Textures/texture";
  53244. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53245. /**
  53246. * 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.
  53247. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53248. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53249. */
  53250. export class CustomProceduralTexture extends ProceduralTexture {
  53251. private _animate;
  53252. private _time;
  53253. private _config;
  53254. private _texturePath;
  53255. /**
  53256. * Instantiates a new Custom Procedural Texture.
  53257. * 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.
  53258. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53259. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53260. * @param name Define the name of the texture
  53261. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53262. * @param size Define the size of the texture to create
  53263. * @param scene Define the scene the texture belongs to
  53264. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53265. * @param generateMipMaps Define if the texture should creates mip maps or not
  53266. */
  53267. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53268. private _loadJson;
  53269. /**
  53270. * Is the texture ready to be used ? (rendered at least once)
  53271. * @returns true if ready, otherwise, false.
  53272. */
  53273. isReady(): boolean;
  53274. /**
  53275. * Render the texture to its associated render target.
  53276. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53277. */
  53278. render(useCameraPostProcess?: boolean): void;
  53279. /**
  53280. * Update the list of dependant textures samplers in the shader.
  53281. */
  53282. updateTextures(): void;
  53283. /**
  53284. * Update the uniform values of the procedural texture in the shader.
  53285. */
  53286. updateShaderUniforms(): void;
  53287. /**
  53288. * Define if the texture animates or not.
  53289. */
  53290. animate: boolean;
  53291. }
  53292. }
  53293. declare module "babylonjs/Shaders/noise.fragment" {
  53294. /** @hidden */
  53295. export var noisePixelShader: {
  53296. name: string;
  53297. shader: string;
  53298. };
  53299. }
  53300. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53301. import { Nullable } from "babylonjs/types";
  53302. import { Scene } from "babylonjs/scene";
  53303. import { Texture } from "babylonjs/Materials/Textures/texture";
  53304. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53305. import "babylonjs/Shaders/noise.fragment";
  53306. /**
  53307. * Class used to generate noise procedural textures
  53308. */
  53309. export class NoiseProceduralTexture extends ProceduralTexture {
  53310. private _time;
  53311. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53312. brightness: number;
  53313. /** Defines the number of octaves to process */
  53314. octaves: number;
  53315. /** Defines the level of persistence (0.8 by default) */
  53316. persistence: number;
  53317. /** Gets or sets animation speed factor (default is 1) */
  53318. animationSpeedFactor: number;
  53319. /**
  53320. * Creates a new NoiseProceduralTexture
  53321. * @param name defines the name fo the texture
  53322. * @param size defines the size of the texture (default is 256)
  53323. * @param scene defines the hosting scene
  53324. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53325. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53326. */
  53327. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53328. private _updateShaderUniforms;
  53329. protected _getDefines(): string;
  53330. /** Generate the current state of the procedural texture */
  53331. render(useCameraPostProcess?: boolean): void;
  53332. /**
  53333. * Serializes this noise procedural texture
  53334. * @returns a serialized noise procedural texture object
  53335. */
  53336. serialize(): any;
  53337. /**
  53338. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53339. * @param parsedTexture defines parsed texture data
  53340. * @param scene defines the current scene
  53341. * @param rootUrl defines the root URL containing noise procedural texture information
  53342. * @returns a parsed NoiseProceduralTexture
  53343. */
  53344. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53345. }
  53346. }
  53347. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53348. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53349. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53350. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53351. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53352. }
  53353. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53354. import { Nullable } from "babylonjs/types";
  53355. import { Scene } from "babylonjs/scene";
  53356. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53357. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53358. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53359. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53360. /**
  53361. * Raw cube texture where the raw buffers are passed in
  53362. */
  53363. export class RawCubeTexture extends CubeTexture {
  53364. /**
  53365. * Creates a cube texture where the raw buffers are passed in.
  53366. * @param scene defines the scene the texture is attached to
  53367. * @param data defines the array of data to use to create each face
  53368. * @param size defines the size of the textures
  53369. * @param format defines the format of the data
  53370. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53371. * @param generateMipMaps defines if the engine should generate the mip levels
  53372. * @param invertY defines if data must be stored with Y axis inverted
  53373. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53374. * @param compression defines the compression used (null by default)
  53375. */
  53376. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53377. /**
  53378. * Updates the raw cube texture.
  53379. * @param data defines the data to store
  53380. * @param format defines the data format
  53381. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53382. * @param invertY defines if data must be stored with Y axis inverted
  53383. * @param compression defines the compression used (null by default)
  53384. * @param level defines which level of the texture to update
  53385. */
  53386. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53387. /**
  53388. * Updates a raw cube texture with RGBD encoded data.
  53389. * @param data defines the array of data [mipmap][face] to use to create each face
  53390. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53391. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53392. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53393. * @returns a promsie that resolves when the operation is complete
  53394. */
  53395. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53396. /**
  53397. * Clones the raw cube texture.
  53398. * @return a new cube texture
  53399. */
  53400. clone(): CubeTexture;
  53401. /** @hidden */
  53402. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53403. }
  53404. }
  53405. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53406. import { Scene } from "babylonjs/scene";
  53407. import { Texture } from "babylonjs/Materials/Textures/texture";
  53408. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53409. /**
  53410. * Class used to store 3D textures containing user data
  53411. */
  53412. export class RawTexture3D extends Texture {
  53413. /** Gets or sets the texture format to use */
  53414. format: number;
  53415. private _engine;
  53416. /**
  53417. * Create a new RawTexture3D
  53418. * @param data defines the data of the texture
  53419. * @param width defines the width of the texture
  53420. * @param height defines the height of the texture
  53421. * @param depth defines the depth of the texture
  53422. * @param format defines the texture format to use
  53423. * @param scene defines the hosting scene
  53424. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53425. * @param invertY defines if texture must be stored with Y axis inverted
  53426. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53427. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53428. */
  53429. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53430. /** Gets or sets the texture format to use */
  53431. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53432. /**
  53433. * Update the texture with new data
  53434. * @param data defines the data to store in the texture
  53435. */
  53436. update(data: ArrayBufferView): void;
  53437. }
  53438. }
  53439. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53440. import { Scene } from "babylonjs/scene";
  53441. import { Plane } from "babylonjs/Maths/math.plane";
  53442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53443. /**
  53444. * Creates a refraction texture used by refraction channel of the standard material.
  53445. * It is like a mirror but to see through a material.
  53446. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53447. */
  53448. export class RefractionTexture extends RenderTargetTexture {
  53449. /**
  53450. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53451. * 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.
  53452. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53453. */
  53454. refractionPlane: Plane;
  53455. /**
  53456. * Define how deep under the surface we should see.
  53457. */
  53458. depth: number;
  53459. /**
  53460. * Creates a refraction texture used by refraction channel of the standard material.
  53461. * It is like a mirror but to see through a material.
  53462. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53463. * @param name Define the texture name
  53464. * @param size Define the size of the underlying texture
  53465. * @param scene Define the scene the refraction belongs to
  53466. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53467. */
  53468. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53469. /**
  53470. * Clone the refraction texture.
  53471. * @returns the cloned texture
  53472. */
  53473. clone(): RefractionTexture;
  53474. /**
  53475. * Serialize the texture to a JSON representation you could use in Parse later on
  53476. * @returns the serialized JSON representation
  53477. */
  53478. serialize(): any;
  53479. }
  53480. }
  53481. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53482. import { Nullable } from "babylonjs/types";
  53483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53484. import { Matrix } from "babylonjs/Maths/math.vector";
  53485. import { Engine } from "babylonjs/Engines/engine";
  53486. import { Scene } from "babylonjs/scene";
  53487. /**
  53488. * Defines the options related to the creation of an HtmlElementTexture
  53489. */
  53490. export interface IHtmlElementTextureOptions {
  53491. /**
  53492. * Defines wether mip maps should be created or not.
  53493. */
  53494. generateMipMaps?: boolean;
  53495. /**
  53496. * Defines the sampling mode of the texture.
  53497. */
  53498. samplingMode?: number;
  53499. /**
  53500. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53501. */
  53502. engine: Nullable<Engine>;
  53503. /**
  53504. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53505. */
  53506. scene: Nullable<Scene>;
  53507. }
  53508. /**
  53509. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53510. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53511. * is automatically managed.
  53512. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53513. * in your application.
  53514. *
  53515. * As the update is not automatic, you need to call them manually.
  53516. */
  53517. export class HtmlElementTexture extends BaseTexture {
  53518. /**
  53519. * The texture URL.
  53520. */
  53521. element: HTMLVideoElement | HTMLCanvasElement;
  53522. private static readonly DefaultOptions;
  53523. private _textureMatrix;
  53524. private _engine;
  53525. private _isVideo;
  53526. private _generateMipMaps;
  53527. private _samplingMode;
  53528. /**
  53529. * Instantiates a HtmlElementTexture from the following parameters.
  53530. *
  53531. * @param name Defines the name of the texture
  53532. * @param element Defines the video or canvas the texture is filled with
  53533. * @param options Defines the other none mandatory texture creation options
  53534. */
  53535. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53536. private _createInternalTexture;
  53537. /**
  53538. * Returns the texture matrix used in most of the material.
  53539. */
  53540. getTextureMatrix(): Matrix;
  53541. /**
  53542. * Updates the content of the texture.
  53543. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53544. */
  53545. update(invertY?: Nullable<boolean>): void;
  53546. }
  53547. }
  53548. declare module "babylonjs/Materials/Textures/index" {
  53549. export * from "babylonjs/Materials/Textures/baseTexture";
  53550. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53551. export * from "babylonjs/Materials/Textures/cubeTexture";
  53552. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53553. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53554. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53555. export * from "babylonjs/Materials/Textures/internalTexture";
  53556. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53557. export * from "babylonjs/Materials/Textures/Loaders/index";
  53558. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53559. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53560. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53561. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53562. export * from "babylonjs/Materials/Textures/rawTexture";
  53563. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53564. export * from "babylonjs/Materials/Textures/refractionTexture";
  53565. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53566. export * from "babylonjs/Materials/Textures/texture";
  53567. export * from "babylonjs/Materials/Textures/videoTexture";
  53568. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53569. }
  53570. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53571. /**
  53572. * Enum used to define the target of a block
  53573. */
  53574. export enum NodeMaterialBlockTargets {
  53575. /** Vertex shader */
  53576. Vertex = 1,
  53577. /** Fragment shader */
  53578. Fragment = 2,
  53579. /** Neutral */
  53580. Neutral = 4,
  53581. /** Vertex and Fragment */
  53582. VertexAndFragment = 3
  53583. }
  53584. }
  53585. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53586. /**
  53587. * Defines the kind of connection point for node based material
  53588. */
  53589. export enum NodeMaterialBlockConnectionPointTypes {
  53590. /** Float */
  53591. Float = 1,
  53592. /** Int */
  53593. Int = 2,
  53594. /** Vector2 */
  53595. Vector2 = 4,
  53596. /** Vector3 */
  53597. Vector3 = 8,
  53598. /** Vector4 */
  53599. Vector4 = 16,
  53600. /** Color3 */
  53601. Color3 = 32,
  53602. /** Color4 */
  53603. Color4 = 64,
  53604. /** Matrix */
  53605. Matrix = 128,
  53606. /** Detect type based on connection */
  53607. AutoDetect = 1024,
  53608. /** Output type that will be defined by input type */
  53609. BasedOnInput = 2048
  53610. }
  53611. }
  53612. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53614. /**
  53615. * Root class for all node material optimizers
  53616. */
  53617. export class NodeMaterialOptimizer {
  53618. /**
  53619. * Function used to optimize a NodeMaterial graph
  53620. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53621. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53622. */
  53623. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53624. }
  53625. }
  53626. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53630. import { Scene } from "babylonjs/scene";
  53631. /**
  53632. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53633. */
  53634. export class TransformBlock extends NodeMaterialBlock {
  53635. /**
  53636. * Defines the value to use to complement W value to transform it to a Vector4
  53637. */
  53638. complementW: number;
  53639. /**
  53640. * Defines the value to use to complement z value to transform it to a Vector4
  53641. */
  53642. complementZ: number;
  53643. /**
  53644. * Creates a new TransformBlock
  53645. * @param name defines the block name
  53646. */
  53647. constructor(name: string);
  53648. /**
  53649. * Gets the current class name
  53650. * @returns the class name
  53651. */
  53652. getClassName(): string;
  53653. /**
  53654. * Gets the vector input
  53655. */
  53656. readonly vector: NodeMaterialConnectionPoint;
  53657. /**
  53658. * Gets the output component
  53659. */
  53660. readonly output: NodeMaterialConnectionPoint;
  53661. /**
  53662. * Gets the matrix transform input
  53663. */
  53664. readonly transform: NodeMaterialConnectionPoint;
  53665. protected _buildBlock(state: NodeMaterialBuildState): this;
  53666. serialize(): any;
  53667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53668. }
  53669. }
  53670. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53673. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53674. /**
  53675. * Block used to output the vertex position
  53676. */
  53677. export class VertexOutputBlock extends NodeMaterialBlock {
  53678. /**
  53679. * Creates a new VertexOutputBlock
  53680. * @param name defines the block name
  53681. */
  53682. constructor(name: string);
  53683. /**
  53684. * Gets the current class name
  53685. * @returns the class name
  53686. */
  53687. getClassName(): string;
  53688. /**
  53689. * Gets the vector input component
  53690. */
  53691. readonly vector: NodeMaterialConnectionPoint;
  53692. protected _buildBlock(state: NodeMaterialBuildState): this;
  53693. }
  53694. }
  53695. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53699. /**
  53700. * Block used to output the final color
  53701. */
  53702. export class FragmentOutputBlock extends NodeMaterialBlock {
  53703. /**
  53704. * Create a new FragmentOutputBlock
  53705. * @param name defines the block name
  53706. */
  53707. constructor(name: string);
  53708. /**
  53709. * Gets the current class name
  53710. * @returns the class name
  53711. */
  53712. getClassName(): string;
  53713. /**
  53714. * Gets the rgba input component
  53715. */
  53716. readonly rgba: NodeMaterialConnectionPoint;
  53717. /**
  53718. * Gets the rgb input component
  53719. */
  53720. readonly rgb: NodeMaterialConnectionPoint;
  53721. /**
  53722. * Gets the a input component
  53723. */
  53724. readonly a: NodeMaterialConnectionPoint;
  53725. protected _buildBlock(state: NodeMaterialBuildState): this;
  53726. }
  53727. }
  53728. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53730. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53731. import { Scene } from "babylonjs/scene";
  53732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53733. import { Matrix } from "babylonjs/Maths/math.vector";
  53734. import { Mesh } from "babylonjs/Meshes/mesh";
  53735. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53736. import { Observable } from "babylonjs/Misc/observable";
  53737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53738. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53739. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53740. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53741. import { Nullable } from "babylonjs/types";
  53742. /**
  53743. * Interface used to configure the node material editor
  53744. */
  53745. export interface INodeMaterialEditorOptions {
  53746. /** Define the URl to load node editor script */
  53747. editorURL?: string;
  53748. }
  53749. /** @hidden */
  53750. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53751. /** BONES */
  53752. NUM_BONE_INFLUENCERS: number;
  53753. BonesPerMesh: number;
  53754. BONETEXTURE: boolean;
  53755. /** MORPH TARGETS */
  53756. MORPHTARGETS: boolean;
  53757. MORPHTARGETS_NORMAL: boolean;
  53758. MORPHTARGETS_TANGENT: boolean;
  53759. MORPHTARGETS_UV: boolean;
  53760. NUM_MORPH_INFLUENCERS: number;
  53761. /** IMAGE PROCESSING */
  53762. IMAGEPROCESSING: boolean;
  53763. VIGNETTE: boolean;
  53764. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53765. VIGNETTEBLENDMODEOPAQUE: boolean;
  53766. TONEMAPPING: boolean;
  53767. TONEMAPPING_ACES: boolean;
  53768. CONTRAST: boolean;
  53769. EXPOSURE: boolean;
  53770. COLORCURVES: boolean;
  53771. COLORGRADING: boolean;
  53772. COLORGRADING3D: boolean;
  53773. SAMPLER3DGREENDEPTH: boolean;
  53774. SAMPLER3DBGRMAP: boolean;
  53775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53776. constructor();
  53777. setValue(name: string, value: boolean): void;
  53778. }
  53779. /**
  53780. * Class used to configure NodeMaterial
  53781. */
  53782. export interface INodeMaterialOptions {
  53783. /**
  53784. * Defines if blocks should emit comments
  53785. */
  53786. emitComments: boolean;
  53787. }
  53788. /**
  53789. * Class used to create a node based material built by assembling shader blocks
  53790. */
  53791. export class NodeMaterial extends PushMaterial {
  53792. private static _BuildIdGenerator;
  53793. private _options;
  53794. private _vertexCompilationState;
  53795. private _fragmentCompilationState;
  53796. private _sharedData;
  53797. private _buildId;
  53798. private _buildWasSuccessful;
  53799. private _cachedWorldViewMatrix;
  53800. private _cachedWorldViewProjectionMatrix;
  53801. private _optimizers;
  53802. /** Define the URl to load node editor script */
  53803. static EditorURL: string;
  53804. private BJSNODEMATERIALEDITOR;
  53805. /** Get the inspector from bundle or global */
  53806. private _getGlobalNodeMaterialEditor;
  53807. /**
  53808. * 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)
  53809. */
  53810. ignoreAlpha: boolean;
  53811. /**
  53812. * Defines the maximum number of lights that can be used in the material
  53813. */
  53814. maxSimultaneousLights: number;
  53815. /**
  53816. * Observable raised when the material is built
  53817. */
  53818. onBuildObservable: Observable<NodeMaterial>;
  53819. /**
  53820. * Gets or sets the root nodes of the material vertex shader
  53821. */
  53822. _vertexOutputNodes: NodeMaterialBlock[];
  53823. /**
  53824. * Gets or sets the root nodes of the material fragment (pixel) shader
  53825. */
  53826. _fragmentOutputNodes: NodeMaterialBlock[];
  53827. /** Gets or sets options to control the node material overall behavior */
  53828. options: INodeMaterialOptions;
  53829. /**
  53830. * Default configuration related to image processing available in the standard Material.
  53831. */
  53832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53833. /**
  53834. * Gets the image processing configuration used either in this material.
  53835. */
  53836. /**
  53837. * Sets the Default image processing configuration used either in the this material.
  53838. *
  53839. * If sets to null, the scene one is in use.
  53840. */
  53841. imageProcessingConfiguration: ImageProcessingConfiguration;
  53842. /**
  53843. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53844. */
  53845. attachedBlocks: NodeMaterialBlock[];
  53846. /**
  53847. * Create a new node based material
  53848. * @param name defines the material name
  53849. * @param scene defines the hosting scene
  53850. * @param options defines creation option
  53851. */
  53852. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53853. /**
  53854. * Gets the current class name of the material e.g. "NodeMaterial"
  53855. * @returns the class name
  53856. */
  53857. getClassName(): string;
  53858. /**
  53859. * Keep track of the image processing observer to allow dispose and replace.
  53860. */
  53861. private _imageProcessingObserver;
  53862. /**
  53863. * Attaches a new image processing configuration to the Standard Material.
  53864. * @param configuration
  53865. */
  53866. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53867. /**
  53868. * Adds a new optimizer to the list of optimizers
  53869. * @param optimizer defines the optimizers to add
  53870. * @returns the current material
  53871. */
  53872. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53873. /**
  53874. * Remove an optimizer from the list of optimizers
  53875. * @param optimizer defines the optimizers to remove
  53876. * @returns the current material
  53877. */
  53878. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53879. /**
  53880. * Add a new block to the list of output nodes
  53881. * @param node defines the node to add
  53882. * @returns the current material
  53883. */
  53884. addOutputNode(node: NodeMaterialBlock): this;
  53885. /**
  53886. * Remove a block from the list of root nodes
  53887. * @param node defines the node to remove
  53888. * @returns the current material
  53889. */
  53890. removeOutputNode(node: NodeMaterialBlock): this;
  53891. private _addVertexOutputNode;
  53892. private _removeVertexOutputNode;
  53893. private _addFragmentOutputNode;
  53894. private _removeFragmentOutputNode;
  53895. /**
  53896. * Specifies if the material will require alpha blending
  53897. * @returns a boolean specifying if alpha blending is needed
  53898. */
  53899. needAlphaBlending(): boolean;
  53900. /**
  53901. * Specifies if this material should be rendered in alpha test mode
  53902. * @returns a boolean specifying if an alpha test is needed.
  53903. */
  53904. needAlphaTesting(): boolean;
  53905. private _initializeBlock;
  53906. private _resetDualBlocks;
  53907. /**
  53908. * Build the material and generates the inner effect
  53909. * @param verbose defines if the build should log activity
  53910. */
  53911. build(verbose?: boolean): void;
  53912. /**
  53913. * Runs an otpimization phase to try to improve the shader code
  53914. */
  53915. optimize(): void;
  53916. private _prepareDefinesForAttributes;
  53917. /**
  53918. * Get if the submesh is ready to be used and all its information available.
  53919. * Child classes can use it to update shaders
  53920. * @param mesh defines the mesh to check
  53921. * @param subMesh defines which submesh to check
  53922. * @param useInstances specifies that instances should be used
  53923. * @returns a boolean indicating that the submesh is ready or not
  53924. */
  53925. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53926. /**
  53927. * Get a string representing the shaders built by the current node graph
  53928. */
  53929. readonly compiledShaders: string;
  53930. /**
  53931. * Binds the world matrix to the material
  53932. * @param world defines the world transformation matrix
  53933. */
  53934. bindOnlyWorldMatrix(world: Matrix): void;
  53935. /**
  53936. * Binds the submesh to this material by preparing the effect and shader to draw
  53937. * @param world defines the world transformation matrix
  53938. * @param mesh defines the mesh containing the submesh
  53939. * @param subMesh defines the submesh to bind the material to
  53940. */
  53941. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53942. /**
  53943. * Gets the active textures from the material
  53944. * @returns an array of textures
  53945. */
  53946. getActiveTextures(): BaseTexture[];
  53947. /**
  53948. * Specifies if the material uses a texture
  53949. * @param texture defines the texture to check against the material
  53950. * @returns a boolean specifying if the material uses the texture
  53951. */
  53952. hasTexture(texture: BaseTexture): boolean;
  53953. /**
  53954. * Disposes the material
  53955. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53956. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53957. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53958. */
  53959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53960. /** Creates the node editor window. */
  53961. private _createNodeEditor;
  53962. /**
  53963. * Launch the node material editor
  53964. * @param config Define the configuration of the editor
  53965. * @return a promise fulfilled when the node editor is visible
  53966. */
  53967. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53968. /**
  53969. * Clear the current material
  53970. */
  53971. clear(): void;
  53972. /**
  53973. * Clear the current material and set it to a default state
  53974. */
  53975. setToDefault(): void;
  53976. private _gatherBlocks;
  53977. /**
  53978. * Serializes this material in a JSON representation
  53979. * @returns the serialized material object
  53980. */
  53981. serialize(): any;
  53982. /**
  53983. * Clear the current graph and load a new one from a serialization object
  53984. * @param source defines the JSON representation of the material
  53985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53986. */
  53987. loadFromSerialization(source: any, rootUrl?: string): void;
  53988. /**
  53989. * Creates a node material from parsed material data
  53990. * @param source defines the JSON representation of the material
  53991. * @param scene defines the hosting scene
  53992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53993. * @returns a new node material
  53994. */
  53995. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53996. }
  53997. }
  53998. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54004. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54005. import { Effect } from "babylonjs/Materials/effect";
  54006. import { Mesh } from "babylonjs/Meshes/mesh";
  54007. import { Nullable } from "babylonjs/types";
  54008. import { Scene } from "babylonjs/scene";
  54009. /**
  54010. * Block used to read a texture from a sampler
  54011. */
  54012. export class TextureBlock extends NodeMaterialBlock {
  54013. private _defineName;
  54014. private _samplerName;
  54015. private _transformedUVName;
  54016. private _textureTransformName;
  54017. private _textureInfoName;
  54018. private _mainUVName;
  54019. private _mainUVDefineName;
  54020. /**
  54021. * Gets or sets the texture associated with the node
  54022. */
  54023. texture: Nullable<BaseTexture>;
  54024. /**
  54025. * Create a new TextureBlock
  54026. * @param name defines the block name
  54027. */
  54028. constructor(name: string);
  54029. /**
  54030. * Gets the current class name
  54031. * @returns the class name
  54032. */
  54033. getClassName(): string;
  54034. /**
  54035. * Gets the uv input component
  54036. */
  54037. readonly uv: NodeMaterialConnectionPoint;
  54038. /**
  54039. * Gets the output component
  54040. */
  54041. readonly output: NodeMaterialConnectionPoint;
  54042. autoConfigure(): void;
  54043. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54045. isReady(): boolean;
  54046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54047. private _injectVertexCode;
  54048. private _writeOutput;
  54049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54050. serialize(): any;
  54051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54052. }
  54053. }
  54054. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54057. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54058. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54059. /**
  54060. * Class used to store shared data between 2 NodeMaterialBuildState
  54061. */
  54062. export class NodeMaterialBuildStateSharedData {
  54063. /**
  54064. * Gets the list of emitted varyings
  54065. */
  54066. varyings: string[];
  54067. /**
  54068. * Gets the varying declaration string
  54069. */
  54070. varyingDeclaration: string;
  54071. /**
  54072. * Input blocks
  54073. */
  54074. inputBlocks: InputBlock[];
  54075. /**
  54076. * Input blocks
  54077. */
  54078. textureBlocks: TextureBlock[];
  54079. /**
  54080. * Bindable blocks (Blocks that need to set data to the effect)
  54081. */
  54082. bindableBlocks: NodeMaterialBlock[];
  54083. /**
  54084. * List of blocks that can provide a compilation fallback
  54085. */
  54086. blocksWithFallbacks: NodeMaterialBlock[];
  54087. /**
  54088. * List of blocks that can provide a define update
  54089. */
  54090. blocksWithDefines: NodeMaterialBlock[];
  54091. /**
  54092. * List of blocks that can provide a repeatable content
  54093. */
  54094. repeatableContentBlocks: NodeMaterialBlock[];
  54095. /**
  54096. * List of blocks that can provide a dynamic list of uniforms
  54097. */
  54098. dynamicUniformBlocks: NodeMaterialBlock[];
  54099. /**
  54100. * List of blocks that can block the isReady function for the material
  54101. */
  54102. blockingBlocks: NodeMaterialBlock[];
  54103. /**
  54104. * Build Id used to avoid multiple recompilations
  54105. */
  54106. buildId: number;
  54107. /** List of emitted variables */
  54108. variableNames: {
  54109. [key: string]: number;
  54110. };
  54111. /** List of emitted defines */
  54112. defineNames: {
  54113. [key: string]: number;
  54114. };
  54115. /** Should emit comments? */
  54116. emitComments: boolean;
  54117. /** Emit build activity */
  54118. verbose: boolean;
  54119. /**
  54120. * Gets the compilation hints emitted at compilation time
  54121. */
  54122. hints: {
  54123. needWorldViewMatrix: boolean;
  54124. needWorldViewProjectionMatrix: boolean;
  54125. needAlphaBlending: boolean;
  54126. needAlphaTesting: boolean;
  54127. };
  54128. /**
  54129. * List of compilation checks
  54130. */
  54131. checks: {
  54132. emitVertex: boolean;
  54133. emitFragment: boolean;
  54134. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54135. };
  54136. /** Creates a new shared data */
  54137. constructor();
  54138. /**
  54139. * Emits console errors and exceptions if there is a failing check
  54140. */
  54141. emitErrors(): void;
  54142. }
  54143. }
  54144. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54145. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54146. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54147. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54148. /**
  54149. * Class used to store node based material build state
  54150. */
  54151. export class NodeMaterialBuildState {
  54152. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54153. supportUniformBuffers: boolean;
  54154. /**
  54155. * Gets the list of emitted attributes
  54156. */
  54157. attributes: string[];
  54158. /**
  54159. * Gets the list of emitted uniforms
  54160. */
  54161. uniforms: string[];
  54162. /**
  54163. * Gets the list of emitted uniform buffers
  54164. */
  54165. uniformBuffers: string[];
  54166. /**
  54167. * Gets the list of emitted samplers
  54168. */
  54169. samplers: string[];
  54170. /**
  54171. * Gets the list of emitted functions
  54172. */
  54173. functions: {
  54174. [key: string]: string;
  54175. };
  54176. /**
  54177. * Gets the target of the compilation state
  54178. */
  54179. target: NodeMaterialBlockTargets;
  54180. /**
  54181. * Gets the list of emitted counters
  54182. */
  54183. counters: {
  54184. [key: string]: number;
  54185. };
  54186. /**
  54187. * Shared data between multiple NodeMaterialBuildState instances
  54188. */
  54189. sharedData: NodeMaterialBuildStateSharedData;
  54190. /** @hidden */
  54191. _vertexState: NodeMaterialBuildState;
  54192. /** @hidden */
  54193. _attributeDeclaration: string;
  54194. /** @hidden */
  54195. _uniformDeclaration: string;
  54196. /** @hidden */
  54197. _samplerDeclaration: string;
  54198. /** @hidden */
  54199. _varyingTransfer: string;
  54200. private _repeatableContentAnchorIndex;
  54201. /** @hidden */
  54202. _builtCompilationString: string;
  54203. /**
  54204. * Gets the emitted compilation strings
  54205. */
  54206. compilationString: string;
  54207. /**
  54208. * Finalize the compilation strings
  54209. * @param state defines the current compilation state
  54210. */
  54211. finalize(state: NodeMaterialBuildState): void;
  54212. /** @hidden */
  54213. readonly _repeatableContentAnchor: string;
  54214. /** @hidden */
  54215. _getFreeVariableName(prefix: string): string;
  54216. /** @hidden */
  54217. _getFreeDefineName(prefix: string): string;
  54218. /** @hidden */
  54219. _excludeVariableName(name: string): void;
  54220. /** @hidden */
  54221. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54222. /** @hidden */
  54223. _emitFunction(name: string, code: string, comments: string): void;
  54224. /** @hidden */
  54225. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54226. replaceStrings?: {
  54227. search: RegExp;
  54228. replace: string;
  54229. }[];
  54230. repeatKey?: string;
  54231. }): string;
  54232. /** @hidden */
  54233. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54234. repeatKey?: string;
  54235. removeAttributes?: boolean;
  54236. removeUniforms?: boolean;
  54237. removeVaryings?: boolean;
  54238. removeIfDef?: boolean;
  54239. replaceStrings?: {
  54240. search: RegExp;
  54241. replace: string;
  54242. }[];
  54243. }, storeKey?: string): void;
  54244. /** @hidden */
  54245. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54246. /** @hidden */
  54247. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54248. }
  54249. }
  54250. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54251. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54253. import { Nullable } from "babylonjs/types";
  54254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54255. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54256. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54258. import { Mesh } from "babylonjs/Meshes/mesh";
  54259. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54260. import { Scene } from "babylonjs/scene";
  54261. /**
  54262. * Defines a block that can be used inside a node based material
  54263. */
  54264. export class NodeMaterialBlock {
  54265. private _buildId;
  54266. private _buildTarget;
  54267. private _target;
  54268. private _isFinalMerger;
  54269. private _isInput;
  54270. /** @hidden */
  54271. _inputs: NodeMaterialConnectionPoint[];
  54272. /** @hidden */
  54273. _outputs: NodeMaterialConnectionPoint[];
  54274. /**
  54275. * Gets or sets the name of the block
  54276. */
  54277. name: string;
  54278. /**
  54279. * Gets or sets the unique id of the node
  54280. */
  54281. uniqueId: number;
  54282. /**
  54283. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54284. */
  54285. readonly isFinalMerger: boolean;
  54286. /**
  54287. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54288. */
  54289. readonly isInput: boolean;
  54290. /**
  54291. * Gets or sets the build Id
  54292. */
  54293. buildId: number;
  54294. /**
  54295. * Gets or sets the target of the block
  54296. */
  54297. target: NodeMaterialBlockTargets;
  54298. /**
  54299. * Gets the list of input points
  54300. */
  54301. readonly inputs: NodeMaterialConnectionPoint[];
  54302. /** Gets the list of output points */
  54303. readonly outputs: NodeMaterialConnectionPoint[];
  54304. /**
  54305. * Find an input by its name
  54306. * @param name defines the name of the input to look for
  54307. * @returns the input or null if not found
  54308. */
  54309. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54310. /**
  54311. * Find an output by its name
  54312. * @param name defines the name of the outputto look for
  54313. * @returns the output or null if not found
  54314. */
  54315. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54316. /**
  54317. * Creates a new NodeMaterialBlock
  54318. * @param name defines the block name
  54319. * @param target defines the target of that block (Vertex by default)
  54320. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54321. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54322. */
  54323. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54324. /**
  54325. * Initialize the block and prepare the context for build
  54326. * @param state defines the state that will be used for the build
  54327. */
  54328. initialize(state: NodeMaterialBuildState): void;
  54329. /**
  54330. * Bind data to effect. Will only be called for blocks with isBindable === true
  54331. * @param effect defines the effect to bind data to
  54332. * @param nodeMaterial defines the hosting NodeMaterial
  54333. * @param mesh defines the mesh that will be rendered
  54334. */
  54335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54336. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54337. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54338. protected _writeFloat(value: number): string;
  54339. /**
  54340. * Gets the current class name e.g. "NodeMaterialBlock"
  54341. * @returns the class name
  54342. */
  54343. getClassName(): string;
  54344. /**
  54345. * Register a new input. Must be called inside a block constructor
  54346. * @param name defines the connection point name
  54347. * @param type defines the connection point type
  54348. * @param isOptional defines a boolean indicating that this input can be omitted
  54349. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54350. * @returns the current block
  54351. */
  54352. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54353. /**
  54354. * Register a new output. Must be called inside a block constructor
  54355. * @param name defines the connection point name
  54356. * @param type defines the connection point type
  54357. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54358. * @returns the current block
  54359. */
  54360. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54361. /**
  54362. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54363. * @param forOutput defines an optional connection point to check compatibility with
  54364. * @returns the first available input or null
  54365. */
  54366. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54367. /**
  54368. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54369. * @param forBlock defines an optional block to check compatibility with
  54370. * @returns the first available input or null
  54371. */
  54372. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54373. /**
  54374. * Connect current block with another block
  54375. * @param other defines the block to connect with
  54376. * @param options define the various options to help pick the right connections
  54377. * @returns the current block
  54378. */
  54379. connectTo(other: NodeMaterialBlock, options?: {
  54380. input?: string;
  54381. output?: string;
  54382. outputSwizzle?: string;
  54383. }): this | undefined;
  54384. protected _buildBlock(state: NodeMaterialBuildState): void;
  54385. /**
  54386. * Add uniforms, samplers and uniform buffers at compilation time
  54387. * @param state defines the state to update
  54388. * @param nodeMaterial defines the node material requesting the update
  54389. * @param defines defines the material defines to update
  54390. */
  54391. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54392. /**
  54393. * Add potential fallbacks if shader compilation fails
  54394. * @param mesh defines the mesh to be rendered
  54395. * @param fallbacks defines the current prioritized list of fallbacks
  54396. */
  54397. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54398. /**
  54399. * Update defines for shader compilation
  54400. * @param mesh defines the mesh to be rendered
  54401. * @param nodeMaterial defines the node material requesting the update
  54402. * @param defines defines the material defines to update
  54403. * @param useInstances specifies that instances should be used
  54404. */
  54405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54406. /**
  54407. * Initialize defines for shader compilation
  54408. * @param mesh defines the mesh to be rendered
  54409. * @param nodeMaterial defines the node material requesting the update
  54410. * @param defines defines the material defines to be prepared
  54411. * @param useInstances specifies that instances should be used
  54412. */
  54413. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54414. /**
  54415. * Lets the block try to connect some inputs automatically
  54416. */
  54417. autoConfigure(): void;
  54418. /**
  54419. * Function called when a block is declared as repeatable content generator
  54420. * @param vertexShaderState defines the current compilation state for the vertex shader
  54421. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54422. * @param mesh defines the mesh to be rendered
  54423. * @param defines defines the material defines to update
  54424. */
  54425. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54426. /**
  54427. * Checks if the block is ready
  54428. * @param mesh defines the mesh to be rendered
  54429. * @param nodeMaterial defines the node material requesting the update
  54430. * @param defines defines the material defines to update
  54431. * @param useInstances specifies that instances should be used
  54432. * @returns true if the block is ready
  54433. */
  54434. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54435. private _processBuild;
  54436. /**
  54437. * Compile the current node and generate the shader code
  54438. * @param state defines the current compilation state (uniforms, samplers, current string)
  54439. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54440. * @returns true if already built
  54441. */
  54442. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54443. /**
  54444. * Serializes this block in a JSON representation
  54445. * @returns the serialized block object
  54446. */
  54447. serialize(): any;
  54448. /** @hidden */
  54449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54450. }
  54451. }
  54452. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54453. /**
  54454. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54455. */
  54456. export enum NodeMaterialBlockConnectionPointMode {
  54457. /** Value is an uniform */
  54458. Uniform = 0,
  54459. /** Value is a mesh attribute */
  54460. Attribute = 1,
  54461. /** Value is a varying between vertex and fragment shaders */
  54462. Varying = 2,
  54463. /** Mode is undefined */
  54464. Undefined = 3
  54465. }
  54466. }
  54467. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54468. /**
  54469. * Enum used to define well known values e.g. values automatically provided by the system
  54470. */
  54471. export enum NodeMaterialWellKnownValues {
  54472. /** World */
  54473. World = 1,
  54474. /** View */
  54475. View = 2,
  54476. /** Projection */
  54477. Projection = 3,
  54478. /** ViewProjection */
  54479. ViewProjection = 4,
  54480. /** WorldView */
  54481. WorldView = 5,
  54482. /** WorldViewProjection */
  54483. WorldViewProjection = 6,
  54484. /** CameraPosition */
  54485. CameraPosition = 7,
  54486. /** Fog Color */
  54487. FogColor = 8
  54488. }
  54489. }
  54490. declare module "babylonjs/Maths/math.vertexFormat" {
  54491. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54492. /**
  54493. * Contains position and normal vectors for a vertex
  54494. */
  54495. export class PositionNormalVertex {
  54496. /** the position of the vertex (defaut: 0,0,0) */
  54497. position: Vector3;
  54498. /** the normal of the vertex (defaut: 0,1,0) */
  54499. normal: Vector3;
  54500. /**
  54501. * Creates a PositionNormalVertex
  54502. * @param position the position of the vertex (defaut: 0,0,0)
  54503. * @param normal the normal of the vertex (defaut: 0,1,0)
  54504. */
  54505. constructor(
  54506. /** the position of the vertex (defaut: 0,0,0) */
  54507. position?: Vector3,
  54508. /** the normal of the vertex (defaut: 0,1,0) */
  54509. normal?: Vector3);
  54510. /**
  54511. * Clones the PositionNormalVertex
  54512. * @returns the cloned PositionNormalVertex
  54513. */
  54514. clone(): PositionNormalVertex;
  54515. }
  54516. /**
  54517. * Contains position, normal and uv vectors for a vertex
  54518. */
  54519. export class PositionNormalTextureVertex {
  54520. /** the position of the vertex (defaut: 0,0,0) */
  54521. position: Vector3;
  54522. /** the normal of the vertex (defaut: 0,1,0) */
  54523. normal: Vector3;
  54524. /** the uv of the vertex (default: 0,0) */
  54525. uv: Vector2;
  54526. /**
  54527. * Creates a PositionNormalTextureVertex
  54528. * @param position the position of the vertex (defaut: 0,0,0)
  54529. * @param normal the normal of the vertex (defaut: 0,1,0)
  54530. * @param uv the uv of the vertex (default: 0,0)
  54531. */
  54532. constructor(
  54533. /** the position of the vertex (defaut: 0,0,0) */
  54534. position?: Vector3,
  54535. /** the normal of the vertex (defaut: 0,1,0) */
  54536. normal?: Vector3,
  54537. /** the uv of the vertex (default: 0,0) */
  54538. uv?: Vector2);
  54539. /**
  54540. * Clones the PositionNormalTextureVertex
  54541. * @returns the cloned PositionNormalTextureVertex
  54542. */
  54543. clone(): PositionNormalTextureVertex;
  54544. }
  54545. }
  54546. declare module "babylonjs/Maths/math" {
  54547. export * from "babylonjs/Maths/math.axis";
  54548. export * from "babylonjs/Maths/math.color";
  54549. export * from "babylonjs/Maths/math.constants";
  54550. export * from "babylonjs/Maths/math.frustum";
  54551. export * from "babylonjs/Maths/math.path";
  54552. export * from "babylonjs/Maths/math.plane";
  54553. export * from "babylonjs/Maths/math.size";
  54554. export * from "babylonjs/Maths/math.vector";
  54555. export * from "babylonjs/Maths/math.vertexFormat";
  54556. export * from "babylonjs/Maths/math.viewport";
  54557. }
  54558. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54560. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54561. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54562. import { Nullable } from "babylonjs/types";
  54563. import { Effect } from "babylonjs/Materials/effect";
  54564. import { Matrix } from "babylonjs/Maths/math.vector";
  54565. import { Scene } from "babylonjs/scene";
  54566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54568. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54569. /**
  54570. * Block used to expose an input value
  54571. */
  54572. export class InputBlock extends NodeMaterialBlock {
  54573. private _mode;
  54574. private _associatedVariableName;
  54575. private _storedValue;
  54576. private _valueCallback;
  54577. private _type;
  54578. /** @hidden */
  54579. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54580. /**
  54581. * Gets or sets the connection point type (default is float)
  54582. */
  54583. readonly type: NodeMaterialBlockConnectionPointTypes;
  54584. /**
  54585. * Creates a new InputBlock
  54586. * @param name defines the block name
  54587. * @param target defines the target of that block (Vertex by default)
  54588. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54589. */
  54590. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54591. /**
  54592. * Gets the output component
  54593. */
  54594. readonly output: NodeMaterialConnectionPoint;
  54595. /**
  54596. * Set the source of this connection point to a vertex attribute
  54597. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54598. * @returns the current connection point
  54599. */
  54600. setAsAttribute(attributeName?: string): InputBlock;
  54601. /**
  54602. * Set the source of this connection point to a well known value
  54603. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54604. * @returns the current connection point
  54605. */
  54606. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54607. /**
  54608. * Gets or sets the value of that point.
  54609. * Please note that this value will be ignored if valueCallback is defined
  54610. */
  54611. value: any;
  54612. /**
  54613. * Gets or sets a callback used to get the value of that point.
  54614. * Please note that setting this value will force the connection point to ignore the value property
  54615. */
  54616. valueCallback: () => any;
  54617. /**
  54618. * Gets or sets the associated variable name in the shader
  54619. */
  54620. associatedVariableName: string;
  54621. /**
  54622. * Gets a boolean indicating that this connection point not defined yet
  54623. */
  54624. readonly isUndefined: boolean;
  54625. /**
  54626. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54627. * In this case the connection point name must be the name of the uniform to use.
  54628. * Can only be set on inputs
  54629. */
  54630. isUniform: boolean;
  54631. /**
  54632. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54633. * In this case the connection point name must be the name of the attribute to use
  54634. * Can only be set on inputs
  54635. */
  54636. isAttribute: boolean;
  54637. /**
  54638. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54639. * Can only be set on exit points
  54640. */
  54641. isVarying: boolean;
  54642. /**
  54643. * Gets a boolean indicating that the current connection point is a well known value
  54644. */
  54645. readonly isWellKnownValue: boolean;
  54646. /**
  54647. * Gets or sets the current well known value or null if not defined as well know value
  54648. */
  54649. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54650. /**
  54651. * Gets the current class name
  54652. * @returns the class name
  54653. */
  54654. getClassName(): string;
  54655. private _emitDefine;
  54656. /**
  54657. * Set the input block to its default value (based on its type)
  54658. */
  54659. setDefaultValue(): void;
  54660. private _emit;
  54661. /** @hidden */
  54662. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54663. /** @hidden */
  54664. _transmit(effect: Effect, scene: Scene): void;
  54665. protected _buildBlock(state: NodeMaterialBuildState): void;
  54666. serialize(): any;
  54667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54668. }
  54669. }
  54670. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54671. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54672. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54673. import { Nullable } from "babylonjs/types";
  54674. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54676. /**
  54677. * Defines a connection point for a block
  54678. */
  54679. export class NodeMaterialConnectionPoint {
  54680. /** @hidden */
  54681. _ownerBlock: NodeMaterialBlock;
  54682. /** @hidden */
  54683. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54684. private _endpoints;
  54685. private _associatedVariableName;
  54686. /** @hidden */
  54687. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54688. private _type;
  54689. /** @hidden */
  54690. _enforceAssociatedVariableName: boolean;
  54691. /**
  54692. * Gets or sets the additional types supported byt this connection point
  54693. */
  54694. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54695. /**
  54696. * Gets or sets the associated variable name in the shader
  54697. */
  54698. associatedVariableName: string;
  54699. /**
  54700. * Gets or sets the connection point type (default is float)
  54701. */
  54702. type: NodeMaterialBlockConnectionPointTypes;
  54703. /**
  54704. * Gets or sets the connection point name
  54705. */
  54706. name: string;
  54707. /**
  54708. * Gets or sets a boolean indicating that this connection point can be omitted
  54709. */
  54710. isOptional: boolean;
  54711. /**
  54712. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54713. */
  54714. define: string;
  54715. /** Gets or sets the target of that connection point */
  54716. target: NodeMaterialBlockTargets;
  54717. /**
  54718. * Gets a boolean indicating that the current point is connected
  54719. */
  54720. readonly isConnected: boolean;
  54721. /**
  54722. * Gets a boolean indicating that the current point is connected to an input block
  54723. */
  54724. readonly isConnectedToInput: boolean;
  54725. /**
  54726. * Gets a the connected input block (if any)
  54727. */
  54728. readonly connectInputBlock: Nullable<InputBlock>;
  54729. /** Get the other side of the connection (if any) */
  54730. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54731. /** Get the block that owns this connection point */
  54732. readonly ownerBlock: NodeMaterialBlock;
  54733. /** Get the block connected on the other side of this connection (if any) */
  54734. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54735. /** Get the block connected on the endpoints of this connection (if any) */
  54736. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54737. /** Gets the list of connected endpoints */
  54738. readonly endpoints: NodeMaterialConnectionPoint[];
  54739. /**
  54740. * Creates a new connection point
  54741. * @param name defines the connection point name
  54742. * @param ownerBlock defines the block hosting this connection point
  54743. */
  54744. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54745. /**
  54746. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54747. * @returns the class name
  54748. */
  54749. getClassName(): string;
  54750. /**
  54751. * Gets an boolean indicating if the current point can be connected to another point
  54752. * @param connectionPoint defines the other connection point
  54753. * @returns true if the connection is possible
  54754. */
  54755. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54756. /**
  54757. * Connect this point to another connection point
  54758. * @param connectionPoint defines the other connection point
  54759. * @returns the current connection point
  54760. */
  54761. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54762. /**
  54763. * Disconnect this point from one of his endpoint
  54764. * @param endpoint defines the other connection point
  54765. * @returns the current connection point
  54766. */
  54767. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54768. /**
  54769. * Serializes this point in a JSON representation
  54770. * @returns the serialized point object
  54771. */
  54772. serialize(): any;
  54773. }
  54774. }
  54775. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54779. import { Mesh } from "babylonjs/Meshes/mesh";
  54780. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54782. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54783. /**
  54784. * Block used to add support for vertex skinning (bones)
  54785. */
  54786. export class BonesBlock extends NodeMaterialBlock {
  54787. /**
  54788. * Creates a new BonesBlock
  54789. * @param name defines the block name
  54790. */
  54791. constructor(name: string);
  54792. /**
  54793. * Initialize the block and prepare the context for build
  54794. * @param state defines the state that will be used for the build
  54795. */
  54796. initialize(state: NodeMaterialBuildState): void;
  54797. /**
  54798. * Gets the current class name
  54799. * @returns the class name
  54800. */
  54801. getClassName(): string;
  54802. /**
  54803. * Gets the matrix indices input component
  54804. */
  54805. readonly matricesIndices: NodeMaterialConnectionPoint;
  54806. /**
  54807. * Gets the matrix weights input component
  54808. */
  54809. readonly matricesWeights: NodeMaterialConnectionPoint;
  54810. /**
  54811. * Gets the extra matrix indices input component
  54812. */
  54813. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54814. /**
  54815. * Gets the extra matrix weights input component
  54816. */
  54817. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54818. /**
  54819. * Gets the world input component
  54820. */
  54821. readonly world: NodeMaterialConnectionPoint;
  54822. /**
  54823. * Gets the output component
  54824. */
  54825. readonly output: NodeMaterialConnectionPoint;
  54826. autoConfigure(): void;
  54827. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54830. protected _buildBlock(state: NodeMaterialBuildState): this;
  54831. }
  54832. }
  54833. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54838. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54839. /**
  54840. * Block used to add support for instances
  54841. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54842. */
  54843. export class InstancesBlock extends NodeMaterialBlock {
  54844. /**
  54845. * Creates a new InstancesBlock
  54846. * @param name defines the block name
  54847. */
  54848. constructor(name: string);
  54849. /**
  54850. * Gets the current class name
  54851. * @returns the class name
  54852. */
  54853. getClassName(): string;
  54854. /**
  54855. * Gets the first world row input component
  54856. */
  54857. readonly world0: NodeMaterialConnectionPoint;
  54858. /**
  54859. * Gets the second world row input component
  54860. */
  54861. readonly world1: NodeMaterialConnectionPoint;
  54862. /**
  54863. * Gets the third world row input component
  54864. */
  54865. readonly world2: NodeMaterialConnectionPoint;
  54866. /**
  54867. * Gets the forth world row input component
  54868. */
  54869. readonly world3: NodeMaterialConnectionPoint;
  54870. /**
  54871. * Gets the world input component
  54872. */
  54873. readonly world: NodeMaterialConnectionPoint;
  54874. /**
  54875. * Gets the output component
  54876. */
  54877. readonly output: NodeMaterialConnectionPoint;
  54878. autoConfigure(): void;
  54879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54880. protected _buildBlock(state: NodeMaterialBuildState): this;
  54881. }
  54882. }
  54883. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54888. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54889. import { Effect } from "babylonjs/Materials/effect";
  54890. import { Mesh } from "babylonjs/Meshes/mesh";
  54891. /**
  54892. * Block used to add morph targets support to vertex shader
  54893. */
  54894. export class MorphTargetsBlock extends NodeMaterialBlock {
  54895. private _repeatableContentAnchor;
  54896. private _repeatebleContentGenerated;
  54897. /**
  54898. * Create a new MorphTargetsBlock
  54899. * @param name defines the block name
  54900. */
  54901. constructor(name: string);
  54902. /**
  54903. * Gets the current class name
  54904. * @returns the class name
  54905. */
  54906. getClassName(): string;
  54907. /**
  54908. * Gets the position input component
  54909. */
  54910. readonly position: NodeMaterialConnectionPoint;
  54911. /**
  54912. * Gets the normal input component
  54913. */
  54914. readonly normal: NodeMaterialConnectionPoint;
  54915. /**
  54916. * Gets the tangent input component
  54917. */
  54918. readonly tangent: NodeMaterialConnectionPoint;
  54919. /**
  54920. * Gets the tangent input component
  54921. */
  54922. readonly uv: NodeMaterialConnectionPoint;
  54923. /**
  54924. * Gets the position output component
  54925. */
  54926. readonly positionOutput: NodeMaterialConnectionPoint;
  54927. /**
  54928. * Gets the normal output component
  54929. */
  54930. readonly normalOutput: NodeMaterialConnectionPoint;
  54931. /**
  54932. * Gets the tangent output component
  54933. */
  54934. readonly tangentOutput: NodeMaterialConnectionPoint;
  54935. /**
  54936. * Gets the tangent output component
  54937. */
  54938. readonly uvOutput: NodeMaterialConnectionPoint;
  54939. initialize(state: NodeMaterialBuildState): void;
  54940. autoConfigure(): void;
  54941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54943. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54944. protected _buildBlock(state: NodeMaterialBuildState): this;
  54945. }
  54946. }
  54947. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54948. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54949. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54950. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54951. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54952. }
  54953. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54957. /**
  54958. * Block used to add an alpha test in the fragment shader
  54959. */
  54960. export class AlphaTestBlock extends NodeMaterialBlock {
  54961. /**
  54962. * Gets or sets the alpha value where alpha testing happens
  54963. */
  54964. alphaCutOff: number;
  54965. /**
  54966. * Create a new AlphaTestBlock
  54967. * @param name defines the block name
  54968. */
  54969. constructor(name: string);
  54970. /**
  54971. * Gets the current class name
  54972. * @returns the class name
  54973. */
  54974. getClassName(): string;
  54975. /**
  54976. * Gets the color input component
  54977. */
  54978. readonly color: NodeMaterialConnectionPoint;
  54979. /**
  54980. * Gets the alpha input component
  54981. */
  54982. readonly alpha: NodeMaterialConnectionPoint;
  54983. protected _buildBlock(state: NodeMaterialBuildState): this;
  54984. }
  54985. }
  54986. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  54987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54990. /**
  54991. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54992. */
  54993. export class ColorMergerBlock extends NodeMaterialBlock {
  54994. /**
  54995. * Create a new ColorMergerBlock
  54996. * @param name defines the block name
  54997. */
  54998. constructor(name: string);
  54999. /**
  55000. * Gets the current class name
  55001. * @returns the class name
  55002. */
  55003. getClassName(): string;
  55004. /**
  55005. * Gets the r component (input)
  55006. */
  55007. readonly r: NodeMaterialConnectionPoint;
  55008. /**
  55009. * Gets the g component (input)
  55010. */
  55011. readonly g: NodeMaterialConnectionPoint;
  55012. /**
  55013. * Gets the b component (input)
  55014. */
  55015. readonly b: NodeMaterialConnectionPoint;
  55016. /**
  55017. * Gets the a component (input)
  55018. */
  55019. readonly a: NodeMaterialConnectionPoint;
  55020. /**
  55021. * Gets the rgba component (output)
  55022. */
  55023. readonly rgba: NodeMaterialConnectionPoint;
  55024. /**
  55025. * Gets the rgb component (output)
  55026. */
  55027. readonly rgb: NodeMaterialConnectionPoint;
  55028. protected _buildBlock(state: NodeMaterialBuildState): this;
  55029. }
  55030. }
  55031. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55035. /**
  55036. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55037. */
  55038. export class VectorMergerBlock extends NodeMaterialBlock {
  55039. /**
  55040. * Create a new VectorMergerBlock
  55041. * @param name defines the block name
  55042. */
  55043. constructor(name: string);
  55044. /**
  55045. * Gets the current class name
  55046. * @returns the class name
  55047. */
  55048. getClassName(): string;
  55049. /**
  55050. * Gets the x component (input)
  55051. */
  55052. readonly x: NodeMaterialConnectionPoint;
  55053. /**
  55054. * Gets the y component (input)
  55055. */
  55056. readonly y: NodeMaterialConnectionPoint;
  55057. /**
  55058. * Gets the z component (input)
  55059. */
  55060. readonly z: NodeMaterialConnectionPoint;
  55061. /**
  55062. * Gets the w component (input)
  55063. */
  55064. readonly w: NodeMaterialConnectionPoint;
  55065. /**
  55066. * Gets the xyzw component (output)
  55067. */
  55068. readonly xyzw: NodeMaterialConnectionPoint;
  55069. /**
  55070. * Gets the xyz component (output)
  55071. */
  55072. readonly xyz: NodeMaterialConnectionPoint;
  55073. /**
  55074. * Gets the xy component (output)
  55075. */
  55076. readonly xy: NodeMaterialConnectionPoint;
  55077. protected _buildBlock(state: NodeMaterialBuildState): this;
  55078. }
  55079. }
  55080. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55084. /**
  55085. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55086. */
  55087. export class ColorSplitterBlock extends NodeMaterialBlock {
  55088. /**
  55089. * Create a new ColorSplitterBlock
  55090. * @param name defines the block name
  55091. */
  55092. constructor(name: string);
  55093. /**
  55094. * Gets the current class name
  55095. * @returns the class name
  55096. */
  55097. getClassName(): string;
  55098. /**
  55099. * Gets the rgba component (input)
  55100. */
  55101. readonly rgba: NodeMaterialConnectionPoint;
  55102. /**
  55103. * Gets the rgb component (input)
  55104. */
  55105. readonly rgbIn: NodeMaterialConnectionPoint;
  55106. /**
  55107. * Gets the rgb component (output)
  55108. */
  55109. readonly rgbOut: NodeMaterialConnectionPoint;
  55110. /**
  55111. * Gets the r component (output)
  55112. */
  55113. readonly r: NodeMaterialConnectionPoint;
  55114. /**
  55115. * Gets the g component (output)
  55116. */
  55117. readonly g: NodeMaterialConnectionPoint;
  55118. /**
  55119. * Gets the b component (output)
  55120. */
  55121. readonly b: NodeMaterialConnectionPoint;
  55122. /**
  55123. * Gets the a component (output)
  55124. */
  55125. readonly a: NodeMaterialConnectionPoint;
  55126. protected _buildBlock(state: NodeMaterialBuildState): this;
  55127. }
  55128. }
  55129. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55133. /**
  55134. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55135. */
  55136. export class VectorSplitterBlock extends NodeMaterialBlock {
  55137. /**
  55138. * Create a new VectorSplitterBlock
  55139. * @param name defines the block name
  55140. */
  55141. constructor(name: string);
  55142. /**
  55143. * Gets the current class name
  55144. * @returns the class name
  55145. */
  55146. getClassName(): string;
  55147. /**
  55148. * Gets the xyzw component (input)
  55149. */
  55150. readonly xyzw: NodeMaterialConnectionPoint;
  55151. /**
  55152. * Gets the xyz component (input)
  55153. */
  55154. readonly xyzIn: NodeMaterialConnectionPoint;
  55155. /**
  55156. * Gets the xyz component (output)
  55157. */
  55158. readonly xyzOut: NodeMaterialConnectionPoint;
  55159. /**
  55160. * Gets the xy component (output)
  55161. */
  55162. readonly xy: NodeMaterialConnectionPoint;
  55163. /**
  55164. * Gets the x component (output)
  55165. */
  55166. readonly x: NodeMaterialConnectionPoint;
  55167. /**
  55168. * Gets the y component (output)
  55169. */
  55170. readonly y: NodeMaterialConnectionPoint;
  55171. /**
  55172. * Gets the z component (output)
  55173. */
  55174. readonly z: NodeMaterialConnectionPoint;
  55175. /**
  55176. * Gets the w component (output)
  55177. */
  55178. readonly w: NodeMaterialConnectionPoint;
  55179. protected _buildBlock(state: NodeMaterialBuildState): this;
  55180. }
  55181. }
  55182. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55183. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55185. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55187. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55188. import { Effect } from "babylonjs/Materials/effect";
  55189. import { Mesh } from "babylonjs/Meshes/mesh";
  55190. /**
  55191. * Block used to add image processing support to fragment shader
  55192. */
  55193. export class ImageProcessingBlock extends NodeMaterialBlock {
  55194. /**
  55195. * Create a new ImageProcessingBlock
  55196. * @param name defines the block name
  55197. */
  55198. constructor(name: string);
  55199. /**
  55200. * Gets the current class name
  55201. * @returns the class name
  55202. */
  55203. getClassName(): string;
  55204. /**
  55205. * Gets the color input component
  55206. */
  55207. readonly color: NodeMaterialConnectionPoint;
  55208. /**
  55209. * Gets the output component
  55210. */
  55211. readonly output: NodeMaterialConnectionPoint;
  55212. /**
  55213. * Initialize the block and prepare the context for build
  55214. * @param state defines the state that will be used for the build
  55215. */
  55216. initialize(state: NodeMaterialBuildState): void;
  55217. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55220. protected _buildBlock(state: NodeMaterialBuildState): this;
  55221. }
  55222. }
  55223. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55224. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55225. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55226. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55227. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55228. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55229. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55230. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55231. }
  55232. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55235. import { Mesh } from "babylonjs/Meshes/mesh";
  55236. import { Effect } from "babylonjs/Materials/effect";
  55237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55239. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55240. /**
  55241. * Block used to add support for scene fog
  55242. */
  55243. export class FogBlock extends NodeMaterialBlock {
  55244. private _fogDistanceName;
  55245. private _fogParameters;
  55246. /**
  55247. * Create a new FogBlock
  55248. * @param name defines the block name
  55249. */
  55250. constructor(name: string);
  55251. /**
  55252. * Gets the current class name
  55253. * @returns the class name
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Gets the world position input component
  55258. */
  55259. readonly worldPosition: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the view input component
  55262. */
  55263. readonly view: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the color input component
  55266. */
  55267. readonly color: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the fog color input component
  55270. */
  55271. readonly fogColor: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the output component
  55274. */
  55275. readonly output: NodeMaterialConnectionPoint;
  55276. autoConfigure(): void;
  55277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55278. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55279. protected _buildBlock(state: NodeMaterialBuildState): this;
  55280. }
  55281. }
  55282. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55287. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55288. import { Effect } from "babylonjs/Materials/effect";
  55289. import { Mesh } from "babylonjs/Meshes/mesh";
  55290. import { Light } from "babylonjs/Lights/light";
  55291. import { Nullable } from "babylonjs/types";
  55292. import { Scene } from "babylonjs/scene";
  55293. /**
  55294. * Block used to add light in the fragment shader
  55295. */
  55296. export class LightBlock extends NodeMaterialBlock {
  55297. private _lightId;
  55298. /**
  55299. * Gets or sets the light associated with this block
  55300. */
  55301. light: Nullable<Light>;
  55302. /**
  55303. * Create a new LightBlock
  55304. * @param name defines the block name
  55305. */
  55306. constructor(name: string);
  55307. /**
  55308. * Gets the current class name
  55309. * @returns the class name
  55310. */
  55311. getClassName(): string;
  55312. /**
  55313. * Gets the world position input component
  55314. */
  55315. readonly worldPosition: NodeMaterialConnectionPoint;
  55316. /**
  55317. * Gets the world normal input component
  55318. */
  55319. readonly worldNormal: NodeMaterialConnectionPoint;
  55320. /**
  55321. * Gets the camera (or eye) position component
  55322. */
  55323. readonly cameraPosition: NodeMaterialConnectionPoint;
  55324. /**
  55325. * Gets the diffuse output component
  55326. */
  55327. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55328. /**
  55329. * Gets the specular output component
  55330. */
  55331. readonly specularOutput: NodeMaterialConnectionPoint;
  55332. autoConfigure(): void;
  55333. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55334. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55336. private _injectVertexCode;
  55337. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55338. serialize(): any;
  55339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55340. }
  55341. }
  55342. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55343. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55344. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55345. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55346. }
  55347. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55348. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55349. }
  55350. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55354. /**
  55355. * Block used to multiply 2 values
  55356. */
  55357. export class MultiplyBlock extends NodeMaterialBlock {
  55358. /**
  55359. * Creates a new MultiplyBlock
  55360. * @param name defines the block name
  55361. */
  55362. constructor(name: string);
  55363. /**
  55364. * Gets the current class name
  55365. * @returns the class name
  55366. */
  55367. getClassName(): string;
  55368. /**
  55369. * Gets the left operand input component
  55370. */
  55371. readonly left: NodeMaterialConnectionPoint;
  55372. /**
  55373. * Gets the right operand input component
  55374. */
  55375. readonly right: NodeMaterialConnectionPoint;
  55376. /**
  55377. * Gets the output component
  55378. */
  55379. readonly output: NodeMaterialConnectionPoint;
  55380. protected _buildBlock(state: NodeMaterialBuildState): this;
  55381. }
  55382. }
  55383. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55387. /**
  55388. * Block used to add 2 vectors
  55389. */
  55390. export class AddBlock extends NodeMaterialBlock {
  55391. /**
  55392. * Creates a new AddBlock
  55393. * @param name defines the block name
  55394. */
  55395. constructor(name: string);
  55396. /**
  55397. * Gets the current class name
  55398. * @returns the class name
  55399. */
  55400. getClassName(): string;
  55401. /**
  55402. * Gets the left operand input component
  55403. */
  55404. readonly left: NodeMaterialConnectionPoint;
  55405. /**
  55406. * Gets the right operand input component
  55407. */
  55408. readonly right: NodeMaterialConnectionPoint;
  55409. /**
  55410. * Gets the output component
  55411. */
  55412. readonly output: NodeMaterialConnectionPoint;
  55413. protected _buildBlock(state: NodeMaterialBuildState): this;
  55414. }
  55415. }
  55416. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55420. /**
  55421. * Block used to clamp a float
  55422. */
  55423. export class ClampBlock extends NodeMaterialBlock {
  55424. /** Gets or sets the minimum range */
  55425. minimum: number;
  55426. /** Gets or sets the maximum range */
  55427. maximum: number;
  55428. /**
  55429. * Creates a new ClampBlock
  55430. * @param name defines the block name
  55431. */
  55432. constructor(name: string);
  55433. /**
  55434. * Gets the current class name
  55435. * @returns the class name
  55436. */
  55437. getClassName(): string;
  55438. /**
  55439. * Gets the value input component
  55440. */
  55441. readonly value: NodeMaterialConnectionPoint;
  55442. /**
  55443. * Gets the output component
  55444. */
  55445. readonly output: NodeMaterialConnectionPoint;
  55446. protected _buildBlock(state: NodeMaterialBuildState): this;
  55447. }
  55448. }
  55449. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55453. /**
  55454. * Block used to apply a cross product between 2 vectors
  55455. */
  55456. export class CrossBlock extends NodeMaterialBlock {
  55457. /**
  55458. * Creates a new CrossBlock
  55459. * @param name defines the block name
  55460. */
  55461. constructor(name: string);
  55462. /**
  55463. * Gets the current class name
  55464. * @returns the class name
  55465. */
  55466. getClassName(): string;
  55467. /**
  55468. * Gets the left operand input component
  55469. */
  55470. readonly left: NodeMaterialConnectionPoint;
  55471. /**
  55472. * Gets the right operand input component
  55473. */
  55474. readonly right: NodeMaterialConnectionPoint;
  55475. /**
  55476. * Gets the output component
  55477. */
  55478. readonly output: NodeMaterialConnectionPoint;
  55479. protected _buildBlock(state: NodeMaterialBuildState): this;
  55480. }
  55481. }
  55482. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55486. /**
  55487. * Block used to apply a dot product between 2 vectors
  55488. */
  55489. export class DotBlock extends NodeMaterialBlock {
  55490. /**
  55491. * Creates a new DotBlock
  55492. * @param name defines the block name
  55493. */
  55494. constructor(name: string);
  55495. /**
  55496. * Gets the current class name
  55497. * @returns the class name
  55498. */
  55499. getClassName(): string;
  55500. /**
  55501. * Gets the left operand input component
  55502. */
  55503. readonly left: NodeMaterialConnectionPoint;
  55504. /**
  55505. * Gets the right operand input component
  55506. */
  55507. readonly right: NodeMaterialConnectionPoint;
  55508. /**
  55509. * Gets the output component
  55510. */
  55511. readonly output: NodeMaterialConnectionPoint;
  55512. protected _buildBlock(state: NodeMaterialBuildState): this;
  55513. }
  55514. }
  55515. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55519. import { Vector2 } from "babylonjs/Maths/math.vector";
  55520. /**
  55521. * Block used to remap a float from a range to a new one
  55522. */
  55523. export class RemapBlock extends NodeMaterialBlock {
  55524. /**
  55525. * Gets or sets the source range
  55526. */
  55527. sourceRange: Vector2;
  55528. /**
  55529. * Gets or sets the target range
  55530. */
  55531. targetRange: Vector2;
  55532. /**
  55533. * Creates a new RemapBlock
  55534. * @param name defines the block name
  55535. */
  55536. constructor(name: string);
  55537. /**
  55538. * Gets the current class name
  55539. * @returns the class name
  55540. */
  55541. getClassName(): string;
  55542. /**
  55543. * Gets the input component
  55544. */
  55545. readonly input: NodeMaterialConnectionPoint;
  55546. /**
  55547. * Gets the output component
  55548. */
  55549. readonly output: NodeMaterialConnectionPoint;
  55550. protected _buildBlock(state: NodeMaterialBuildState): this;
  55551. }
  55552. }
  55553. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55557. /**
  55558. * Block used to normalize a vector
  55559. */
  55560. export class NormalizeBlock extends NodeMaterialBlock {
  55561. /**
  55562. * Creates a new NormalizeBlock
  55563. * @param name defines the block name
  55564. */
  55565. constructor(name: string);
  55566. /**
  55567. * Gets the current class name
  55568. * @returns the class name
  55569. */
  55570. getClassName(): string;
  55571. /**
  55572. * Gets the input component
  55573. */
  55574. readonly input: NodeMaterialConnectionPoint;
  55575. /**
  55576. * Gets the output component
  55577. */
  55578. readonly output: NodeMaterialConnectionPoint;
  55579. protected _buildBlock(state: NodeMaterialBuildState): this;
  55580. }
  55581. }
  55582. declare module "babylonjs/Materials/Node/Blocks/index" {
  55583. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55584. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55585. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55586. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55587. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55588. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55589. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55590. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55591. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55592. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55593. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  55594. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  55595. }
  55596. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55597. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55598. }
  55599. declare module "babylonjs/Materials/Node/index" {
  55600. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55601. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55602. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55603. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55604. export * from "babylonjs/Materials/Node/nodeMaterial";
  55605. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55606. export * from "babylonjs/Materials/Node/Blocks/index";
  55607. export * from "babylonjs/Materials/Node/Optimizers/index";
  55608. }
  55609. declare module "babylonjs/Materials/effectRenderer" {
  55610. import { Nullable } from "babylonjs/types";
  55611. import { Texture } from "babylonjs/Materials/Textures/texture";
  55612. import { Engine } from "babylonjs/Engines/engine";
  55613. import { Viewport } from "babylonjs/Maths/math.viewport";
  55614. import { Observable } from "babylonjs/Misc/observable";
  55615. import { Effect } from "babylonjs/Materials/effect";
  55616. import "babylonjs/Shaders/postprocess.vertex";
  55617. /**
  55618. * Effect Render Options
  55619. */
  55620. export interface IEffectRendererOptions {
  55621. /**
  55622. * Defines the vertices positions.
  55623. */
  55624. positions?: number[];
  55625. /**
  55626. * Defines the indices.
  55627. */
  55628. indices?: number[];
  55629. }
  55630. /**
  55631. * Helper class to render one or more effects
  55632. */
  55633. export class EffectRenderer {
  55634. private engine;
  55635. private static _DefaultOptions;
  55636. private _vertexBuffers;
  55637. private _indexBuffer;
  55638. private _ringBufferIndex;
  55639. private _ringScreenBuffer;
  55640. private _fullscreenViewport;
  55641. private _getNextFrameBuffer;
  55642. /**
  55643. * Creates an effect renderer
  55644. * @param engine the engine to use for rendering
  55645. * @param options defines the options of the effect renderer
  55646. */
  55647. constructor(engine: Engine, options?: IEffectRendererOptions);
  55648. /**
  55649. * Sets the current viewport in normalized coordinates 0-1
  55650. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55651. */
  55652. setViewport(viewport?: Viewport): void;
  55653. /**
  55654. * Sets the current effect wrapper to use during draw.
  55655. * The effect needs to be ready before calling this api.
  55656. * This also sets the default full screen position attribute.
  55657. * @param effectWrapper Defines the effect to draw with
  55658. */
  55659. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55660. /**
  55661. * Draws a full screen quad.
  55662. */
  55663. draw(): void;
  55664. /**
  55665. * renders one or more effects to a specified texture
  55666. * @param effectWrappers list of effects to renderer
  55667. * @param outputTexture texture to draw to, if null it will render to the screen
  55668. */
  55669. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55670. /**
  55671. * Disposes of the effect renderer
  55672. */
  55673. dispose(): void;
  55674. }
  55675. /**
  55676. * Options to create an EffectWrapper
  55677. */
  55678. interface EffectWrapperCreationOptions {
  55679. /**
  55680. * Engine to use to create the effect
  55681. */
  55682. engine: Engine;
  55683. /**
  55684. * Fragment shader for the effect
  55685. */
  55686. fragmentShader: string;
  55687. /**
  55688. * Vertex shader for the effect
  55689. */
  55690. vertexShader?: string;
  55691. /**
  55692. * Attributes to use in the shader
  55693. */
  55694. attributeNames?: Array<string>;
  55695. /**
  55696. * Uniforms to use in the shader
  55697. */
  55698. uniformNames?: Array<string>;
  55699. /**
  55700. * Texture sampler names to use in the shader
  55701. */
  55702. samplerNames?: Array<string>;
  55703. /**
  55704. * The friendly name of the effect displayed in Spector.
  55705. */
  55706. name?: string;
  55707. }
  55708. /**
  55709. * Wraps an effect to be used for rendering
  55710. */
  55711. export class EffectWrapper {
  55712. /**
  55713. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55714. */
  55715. onApplyObservable: Observable<{}>;
  55716. /**
  55717. * The underlying effect
  55718. */
  55719. effect: Effect;
  55720. /**
  55721. * Creates an effect to be renderer
  55722. * @param creationOptions options to create the effect
  55723. */
  55724. constructor(creationOptions: EffectWrapperCreationOptions);
  55725. /**
  55726. * Disposes of the effect wrapper
  55727. */
  55728. dispose(): void;
  55729. }
  55730. }
  55731. declare module "babylonjs/Materials/index" {
  55732. export * from "babylonjs/Materials/Background/index";
  55733. export * from "babylonjs/Materials/colorCurves";
  55734. export * from "babylonjs/Materials/effect";
  55735. export * from "babylonjs/Materials/fresnelParameters";
  55736. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55737. export * from "babylonjs/Materials/material";
  55738. export * from "babylonjs/Materials/materialDefines";
  55739. export * from "babylonjs/Materials/materialHelper";
  55740. export * from "babylonjs/Materials/multiMaterial";
  55741. export * from "babylonjs/Materials/PBR/index";
  55742. export * from "babylonjs/Materials/pushMaterial";
  55743. export * from "babylonjs/Materials/shaderMaterial";
  55744. export * from "babylonjs/Materials/standardMaterial";
  55745. export * from "babylonjs/Materials/Textures/index";
  55746. export * from "babylonjs/Materials/uniformBuffer";
  55747. export * from "babylonjs/Materials/materialFlags";
  55748. export * from "babylonjs/Materials/Node/index";
  55749. export * from "babylonjs/Materials/effectRenderer";
  55750. }
  55751. declare module "babylonjs/Maths/index" {
  55752. export * from "babylonjs/Maths/math.scalar";
  55753. export * from "babylonjs/Maths/math";
  55754. export * from "babylonjs/Maths/sphericalPolynomial";
  55755. }
  55756. declare module "babylonjs/Misc/workerPool" {
  55757. import { IDisposable } from "babylonjs/scene";
  55758. /**
  55759. * Helper class to push actions to a pool of workers.
  55760. */
  55761. export class WorkerPool implements IDisposable {
  55762. private _workerInfos;
  55763. private _pendingActions;
  55764. /**
  55765. * Constructor
  55766. * @param workers Array of workers to use for actions
  55767. */
  55768. constructor(workers: Array<Worker>);
  55769. /**
  55770. * Terminates all workers and clears any pending actions.
  55771. */
  55772. dispose(): void;
  55773. /**
  55774. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55775. * pended until a worker has completed its action.
  55776. * @param action The action to perform. Call onComplete when the action is complete.
  55777. */
  55778. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55779. private _execute;
  55780. }
  55781. }
  55782. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55783. import { IDisposable } from "babylonjs/scene";
  55784. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55785. /**
  55786. * Configuration for Draco compression
  55787. */
  55788. export interface IDracoCompressionConfiguration {
  55789. /**
  55790. * Configuration for the decoder.
  55791. */
  55792. decoder: {
  55793. /**
  55794. * The url to the WebAssembly module.
  55795. */
  55796. wasmUrl?: string;
  55797. /**
  55798. * The url to the WebAssembly binary.
  55799. */
  55800. wasmBinaryUrl?: string;
  55801. /**
  55802. * The url to the fallback JavaScript module.
  55803. */
  55804. fallbackUrl?: string;
  55805. };
  55806. }
  55807. /**
  55808. * Draco compression (https://google.github.io/draco/)
  55809. *
  55810. * This class wraps the Draco module.
  55811. *
  55812. * **Encoder**
  55813. *
  55814. * The encoder is not currently implemented.
  55815. *
  55816. * **Decoder**
  55817. *
  55818. * 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.
  55819. *
  55820. * To update the configuration, use the following code:
  55821. * ```javascript
  55822. * DracoCompression.Configuration = {
  55823. * decoder: {
  55824. * wasmUrl: "<url to the WebAssembly library>",
  55825. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55826. * fallbackUrl: "<url to the fallback JavaScript library>",
  55827. * }
  55828. * };
  55829. * ```
  55830. *
  55831. * 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.
  55832. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55833. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55834. *
  55835. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55836. * ```javascript
  55837. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55838. * ```
  55839. *
  55840. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55841. */
  55842. export class DracoCompression implements IDisposable {
  55843. private _workerPoolPromise?;
  55844. private _decoderModulePromise?;
  55845. /**
  55846. * The configuration. Defaults to the following urls:
  55847. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55848. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55849. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55850. */
  55851. static Configuration: IDracoCompressionConfiguration;
  55852. /**
  55853. * Returns true if the decoder configuration is available.
  55854. */
  55855. static readonly DecoderAvailable: boolean;
  55856. /**
  55857. * Default number of workers to create when creating the draco compression object.
  55858. */
  55859. static DefaultNumWorkers: number;
  55860. private static GetDefaultNumWorkers;
  55861. private static _Default;
  55862. /**
  55863. * Default instance for the draco compression object.
  55864. */
  55865. static readonly Default: DracoCompression;
  55866. /**
  55867. * Constructor
  55868. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55869. */
  55870. constructor(numWorkers?: number);
  55871. /**
  55872. * Stop all async operations and release resources.
  55873. */
  55874. dispose(): void;
  55875. /**
  55876. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55877. * @returns a promise that resolves when ready
  55878. */
  55879. whenReadyAsync(): Promise<void>;
  55880. /**
  55881. * Decode Draco compressed mesh data to vertex data.
  55882. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55883. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55884. * @returns A promise that resolves with the decoded vertex data
  55885. */
  55886. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55887. [kind: string]: number;
  55888. }): Promise<VertexData>;
  55889. }
  55890. }
  55891. declare module "babylonjs/Meshes/Compression/index" {
  55892. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55893. }
  55894. declare module "babylonjs/Meshes/csg" {
  55895. import { Nullable } from "babylonjs/types";
  55896. import { Scene } from "babylonjs/scene";
  55897. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55898. import { Mesh } from "babylonjs/Meshes/mesh";
  55899. import { Material } from "babylonjs/Materials/material";
  55900. /**
  55901. * Class for building Constructive Solid Geometry
  55902. */
  55903. export class CSG {
  55904. private polygons;
  55905. /**
  55906. * The world matrix
  55907. */
  55908. matrix: Matrix;
  55909. /**
  55910. * Stores the position
  55911. */
  55912. position: Vector3;
  55913. /**
  55914. * Stores the rotation
  55915. */
  55916. rotation: Vector3;
  55917. /**
  55918. * Stores the rotation quaternion
  55919. */
  55920. rotationQuaternion: Nullable<Quaternion>;
  55921. /**
  55922. * Stores the scaling vector
  55923. */
  55924. scaling: Vector3;
  55925. /**
  55926. * Convert the Mesh to CSG
  55927. * @param mesh The Mesh to convert to CSG
  55928. * @returns A new CSG from the Mesh
  55929. */
  55930. static FromMesh(mesh: Mesh): CSG;
  55931. /**
  55932. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55933. * @param polygons Polygons used to construct a CSG solid
  55934. */
  55935. private static FromPolygons;
  55936. /**
  55937. * Clones, or makes a deep copy, of the CSG
  55938. * @returns A new CSG
  55939. */
  55940. clone(): CSG;
  55941. /**
  55942. * Unions this CSG with another CSG
  55943. * @param csg The CSG to union against this CSG
  55944. * @returns The unioned CSG
  55945. */
  55946. union(csg: CSG): CSG;
  55947. /**
  55948. * Unions this CSG with another CSG in place
  55949. * @param csg The CSG to union against this CSG
  55950. */
  55951. unionInPlace(csg: CSG): void;
  55952. /**
  55953. * Subtracts this CSG with another CSG
  55954. * @param csg The CSG to subtract against this CSG
  55955. * @returns A new CSG
  55956. */
  55957. subtract(csg: CSG): CSG;
  55958. /**
  55959. * Subtracts this CSG with another CSG in place
  55960. * @param csg The CSG to subtact against this CSG
  55961. */
  55962. subtractInPlace(csg: CSG): void;
  55963. /**
  55964. * Intersect this CSG with another CSG
  55965. * @param csg The CSG to intersect against this CSG
  55966. * @returns A new CSG
  55967. */
  55968. intersect(csg: CSG): CSG;
  55969. /**
  55970. * Intersects this CSG with another CSG in place
  55971. * @param csg The CSG to intersect against this CSG
  55972. */
  55973. intersectInPlace(csg: CSG): void;
  55974. /**
  55975. * Return a new CSG solid with solid and empty space switched. This solid is
  55976. * not modified.
  55977. * @returns A new CSG solid with solid and empty space switched
  55978. */
  55979. inverse(): CSG;
  55980. /**
  55981. * Inverses the CSG in place
  55982. */
  55983. inverseInPlace(): void;
  55984. /**
  55985. * This is used to keep meshes transformations so they can be restored
  55986. * when we build back a Babylon Mesh
  55987. * NB : All CSG operations are performed in world coordinates
  55988. * @param csg The CSG to copy the transform attributes from
  55989. * @returns This CSG
  55990. */
  55991. copyTransformAttributes(csg: CSG): CSG;
  55992. /**
  55993. * Build Raw mesh from CSG
  55994. * Coordinates here are in world space
  55995. * @param name The name of the mesh geometry
  55996. * @param scene The Scene
  55997. * @param keepSubMeshes Specifies if the submeshes should be kept
  55998. * @returns A new Mesh
  55999. */
  56000. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56001. /**
  56002. * Build Mesh from CSG taking material and transforms into account
  56003. * @param name The name of the Mesh
  56004. * @param material The material of the Mesh
  56005. * @param scene The Scene
  56006. * @param keepSubMeshes Specifies if submeshes should be kept
  56007. * @returns The new Mesh
  56008. */
  56009. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56010. }
  56011. }
  56012. declare module "babylonjs/Meshes/trailMesh" {
  56013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56014. import { Mesh } from "babylonjs/Meshes/mesh";
  56015. import { Scene } from "babylonjs/scene";
  56016. /**
  56017. * Class used to create a trail following a mesh
  56018. */
  56019. export class TrailMesh extends Mesh {
  56020. private _generator;
  56021. private _autoStart;
  56022. private _running;
  56023. private _diameter;
  56024. private _length;
  56025. private _sectionPolygonPointsCount;
  56026. private _sectionVectors;
  56027. private _sectionNormalVectors;
  56028. private _beforeRenderObserver;
  56029. /**
  56030. * @constructor
  56031. * @param name The value used by scene.getMeshByName() to do a lookup.
  56032. * @param generator The mesh to generate a trail.
  56033. * @param scene The scene to add this mesh to.
  56034. * @param diameter Diameter of trailing mesh. Default is 1.
  56035. * @param length Length of trailing mesh. Default is 60.
  56036. * @param autoStart Automatically start trailing mesh. Default true.
  56037. */
  56038. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56039. /**
  56040. * "TrailMesh"
  56041. * @returns "TrailMesh"
  56042. */
  56043. getClassName(): string;
  56044. private _createMesh;
  56045. /**
  56046. * Start trailing mesh.
  56047. */
  56048. start(): void;
  56049. /**
  56050. * Stop trailing mesh.
  56051. */
  56052. stop(): void;
  56053. /**
  56054. * Update trailing mesh geometry.
  56055. */
  56056. update(): void;
  56057. /**
  56058. * Returns a new TrailMesh object.
  56059. * @param name is a string, the name given to the new mesh
  56060. * @param newGenerator use new generator object for cloned trail mesh
  56061. * @returns a new mesh
  56062. */
  56063. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56064. /**
  56065. * Serializes this trail mesh
  56066. * @param serializationObject object to write serialization to
  56067. */
  56068. serialize(serializationObject: any): void;
  56069. /**
  56070. * Parses a serialized trail mesh
  56071. * @param parsedMesh the serialized mesh
  56072. * @param scene the scene to create the trail mesh in
  56073. * @returns the created trail mesh
  56074. */
  56075. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56076. }
  56077. }
  56078. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56079. import { Nullable } from "babylonjs/types";
  56080. import { Scene } from "babylonjs/scene";
  56081. import { Vector4 } from "babylonjs/Maths/math.vector";
  56082. import { Color4 } from "babylonjs/Maths/math.color";
  56083. import { Mesh } from "babylonjs/Meshes/mesh";
  56084. /**
  56085. * Class containing static functions to help procedurally build meshes
  56086. */
  56087. export class TiledBoxBuilder {
  56088. /**
  56089. * Creates a box mesh
  56090. * 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)
  56091. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56095. * @param name defines the name of the mesh
  56096. * @param options defines the options used to create the mesh
  56097. * @param scene defines the hosting scene
  56098. * @returns the box mesh
  56099. */
  56100. static CreateTiledBox(name: string, options: {
  56101. pattern?: number;
  56102. width?: number;
  56103. height?: number;
  56104. depth?: number;
  56105. tileSize?: number;
  56106. tileWidth?: number;
  56107. tileHeight?: number;
  56108. alignHorizontal?: number;
  56109. alignVertical?: number;
  56110. faceUV?: Vector4[];
  56111. faceColors?: Color4[];
  56112. sideOrientation?: number;
  56113. updatable?: boolean;
  56114. }, scene?: Nullable<Scene>): Mesh;
  56115. }
  56116. }
  56117. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56118. import { Vector4 } from "babylonjs/Maths/math.vector";
  56119. import { Mesh } from "babylonjs/Meshes/mesh";
  56120. /**
  56121. * Class containing static functions to help procedurally build meshes
  56122. */
  56123. export class TorusKnotBuilder {
  56124. /**
  56125. * Creates a torus knot mesh
  56126. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56127. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56128. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56129. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56133. * @param name defines the name of the mesh
  56134. * @param options defines the options used to create the mesh
  56135. * @param scene defines the hosting scene
  56136. * @returns the torus knot mesh
  56137. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56138. */
  56139. static CreateTorusKnot(name: string, options: {
  56140. radius?: number;
  56141. tube?: number;
  56142. radialSegments?: number;
  56143. tubularSegments?: number;
  56144. p?: number;
  56145. q?: number;
  56146. updatable?: boolean;
  56147. sideOrientation?: number;
  56148. frontUVs?: Vector4;
  56149. backUVs?: Vector4;
  56150. }, scene: any): Mesh;
  56151. }
  56152. }
  56153. declare module "babylonjs/Meshes/polygonMesh" {
  56154. import { Scene } from "babylonjs/scene";
  56155. import { Vector2 } from "babylonjs/Maths/math.vector";
  56156. import { Mesh } from "babylonjs/Meshes/mesh";
  56157. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56158. import { Path2 } from "babylonjs/Maths/math.path";
  56159. /**
  56160. * Polygon
  56161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56162. */
  56163. export class Polygon {
  56164. /**
  56165. * Creates a rectangle
  56166. * @param xmin bottom X coord
  56167. * @param ymin bottom Y coord
  56168. * @param xmax top X coord
  56169. * @param ymax top Y coord
  56170. * @returns points that make the resulting rectation
  56171. */
  56172. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56173. /**
  56174. * Creates a circle
  56175. * @param radius radius of circle
  56176. * @param cx scale in x
  56177. * @param cy scale in y
  56178. * @param numberOfSides number of sides that make up the circle
  56179. * @returns points that make the resulting circle
  56180. */
  56181. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56182. /**
  56183. * Creates a polygon from input string
  56184. * @param input Input polygon data
  56185. * @returns the parsed points
  56186. */
  56187. static Parse(input: string): Vector2[];
  56188. /**
  56189. * Starts building a polygon from x and y coordinates
  56190. * @param x x coordinate
  56191. * @param y y coordinate
  56192. * @returns the started path2
  56193. */
  56194. static StartingAt(x: number, y: number): Path2;
  56195. }
  56196. /**
  56197. * Builds a polygon
  56198. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56199. */
  56200. export class PolygonMeshBuilder {
  56201. private _points;
  56202. private _outlinepoints;
  56203. private _holes;
  56204. private _name;
  56205. private _scene;
  56206. private _epoints;
  56207. private _eholes;
  56208. private _addToepoint;
  56209. /**
  56210. * Babylon reference to the earcut plugin.
  56211. */
  56212. bjsEarcut: any;
  56213. /**
  56214. * Creates a PolygonMeshBuilder
  56215. * @param name name of the builder
  56216. * @param contours Path of the polygon
  56217. * @param scene scene to add to when creating the mesh
  56218. * @param earcutInjection can be used to inject your own earcut reference
  56219. */
  56220. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56221. /**
  56222. * Adds a whole within the polygon
  56223. * @param hole Array of points defining the hole
  56224. * @returns this
  56225. */
  56226. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56227. /**
  56228. * Creates the polygon
  56229. * @param updatable If the mesh should be updatable
  56230. * @param depth The depth of the mesh created
  56231. * @returns the created mesh
  56232. */
  56233. build(updatable?: boolean, depth?: number): Mesh;
  56234. /**
  56235. * Creates the polygon
  56236. * @param depth The depth of the mesh created
  56237. * @returns the created VertexData
  56238. */
  56239. buildVertexData(depth?: number): VertexData;
  56240. /**
  56241. * Adds a side to the polygon
  56242. * @param positions points that make the polygon
  56243. * @param normals normals of the polygon
  56244. * @param uvs uvs of the polygon
  56245. * @param indices indices of the polygon
  56246. * @param bounds bounds of the polygon
  56247. * @param points points of the polygon
  56248. * @param depth depth of the polygon
  56249. * @param flip flip of the polygon
  56250. */
  56251. private addSide;
  56252. }
  56253. }
  56254. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56255. import { Scene } from "babylonjs/scene";
  56256. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56257. import { Color4 } from "babylonjs/Maths/math.color";
  56258. import { Mesh } from "babylonjs/Meshes/mesh";
  56259. import { Nullable } from "babylonjs/types";
  56260. /**
  56261. * Class containing static functions to help procedurally build meshes
  56262. */
  56263. export class PolygonBuilder {
  56264. /**
  56265. * Creates a polygon mesh
  56266. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56267. * * 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
  56268. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56271. * * Remember you can only change the shape positions, not their number when updating a polygon
  56272. * @param name defines the name of the mesh
  56273. * @param options defines the options used to create the mesh
  56274. * @param scene defines the hosting scene
  56275. * @param earcutInjection can be used to inject your own earcut reference
  56276. * @returns the polygon mesh
  56277. */
  56278. static CreatePolygon(name: string, options: {
  56279. shape: Vector3[];
  56280. holes?: Vector3[][];
  56281. depth?: number;
  56282. faceUV?: Vector4[];
  56283. faceColors?: Color4[];
  56284. updatable?: boolean;
  56285. sideOrientation?: number;
  56286. frontUVs?: Vector4;
  56287. backUVs?: Vector4;
  56288. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56289. /**
  56290. * Creates an extruded polygon mesh, with depth in the Y direction.
  56291. * * 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)
  56292. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56293. * @param name defines the name of the mesh
  56294. * @param options defines the options used to create the mesh
  56295. * @param scene defines the hosting scene
  56296. * @param earcutInjection can be used to inject your own earcut reference
  56297. * @returns the polygon mesh
  56298. */
  56299. static ExtrudePolygon(name: string, options: {
  56300. shape: Vector3[];
  56301. holes?: Vector3[][];
  56302. depth?: number;
  56303. faceUV?: Vector4[];
  56304. faceColors?: Color4[];
  56305. updatable?: boolean;
  56306. sideOrientation?: number;
  56307. frontUVs?: Vector4;
  56308. backUVs?: Vector4;
  56309. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56310. }
  56311. }
  56312. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56313. import { Scene } from "babylonjs/scene";
  56314. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56315. import { Mesh } from "babylonjs/Meshes/mesh";
  56316. import { Nullable } from "babylonjs/types";
  56317. /**
  56318. * Class containing static functions to help procedurally build meshes
  56319. */
  56320. export class LatheBuilder {
  56321. /**
  56322. * Creates lathe mesh.
  56323. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56324. * * 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
  56325. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56326. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56327. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56328. * * 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
  56329. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56330. * * 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
  56331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56335. * @param name defines the name of the mesh
  56336. * @param options defines the options used to create the mesh
  56337. * @param scene defines the hosting scene
  56338. * @returns the lathe mesh
  56339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56340. */
  56341. static CreateLathe(name: string, options: {
  56342. shape: Vector3[];
  56343. radius?: number;
  56344. tessellation?: number;
  56345. clip?: number;
  56346. arc?: number;
  56347. closed?: boolean;
  56348. updatable?: boolean;
  56349. sideOrientation?: number;
  56350. frontUVs?: Vector4;
  56351. backUVs?: Vector4;
  56352. cap?: number;
  56353. invertUV?: boolean;
  56354. }, scene?: Nullable<Scene>): Mesh;
  56355. }
  56356. }
  56357. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56358. import { Nullable } from "babylonjs/types";
  56359. import { Scene } from "babylonjs/scene";
  56360. import { Vector4 } from "babylonjs/Maths/math.vector";
  56361. import { Mesh } from "babylonjs/Meshes/mesh";
  56362. /**
  56363. * Class containing static functions to help procedurally build meshes
  56364. */
  56365. export class TiledPlaneBuilder {
  56366. /**
  56367. * Creates a tiled plane mesh
  56368. * * The parameter `pattern` will, depending on value, do nothing or
  56369. * * * flip (reflect about central vertical) alternate tiles across and up
  56370. * * * flip every tile on alternate rows
  56371. * * * rotate (180 degs) alternate tiles across and up
  56372. * * * rotate every tile on alternate rows
  56373. * * * flip and rotate alternate tiles across and up
  56374. * * * flip and rotate every tile on alternate rows
  56375. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56376. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56379. * * 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)
  56380. * * 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)
  56381. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56382. * @param name defines the name of the mesh
  56383. * @param options defines the options used to create the mesh
  56384. * @param scene defines the hosting scene
  56385. * @returns the box mesh
  56386. */
  56387. static CreateTiledPlane(name: string, options: {
  56388. pattern?: number;
  56389. tileSize?: number;
  56390. tileWidth?: number;
  56391. tileHeight?: number;
  56392. size?: number;
  56393. width?: number;
  56394. height?: number;
  56395. alignHorizontal?: number;
  56396. alignVertical?: number;
  56397. sideOrientation?: number;
  56398. frontUVs?: Vector4;
  56399. backUVs?: Vector4;
  56400. updatable?: boolean;
  56401. }, scene?: Nullable<Scene>): Mesh;
  56402. }
  56403. }
  56404. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56405. import { Nullable } from "babylonjs/types";
  56406. import { Scene } from "babylonjs/scene";
  56407. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56408. import { Mesh } from "babylonjs/Meshes/mesh";
  56409. /**
  56410. * Class containing static functions to help procedurally build meshes
  56411. */
  56412. export class TubeBuilder {
  56413. /**
  56414. * Creates a tube mesh.
  56415. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56416. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56417. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56418. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56419. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56420. * * 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)
  56421. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56422. * * 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
  56423. * * 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
  56424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56428. * @param name defines the name of the mesh
  56429. * @param options defines the options used to create the mesh
  56430. * @param scene defines the hosting scene
  56431. * @returns the tube mesh
  56432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56433. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56434. */
  56435. static CreateTube(name: string, options: {
  56436. path: Vector3[];
  56437. radius?: number;
  56438. tessellation?: number;
  56439. radiusFunction?: {
  56440. (i: number, distance: number): number;
  56441. };
  56442. cap?: number;
  56443. arc?: number;
  56444. updatable?: boolean;
  56445. sideOrientation?: number;
  56446. frontUVs?: Vector4;
  56447. backUVs?: Vector4;
  56448. instance?: Mesh;
  56449. invertUV?: boolean;
  56450. }, scene?: Nullable<Scene>): Mesh;
  56451. }
  56452. }
  56453. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56454. import { Scene } from "babylonjs/scene";
  56455. import { Vector4 } from "babylonjs/Maths/math.vector";
  56456. import { Mesh } from "babylonjs/Meshes/mesh";
  56457. import { Nullable } from "babylonjs/types";
  56458. /**
  56459. * Class containing static functions to help procedurally build meshes
  56460. */
  56461. export class IcoSphereBuilder {
  56462. /**
  56463. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56464. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56465. * * 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`)
  56466. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56467. * * 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
  56468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56471. * @param name defines the name of the mesh
  56472. * @param options defines the options used to create the mesh
  56473. * @param scene defines the hosting scene
  56474. * @returns the icosahedron mesh
  56475. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56476. */
  56477. static CreateIcoSphere(name: string, options: {
  56478. radius?: number;
  56479. radiusX?: number;
  56480. radiusY?: number;
  56481. radiusZ?: number;
  56482. flat?: boolean;
  56483. subdivisions?: number;
  56484. sideOrientation?: number;
  56485. frontUVs?: Vector4;
  56486. backUVs?: Vector4;
  56487. updatable?: boolean;
  56488. }, scene?: Nullable<Scene>): Mesh;
  56489. }
  56490. }
  56491. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56492. import { Vector3 } from "babylonjs/Maths/math.vector";
  56493. import { Mesh } from "babylonjs/Meshes/mesh";
  56494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56495. /**
  56496. * Class containing static functions to help procedurally build meshes
  56497. */
  56498. export class DecalBuilder {
  56499. /**
  56500. * Creates a decal mesh.
  56501. * 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
  56502. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56503. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56504. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56505. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56506. * @param name defines the name of the mesh
  56507. * @param sourceMesh defines the mesh where the decal must be applied
  56508. * @param options defines the options used to create the mesh
  56509. * @param scene defines the hosting scene
  56510. * @returns the decal mesh
  56511. * @see https://doc.babylonjs.com/how_to/decals
  56512. */
  56513. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56514. position?: Vector3;
  56515. normal?: Vector3;
  56516. size?: Vector3;
  56517. angle?: number;
  56518. }): Mesh;
  56519. }
  56520. }
  56521. declare module "babylonjs/Meshes/meshBuilder" {
  56522. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56523. import { Nullable } from "babylonjs/types";
  56524. import { Scene } from "babylonjs/scene";
  56525. import { Mesh } from "babylonjs/Meshes/mesh";
  56526. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56527. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56529. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56530. import { Plane } from "babylonjs/Maths/math.plane";
  56531. /**
  56532. * Class containing static functions to help procedurally build meshes
  56533. */
  56534. export class MeshBuilder {
  56535. /**
  56536. * Creates a box mesh
  56537. * * The parameter `size` sets the size (float) of each box side (default 1)
  56538. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56539. * * 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)
  56540. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56544. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56545. * @param name defines the name of the mesh
  56546. * @param options defines the options used to create the mesh
  56547. * @param scene defines the hosting scene
  56548. * @returns the box mesh
  56549. */
  56550. static CreateBox(name: string, options: {
  56551. size?: number;
  56552. width?: number;
  56553. height?: number;
  56554. depth?: number;
  56555. faceUV?: Vector4[];
  56556. faceColors?: Color4[];
  56557. sideOrientation?: number;
  56558. frontUVs?: Vector4;
  56559. backUVs?: Vector4;
  56560. updatable?: boolean;
  56561. }, scene?: Nullable<Scene>): Mesh;
  56562. /**
  56563. * Creates a tiled box mesh
  56564. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56566. * @param name defines the name of the mesh
  56567. * @param options defines the options used to create the mesh
  56568. * @param scene defines the hosting scene
  56569. * @returns the tiled box mesh
  56570. */
  56571. static CreateTiledBox(name: string, options: {
  56572. pattern?: number;
  56573. size?: number;
  56574. width?: number;
  56575. height?: number;
  56576. depth: number;
  56577. tileSize?: number;
  56578. tileWidth?: number;
  56579. tileHeight?: number;
  56580. faceUV?: Vector4[];
  56581. faceColors?: Color4[];
  56582. alignHorizontal?: number;
  56583. alignVertical?: number;
  56584. sideOrientation?: number;
  56585. updatable?: boolean;
  56586. }, scene?: Nullable<Scene>): Mesh;
  56587. /**
  56588. * Creates a sphere mesh
  56589. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56590. * * 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`)
  56591. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56592. * * 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
  56593. * * 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)
  56594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56597. * @param name defines the name of the mesh
  56598. * @param options defines the options used to create the mesh
  56599. * @param scene defines the hosting scene
  56600. * @returns the sphere mesh
  56601. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56602. */
  56603. static CreateSphere(name: string, options: {
  56604. segments?: number;
  56605. diameter?: number;
  56606. diameterX?: number;
  56607. diameterY?: number;
  56608. diameterZ?: number;
  56609. arc?: number;
  56610. slice?: number;
  56611. sideOrientation?: number;
  56612. frontUVs?: Vector4;
  56613. backUVs?: Vector4;
  56614. updatable?: boolean;
  56615. }, scene?: Nullable<Scene>): Mesh;
  56616. /**
  56617. * Creates a plane polygonal mesh. By default, this is a disc
  56618. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56619. * * 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
  56620. * * 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
  56621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56624. * @param name defines the name of the mesh
  56625. * @param options defines the options used to create the mesh
  56626. * @param scene defines the hosting scene
  56627. * @returns the plane polygonal mesh
  56628. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56629. */
  56630. static CreateDisc(name: string, options: {
  56631. radius?: number;
  56632. tessellation?: number;
  56633. arc?: number;
  56634. updatable?: boolean;
  56635. sideOrientation?: number;
  56636. frontUVs?: Vector4;
  56637. backUVs?: Vector4;
  56638. }, scene?: Nullable<Scene>): Mesh;
  56639. /**
  56640. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56641. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56642. * * 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`)
  56643. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56644. * * 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
  56645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56648. * @param name defines the name of the mesh
  56649. * @param options defines the options used to create the mesh
  56650. * @param scene defines the hosting scene
  56651. * @returns the icosahedron mesh
  56652. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56653. */
  56654. static CreateIcoSphere(name: string, options: {
  56655. radius?: number;
  56656. radiusX?: number;
  56657. radiusY?: number;
  56658. radiusZ?: number;
  56659. flat?: boolean;
  56660. subdivisions?: number;
  56661. sideOrientation?: number;
  56662. frontUVs?: Vector4;
  56663. backUVs?: Vector4;
  56664. updatable?: boolean;
  56665. }, scene?: Nullable<Scene>): Mesh;
  56666. /**
  56667. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56668. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56669. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56670. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56671. * * 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
  56672. * * 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
  56673. * * 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
  56674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56677. * * 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
  56678. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56679. * * 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
  56680. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56682. * @param name defines the name of the mesh
  56683. * @param options defines the options used to create the mesh
  56684. * @param scene defines the hosting scene
  56685. * @returns the ribbon mesh
  56686. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56688. */
  56689. static CreateRibbon(name: string, options: {
  56690. pathArray: Vector3[][];
  56691. closeArray?: boolean;
  56692. closePath?: boolean;
  56693. offset?: number;
  56694. updatable?: boolean;
  56695. sideOrientation?: number;
  56696. frontUVs?: Vector4;
  56697. backUVs?: Vector4;
  56698. instance?: Mesh;
  56699. invertUV?: boolean;
  56700. uvs?: Vector2[];
  56701. colors?: Color4[];
  56702. }, scene?: Nullable<Scene>): Mesh;
  56703. /**
  56704. * Creates a cylinder or a cone mesh
  56705. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56706. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56707. * * 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.
  56708. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56709. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56710. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56711. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56712. * * 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).
  56713. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56714. * * 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).
  56715. * * 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
  56716. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56717. * * 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
  56718. * * 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.
  56719. * * If `enclose` is false, a ring surface is one element.
  56720. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56721. * * 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
  56722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56725. * @param name defines the name of the mesh
  56726. * @param options defines the options used to create the mesh
  56727. * @param scene defines the hosting scene
  56728. * @returns the cylinder mesh
  56729. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56730. */
  56731. static CreateCylinder(name: string, options: {
  56732. height?: number;
  56733. diameterTop?: number;
  56734. diameterBottom?: number;
  56735. diameter?: number;
  56736. tessellation?: number;
  56737. subdivisions?: number;
  56738. arc?: number;
  56739. faceColors?: Color4[];
  56740. faceUV?: Vector4[];
  56741. updatable?: boolean;
  56742. hasRings?: boolean;
  56743. enclose?: boolean;
  56744. cap?: number;
  56745. sideOrientation?: number;
  56746. frontUVs?: Vector4;
  56747. backUVs?: Vector4;
  56748. }, scene?: Nullable<Scene>): Mesh;
  56749. /**
  56750. * Creates a torus mesh
  56751. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56752. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56753. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56757. * @param name defines the name of the mesh
  56758. * @param options defines the options used to create the mesh
  56759. * @param scene defines the hosting scene
  56760. * @returns the torus mesh
  56761. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56762. */
  56763. static CreateTorus(name: string, options: {
  56764. diameter?: number;
  56765. thickness?: number;
  56766. tessellation?: number;
  56767. updatable?: boolean;
  56768. sideOrientation?: number;
  56769. frontUVs?: Vector4;
  56770. backUVs?: Vector4;
  56771. }, scene?: Nullable<Scene>): Mesh;
  56772. /**
  56773. * Creates a torus knot mesh
  56774. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56775. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56776. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56777. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56781. * @param name defines the name of the mesh
  56782. * @param options defines the options used to create the mesh
  56783. * @param scene defines the hosting scene
  56784. * @returns the torus knot mesh
  56785. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56786. */
  56787. static CreateTorusKnot(name: string, options: {
  56788. radius?: number;
  56789. tube?: number;
  56790. radialSegments?: number;
  56791. tubularSegments?: number;
  56792. p?: number;
  56793. q?: number;
  56794. updatable?: boolean;
  56795. sideOrientation?: number;
  56796. frontUVs?: Vector4;
  56797. backUVs?: Vector4;
  56798. }, scene?: Nullable<Scene>): Mesh;
  56799. /**
  56800. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56801. * * 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
  56802. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56803. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56804. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56805. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56806. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56807. * * 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
  56808. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56811. * @param name defines the name of the new line system
  56812. * @param options defines the options used to create the line system
  56813. * @param scene defines the hosting scene
  56814. * @returns a new line system mesh
  56815. */
  56816. static CreateLineSystem(name: string, options: {
  56817. lines: Vector3[][];
  56818. updatable?: boolean;
  56819. instance?: Nullable<LinesMesh>;
  56820. colors?: Nullable<Color4[][]>;
  56821. useVertexAlpha?: boolean;
  56822. }, scene: Nullable<Scene>): LinesMesh;
  56823. /**
  56824. * Creates a line mesh
  56825. * 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
  56826. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56827. * * The parameter `points` is an array successive Vector3
  56828. * * 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
  56829. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56830. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56831. * * When updating an instance, remember that only point positions can change, not the number of points
  56832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56834. * @param name defines the name of the new line system
  56835. * @param options defines the options used to create the line system
  56836. * @param scene defines the hosting scene
  56837. * @returns a new line mesh
  56838. */
  56839. static CreateLines(name: string, options: {
  56840. points: Vector3[];
  56841. updatable?: boolean;
  56842. instance?: Nullable<LinesMesh>;
  56843. colors?: Color4[];
  56844. useVertexAlpha?: boolean;
  56845. }, scene?: Nullable<Scene>): LinesMesh;
  56846. /**
  56847. * Creates a dashed line mesh
  56848. * * 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
  56849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56850. * * The parameter `points` is an array successive Vector3
  56851. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56852. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56853. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56854. * * 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
  56855. * * When updating an instance, remember that only point positions can change, not the number of points
  56856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56857. * @param name defines the name of the mesh
  56858. * @param options defines the options used to create the mesh
  56859. * @param scene defines the hosting scene
  56860. * @returns the dashed line mesh
  56861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56862. */
  56863. static CreateDashedLines(name: string, options: {
  56864. points: Vector3[];
  56865. dashSize?: number;
  56866. gapSize?: number;
  56867. dashNb?: number;
  56868. updatable?: boolean;
  56869. instance?: LinesMesh;
  56870. }, scene?: Nullable<Scene>): LinesMesh;
  56871. /**
  56872. * 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.
  56873. * * 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.
  56874. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56875. * * 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.
  56876. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56877. * * 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
  56878. * * 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
  56879. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56882. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56884. * @param name defines the name of the mesh
  56885. * @param options defines the options used to create the mesh
  56886. * @param scene defines the hosting scene
  56887. * @returns the extruded shape mesh
  56888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56890. */
  56891. static ExtrudeShape(name: string, options: {
  56892. shape: Vector3[];
  56893. path: Vector3[];
  56894. scale?: number;
  56895. rotation?: number;
  56896. cap?: number;
  56897. updatable?: boolean;
  56898. sideOrientation?: number;
  56899. frontUVs?: Vector4;
  56900. backUVs?: Vector4;
  56901. instance?: Mesh;
  56902. invertUV?: boolean;
  56903. }, scene?: Nullable<Scene>): Mesh;
  56904. /**
  56905. * Creates an custom extruded shape mesh.
  56906. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56907. * * 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.
  56908. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56909. * * 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
  56910. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56911. * * 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
  56912. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56913. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56914. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56915. * * 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
  56916. * * 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
  56917. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56922. * @param name defines the name of the mesh
  56923. * @param options defines the options used to create the mesh
  56924. * @param scene defines the hosting scene
  56925. * @returns the custom extruded shape mesh
  56926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56927. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56929. */
  56930. static ExtrudeShapeCustom(name: string, options: {
  56931. shape: Vector3[];
  56932. path: Vector3[];
  56933. scaleFunction?: any;
  56934. rotationFunction?: any;
  56935. ribbonCloseArray?: boolean;
  56936. ribbonClosePath?: boolean;
  56937. cap?: number;
  56938. updatable?: boolean;
  56939. sideOrientation?: number;
  56940. frontUVs?: Vector4;
  56941. backUVs?: Vector4;
  56942. instance?: Mesh;
  56943. invertUV?: boolean;
  56944. }, scene?: Nullable<Scene>): Mesh;
  56945. /**
  56946. * Creates lathe mesh.
  56947. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56948. * * 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
  56949. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56950. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56951. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56952. * * 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
  56953. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56954. * * 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
  56955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56959. * @param name defines the name of the mesh
  56960. * @param options defines the options used to create the mesh
  56961. * @param scene defines the hosting scene
  56962. * @returns the lathe mesh
  56963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56964. */
  56965. static CreateLathe(name: string, options: {
  56966. shape: Vector3[];
  56967. radius?: number;
  56968. tessellation?: number;
  56969. clip?: number;
  56970. arc?: number;
  56971. closed?: boolean;
  56972. updatable?: boolean;
  56973. sideOrientation?: number;
  56974. frontUVs?: Vector4;
  56975. backUVs?: Vector4;
  56976. cap?: number;
  56977. invertUV?: boolean;
  56978. }, scene?: Nullable<Scene>): Mesh;
  56979. /**
  56980. * Creates a tiled plane mesh
  56981. * * You can set a limited pattern arrangement with the tiles
  56982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56985. * @param name defines the name of the mesh
  56986. * @param options defines the options used to create the mesh
  56987. * @param scene defines the hosting scene
  56988. * @returns the plane mesh
  56989. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56990. */
  56991. static CreateTiledPlane(name: string, options: {
  56992. pattern?: number;
  56993. tileSize?: number;
  56994. tileWidth?: number;
  56995. tileHeight?: number;
  56996. size?: number;
  56997. width?: number;
  56998. height?: number;
  56999. alignHorizontal?: number;
  57000. alignVertical?: number;
  57001. sideOrientation?: number;
  57002. frontUVs?: Vector4;
  57003. backUVs?: Vector4;
  57004. updatable?: boolean;
  57005. }, scene?: Nullable<Scene>): Mesh;
  57006. /**
  57007. * Creates a plane mesh
  57008. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57009. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57010. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57014. * @param name defines the name of the mesh
  57015. * @param options defines the options used to create the mesh
  57016. * @param scene defines the hosting scene
  57017. * @returns the plane mesh
  57018. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57019. */
  57020. static CreatePlane(name: string, options: {
  57021. size?: number;
  57022. width?: number;
  57023. height?: number;
  57024. sideOrientation?: number;
  57025. frontUVs?: Vector4;
  57026. backUVs?: Vector4;
  57027. updatable?: boolean;
  57028. sourcePlane?: Plane;
  57029. }, scene?: Nullable<Scene>): Mesh;
  57030. /**
  57031. * Creates a ground mesh
  57032. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57033. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57035. * @param name defines the name of the mesh
  57036. * @param options defines the options used to create the mesh
  57037. * @param scene defines the hosting scene
  57038. * @returns the ground mesh
  57039. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57040. */
  57041. static CreateGround(name: string, options: {
  57042. width?: number;
  57043. height?: number;
  57044. subdivisions?: number;
  57045. subdivisionsX?: number;
  57046. subdivisionsY?: number;
  57047. updatable?: boolean;
  57048. }, scene?: Nullable<Scene>): Mesh;
  57049. /**
  57050. * Creates a tiled ground mesh
  57051. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57052. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57053. * * 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
  57054. * * 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
  57055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57056. * @param name defines the name of the mesh
  57057. * @param options defines the options used to create the mesh
  57058. * @param scene defines the hosting scene
  57059. * @returns the tiled ground mesh
  57060. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57061. */
  57062. static CreateTiledGround(name: string, options: {
  57063. xmin: number;
  57064. zmin: number;
  57065. xmax: number;
  57066. zmax: number;
  57067. subdivisions?: {
  57068. w: number;
  57069. h: number;
  57070. };
  57071. precision?: {
  57072. w: number;
  57073. h: number;
  57074. };
  57075. updatable?: boolean;
  57076. }, scene?: Nullable<Scene>): Mesh;
  57077. /**
  57078. * Creates a ground mesh from a height map
  57079. * * The parameter `url` sets the URL of the height map image resource.
  57080. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57081. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57082. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57083. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57084. * * 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.
  57085. * * 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).
  57086. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57088. * @param name defines the name of the mesh
  57089. * @param url defines the url to the height map
  57090. * @param options defines the options used to create the mesh
  57091. * @param scene defines the hosting scene
  57092. * @returns the ground mesh
  57093. * @see https://doc.babylonjs.com/babylon101/height_map
  57094. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57095. */
  57096. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57097. width?: number;
  57098. height?: number;
  57099. subdivisions?: number;
  57100. minHeight?: number;
  57101. maxHeight?: number;
  57102. colorFilter?: Color3;
  57103. alphaFilter?: number;
  57104. updatable?: boolean;
  57105. onReady?: (mesh: GroundMesh) => void;
  57106. }, scene?: Nullable<Scene>): GroundMesh;
  57107. /**
  57108. * Creates a polygon mesh
  57109. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57110. * * 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
  57111. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57114. * * Remember you can only change the shape positions, not their number when updating a polygon
  57115. * @param name defines the name of the mesh
  57116. * @param options defines the options used to create the mesh
  57117. * @param scene defines the hosting scene
  57118. * @param earcutInjection can be used to inject your own earcut reference
  57119. * @returns the polygon mesh
  57120. */
  57121. static CreatePolygon(name: string, options: {
  57122. shape: Vector3[];
  57123. holes?: Vector3[][];
  57124. depth?: number;
  57125. faceUV?: Vector4[];
  57126. faceColors?: Color4[];
  57127. updatable?: boolean;
  57128. sideOrientation?: number;
  57129. frontUVs?: Vector4;
  57130. backUVs?: Vector4;
  57131. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57132. /**
  57133. * Creates an extruded polygon mesh, with depth in the Y direction.
  57134. * * 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)
  57135. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57136. * @param name defines the name of the mesh
  57137. * @param options defines the options used to create the mesh
  57138. * @param scene defines the hosting scene
  57139. * @param earcutInjection can be used to inject your own earcut reference
  57140. * @returns the polygon mesh
  57141. */
  57142. static ExtrudePolygon(name: string, options: {
  57143. shape: Vector3[];
  57144. holes?: Vector3[][];
  57145. depth?: number;
  57146. faceUV?: Vector4[];
  57147. faceColors?: Color4[];
  57148. updatable?: boolean;
  57149. sideOrientation?: number;
  57150. frontUVs?: Vector4;
  57151. backUVs?: Vector4;
  57152. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57153. /**
  57154. * Creates a tube mesh.
  57155. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57156. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57157. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57158. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57159. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57160. * * 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)
  57161. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57162. * * 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
  57163. * * 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
  57164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57168. * @param name defines the name of the mesh
  57169. * @param options defines the options used to create the mesh
  57170. * @param scene defines the hosting scene
  57171. * @returns the tube mesh
  57172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57173. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57174. */
  57175. static CreateTube(name: string, options: {
  57176. path: Vector3[];
  57177. radius?: number;
  57178. tessellation?: number;
  57179. radiusFunction?: {
  57180. (i: number, distance: number): number;
  57181. };
  57182. cap?: number;
  57183. arc?: number;
  57184. updatable?: boolean;
  57185. sideOrientation?: number;
  57186. frontUVs?: Vector4;
  57187. backUVs?: Vector4;
  57188. instance?: Mesh;
  57189. invertUV?: boolean;
  57190. }, scene?: Nullable<Scene>): Mesh;
  57191. /**
  57192. * Creates a polyhedron mesh
  57193. * * 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
  57194. * * The parameter `size` (positive float, default 1) sets the polygon size
  57195. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57196. * * 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`
  57197. * * 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
  57198. * * 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)`)
  57199. * * 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
  57200. * * 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
  57201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57204. * @param name defines the name of the mesh
  57205. * @param options defines the options used to create the mesh
  57206. * @param scene defines the hosting scene
  57207. * @returns the polyhedron mesh
  57208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57209. */
  57210. static CreatePolyhedron(name: string, options: {
  57211. type?: number;
  57212. size?: number;
  57213. sizeX?: number;
  57214. sizeY?: number;
  57215. sizeZ?: number;
  57216. custom?: any;
  57217. faceUV?: Vector4[];
  57218. faceColors?: Color4[];
  57219. flat?: boolean;
  57220. updatable?: boolean;
  57221. sideOrientation?: number;
  57222. frontUVs?: Vector4;
  57223. backUVs?: Vector4;
  57224. }, scene?: Nullable<Scene>): Mesh;
  57225. /**
  57226. * Creates a decal mesh.
  57227. * 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
  57228. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57229. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57230. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57231. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57232. * @param name defines the name of the mesh
  57233. * @param sourceMesh defines the mesh where the decal must be applied
  57234. * @param options defines the options used to create the mesh
  57235. * @param scene defines the hosting scene
  57236. * @returns the decal mesh
  57237. * @see https://doc.babylonjs.com/how_to/decals
  57238. */
  57239. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57240. position?: Vector3;
  57241. normal?: Vector3;
  57242. size?: Vector3;
  57243. angle?: number;
  57244. }): Mesh;
  57245. }
  57246. }
  57247. declare module "babylonjs/Meshes/meshSimplification" {
  57248. import { Mesh } from "babylonjs/Meshes/mesh";
  57249. /**
  57250. * A simplifier interface for future simplification implementations
  57251. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57252. */
  57253. export interface ISimplifier {
  57254. /**
  57255. * Simplification of a given mesh according to the given settings.
  57256. * Since this requires computation, it is assumed that the function runs async.
  57257. * @param settings The settings of the simplification, including quality and distance
  57258. * @param successCallback A callback that will be called after the mesh was simplified.
  57259. * @param errorCallback in case of an error, this callback will be called. optional.
  57260. */
  57261. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57262. }
  57263. /**
  57264. * Expected simplification settings.
  57265. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57266. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57267. */
  57268. export interface ISimplificationSettings {
  57269. /**
  57270. * Gets or sets the expected quality
  57271. */
  57272. quality: number;
  57273. /**
  57274. * Gets or sets the distance when this optimized version should be used
  57275. */
  57276. distance: number;
  57277. /**
  57278. * Gets an already optimized mesh
  57279. */
  57280. optimizeMesh?: boolean;
  57281. }
  57282. /**
  57283. * Class used to specify simplification options
  57284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57285. */
  57286. export class SimplificationSettings implements ISimplificationSettings {
  57287. /** expected quality */
  57288. quality: number;
  57289. /** distance when this optimized version should be used */
  57290. distance: number;
  57291. /** already optimized mesh */
  57292. optimizeMesh?: boolean | undefined;
  57293. /**
  57294. * Creates a SimplificationSettings
  57295. * @param quality expected quality
  57296. * @param distance distance when this optimized version should be used
  57297. * @param optimizeMesh already optimized mesh
  57298. */
  57299. constructor(
  57300. /** expected quality */
  57301. quality: number,
  57302. /** distance when this optimized version should be used */
  57303. distance: number,
  57304. /** already optimized mesh */
  57305. optimizeMesh?: boolean | undefined);
  57306. }
  57307. /**
  57308. * Interface used to define a simplification task
  57309. */
  57310. export interface ISimplificationTask {
  57311. /**
  57312. * Array of settings
  57313. */
  57314. settings: Array<ISimplificationSettings>;
  57315. /**
  57316. * Simplification type
  57317. */
  57318. simplificationType: SimplificationType;
  57319. /**
  57320. * Mesh to simplify
  57321. */
  57322. mesh: Mesh;
  57323. /**
  57324. * Callback called on success
  57325. */
  57326. successCallback?: () => void;
  57327. /**
  57328. * Defines if parallel processing can be used
  57329. */
  57330. parallelProcessing: boolean;
  57331. }
  57332. /**
  57333. * Queue used to order the simplification tasks
  57334. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57335. */
  57336. export class SimplificationQueue {
  57337. private _simplificationArray;
  57338. /**
  57339. * Gets a boolean indicating that the process is still running
  57340. */
  57341. running: boolean;
  57342. /**
  57343. * Creates a new queue
  57344. */
  57345. constructor();
  57346. /**
  57347. * Adds a new simplification task
  57348. * @param task defines a task to add
  57349. */
  57350. addTask(task: ISimplificationTask): void;
  57351. /**
  57352. * Execute next task
  57353. */
  57354. executeNext(): void;
  57355. /**
  57356. * Execute a simplification task
  57357. * @param task defines the task to run
  57358. */
  57359. runSimplification(task: ISimplificationTask): void;
  57360. private getSimplifier;
  57361. }
  57362. /**
  57363. * The implemented types of simplification
  57364. * At the moment only Quadratic Error Decimation is implemented
  57365. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57366. */
  57367. export enum SimplificationType {
  57368. /** Quadratic error decimation */
  57369. QUADRATIC = 0
  57370. }
  57371. }
  57372. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57373. import { Scene } from "babylonjs/scene";
  57374. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57375. import { ISceneComponent } from "babylonjs/sceneComponent";
  57376. module "babylonjs/scene" {
  57377. interface Scene {
  57378. /** @hidden (Backing field) */
  57379. _simplificationQueue: SimplificationQueue;
  57380. /**
  57381. * Gets or sets the simplification queue attached to the scene
  57382. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57383. */
  57384. simplificationQueue: SimplificationQueue;
  57385. }
  57386. }
  57387. module "babylonjs/Meshes/mesh" {
  57388. interface Mesh {
  57389. /**
  57390. * Simplify the mesh according to the given array of settings.
  57391. * Function will return immediately and will simplify async
  57392. * @param settings a collection of simplification settings
  57393. * @param parallelProcessing should all levels calculate parallel or one after the other
  57394. * @param simplificationType the type of simplification to run
  57395. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57396. * @returns the current mesh
  57397. */
  57398. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57399. }
  57400. }
  57401. /**
  57402. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57403. * created in a scene
  57404. */
  57405. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57406. /**
  57407. * The component name helpfull to identify the component in the list of scene components.
  57408. */
  57409. readonly name: string;
  57410. /**
  57411. * The scene the component belongs to.
  57412. */
  57413. scene: Scene;
  57414. /**
  57415. * Creates a new instance of the component for the given scene
  57416. * @param scene Defines the scene to register the component in
  57417. */
  57418. constructor(scene: Scene);
  57419. /**
  57420. * Registers the component in a given scene
  57421. */
  57422. register(): void;
  57423. /**
  57424. * Rebuilds the elements related to this component in case of
  57425. * context lost for instance.
  57426. */
  57427. rebuild(): void;
  57428. /**
  57429. * Disposes the component and the associated ressources
  57430. */
  57431. dispose(): void;
  57432. private _beforeCameraUpdate;
  57433. }
  57434. }
  57435. declare module "babylonjs/Meshes/Builders/index" {
  57436. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57437. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57438. export * from "babylonjs/Meshes/Builders/discBuilder";
  57439. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57440. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57441. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57442. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57443. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57444. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57445. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57446. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57447. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57448. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57449. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57450. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57451. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57452. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57453. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57454. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57455. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57456. }
  57457. declare module "babylonjs/Meshes/index" {
  57458. export * from "babylonjs/Meshes/abstractMesh";
  57459. export * from "babylonjs/Meshes/buffer";
  57460. export * from "babylonjs/Meshes/Compression/index";
  57461. export * from "babylonjs/Meshes/csg";
  57462. export * from "babylonjs/Meshes/geometry";
  57463. export * from "babylonjs/Meshes/groundMesh";
  57464. export * from "babylonjs/Meshes/trailMesh";
  57465. export * from "babylonjs/Meshes/instancedMesh";
  57466. export * from "babylonjs/Meshes/linesMesh";
  57467. export * from "babylonjs/Meshes/mesh";
  57468. export * from "babylonjs/Meshes/mesh.vertexData";
  57469. export * from "babylonjs/Meshes/meshBuilder";
  57470. export * from "babylonjs/Meshes/meshSimplification";
  57471. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57472. export * from "babylonjs/Meshes/polygonMesh";
  57473. export * from "babylonjs/Meshes/subMesh";
  57474. export * from "babylonjs/Meshes/meshLODLevel";
  57475. export * from "babylonjs/Meshes/transformNode";
  57476. export * from "babylonjs/Meshes/Builders/index";
  57477. export * from "babylonjs/Meshes/dataBuffer";
  57478. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57479. }
  57480. declare module "babylonjs/Morph/index" {
  57481. export * from "babylonjs/Morph/morphTarget";
  57482. export * from "babylonjs/Morph/morphTargetManager";
  57483. }
  57484. declare module "babylonjs/Navigation/INavigationEngine" {
  57485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57486. import { Vector3 } from "babylonjs/Maths/math";
  57487. import { Mesh } from "babylonjs/Meshes/mesh";
  57488. import { Scene } from "babylonjs/scene";
  57489. /**
  57490. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57491. */
  57492. export interface INavigationEnginePlugin {
  57493. /**
  57494. * plugin name
  57495. */
  57496. name: string;
  57497. /**
  57498. * Creates a navigation mesh
  57499. * @param meshes array of all the geometry used to compute the navigatio mesh
  57500. * @param parameters bunch of parameters used to filter geometry
  57501. */
  57502. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57503. /**
  57504. * Create a navigation mesh debug mesh
  57505. * @param scene is where the mesh will be added
  57506. * @returns debug display mesh
  57507. */
  57508. createDebugNavMesh(scene: Scene): Mesh;
  57509. /**
  57510. * Get a navigation mesh constrained position, closest to the parameter position
  57511. * @param position world position
  57512. * @returns the closest point to position constrained by the navigation mesh
  57513. */
  57514. getClosestPoint(position: Vector3): Vector3;
  57515. /**
  57516. * Get a navigation mesh constrained position, within a particular radius
  57517. * @param position world position
  57518. * @param maxRadius the maximum distance to the constrained world position
  57519. * @returns the closest point to position constrained by the navigation mesh
  57520. */
  57521. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57522. /**
  57523. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57524. * @param start world position
  57525. * @param end world position
  57526. * @returns array containing world position composing the path
  57527. */
  57528. computePath(start: Vector3, end: Vector3): Vector3[];
  57529. /**
  57530. * If this plugin is supported
  57531. * @returns true if plugin is supported
  57532. */
  57533. isSupported(): boolean;
  57534. /**
  57535. * Create a new Crowd so you can add agents
  57536. * @param maxAgents the maximum agent count in the crowd
  57537. * @param maxAgentRadius the maximum radius an agent can have
  57538. * @param scene to attach the crowd to
  57539. * @returns the crowd you can add agents to
  57540. */
  57541. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57542. /**
  57543. * Release all resources
  57544. */
  57545. dispose(): void;
  57546. }
  57547. /**
  57548. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57549. */
  57550. export interface ICrowd {
  57551. /**
  57552. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57553. * You can attach anything to that node. The node position is updated in the scene update tick.
  57554. * @param pos world position that will be constrained by the navigation mesh
  57555. * @param parameters agent parameters
  57556. * @param transform hooked to the agent that will be update by the scene
  57557. * @returns agent index
  57558. */
  57559. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57560. /**
  57561. * Returns the agent position in world space
  57562. * @param index agent index returned by addAgent
  57563. * @returns world space position
  57564. */
  57565. getAgentPosition(index: number): Vector3;
  57566. /**
  57567. * Gets the agent velocity in world space
  57568. * @param index agent index returned by addAgent
  57569. * @returns world space velocity
  57570. */
  57571. getAgentVelocity(index: number): Vector3;
  57572. /**
  57573. * remove a particular agent previously created
  57574. * @param index agent index returned by addAgent
  57575. */
  57576. removeAgent(index: number): void;
  57577. /**
  57578. * get the list of all agents attached to this crowd
  57579. * @returns list of agent indices
  57580. */
  57581. getAgents(): number[];
  57582. /**
  57583. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57584. * @param deltaTime in seconds
  57585. */
  57586. update(deltaTime: number): void;
  57587. /**
  57588. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57589. * @param index agent index returned by addAgent
  57590. * @param destination targeted world position
  57591. */
  57592. agentGoto(index: number, destination: Vector3): void;
  57593. /**
  57594. * Release all resources
  57595. */
  57596. dispose(): void;
  57597. }
  57598. /**
  57599. * Configures an agent
  57600. */
  57601. export interface IAgentParameters {
  57602. /**
  57603. * Agent radius. [Limit: >= 0]
  57604. */
  57605. radius: number;
  57606. /**
  57607. * Agent height. [Limit: > 0]
  57608. */
  57609. height: number;
  57610. /**
  57611. * Maximum allowed acceleration. [Limit: >= 0]
  57612. */
  57613. maxAcceleration: number;
  57614. /**
  57615. * Maximum allowed speed. [Limit: >= 0]
  57616. */
  57617. maxSpeed: number;
  57618. /**
  57619. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57620. */
  57621. collisionQueryRange: number;
  57622. /**
  57623. * The path visibility optimization range. [Limit: > 0]
  57624. */
  57625. pathOptimizationRange: number;
  57626. /**
  57627. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57628. */
  57629. separationWeight: number;
  57630. }
  57631. /**
  57632. * Configures the navigation mesh creation
  57633. */
  57634. export interface INavMeshParameters {
  57635. /**
  57636. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57637. */
  57638. cs: number;
  57639. /**
  57640. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57641. */
  57642. ch: number;
  57643. /**
  57644. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57645. */
  57646. walkableSlopeAngle: number;
  57647. /**
  57648. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57649. * be considered walkable. [Limit: >= 3] [Units: vx]
  57650. */
  57651. walkableHeight: number;
  57652. /**
  57653. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57654. */
  57655. walkableClimb: number;
  57656. /**
  57657. * The distance to erode/shrink the walkable area of the heightfield away from
  57658. * obstructions. [Limit: >=0] [Units: vx]
  57659. */
  57660. walkableRadius: number;
  57661. /**
  57662. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57663. */
  57664. maxEdgeLen: number;
  57665. /**
  57666. * The maximum distance a simplfied contour's border edges should deviate
  57667. * the original raw contour. [Limit: >=0] [Units: vx]
  57668. */
  57669. maxSimplificationError: number;
  57670. /**
  57671. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57672. */
  57673. minRegionArea: number;
  57674. /**
  57675. * Any regions with a span count smaller than this value will, if possible,
  57676. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57677. */
  57678. mergeRegionArea: number;
  57679. /**
  57680. * The maximum number of vertices allowed for polygons generated during the
  57681. * contour to polygon conversion process. [Limit: >= 3]
  57682. */
  57683. maxVertsPerPoly: number;
  57684. /**
  57685. * Sets the sampling distance to use when generating the detail mesh.
  57686. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57687. */
  57688. detailSampleDist: number;
  57689. /**
  57690. * The maximum distance the detail mesh surface should deviate from heightfield
  57691. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57692. */
  57693. detailSampleMaxError: number;
  57694. }
  57695. }
  57696. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57697. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57698. import { Mesh } from "babylonjs/Meshes/mesh";
  57699. import { Scene } from "babylonjs/scene";
  57700. import { Vector3 } from "babylonjs/Maths/math";
  57701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57702. /**
  57703. * RecastJS navigation plugin
  57704. */
  57705. export class RecastJSPlugin implements INavigationEnginePlugin {
  57706. /**
  57707. * Reference to the Recast library
  57708. */
  57709. bjsRECAST: any;
  57710. /**
  57711. * plugin name
  57712. */
  57713. name: string;
  57714. /**
  57715. * the first navmesh created. We might extend this to support multiple navmeshes
  57716. */
  57717. navMesh: any;
  57718. /**
  57719. * Initializes the recastJS plugin
  57720. * @param recastInjection can be used to inject your own recast reference
  57721. */
  57722. constructor(recastInjection?: any);
  57723. /**
  57724. * Creates a navigation mesh
  57725. * @param meshes array of all the geometry used to compute the navigatio mesh
  57726. * @param parameters bunch of parameters used to filter geometry
  57727. */
  57728. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57729. /**
  57730. * Create a navigation mesh debug mesh
  57731. * @param scene is where the mesh will be added
  57732. * @returns debug display mesh
  57733. */
  57734. createDebugNavMesh(scene: Scene): Mesh;
  57735. /**
  57736. * Get a navigation mesh constrained position, closest to the parameter position
  57737. * @param position world position
  57738. * @returns the closest point to position constrained by the navigation mesh
  57739. */
  57740. getClosestPoint(position: Vector3): Vector3;
  57741. /**
  57742. * Get a navigation mesh constrained position, within a particular radius
  57743. * @param position world position
  57744. * @param maxRadius the maximum distance to the constrained world position
  57745. * @returns the closest point to position constrained by the navigation mesh
  57746. */
  57747. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57748. /**
  57749. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57750. * @param start world position
  57751. * @param end world position
  57752. * @returns array containing world position composing the path
  57753. */
  57754. computePath(start: Vector3, end: Vector3): Vector3[];
  57755. /**
  57756. * Create a new Crowd so you can add agents
  57757. * @param maxAgents the maximum agent count in the crowd
  57758. * @param maxAgentRadius the maximum radius an agent can have
  57759. * @param scene to attach the crowd to
  57760. * @returns the crowd you can add agents to
  57761. */
  57762. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57763. /**
  57764. * Disposes
  57765. */
  57766. dispose(): void;
  57767. /**
  57768. * If this plugin is supported
  57769. * @returns true if plugin is supported
  57770. */
  57771. isSupported(): boolean;
  57772. }
  57773. /**
  57774. * Recast detour crowd implementation
  57775. */
  57776. export class RecastJSCrowd implements ICrowd {
  57777. /**
  57778. * Recast/detour plugin
  57779. */
  57780. bjsRECASTPlugin: RecastJSPlugin;
  57781. /**
  57782. * Link to the detour crowd
  57783. */
  57784. recastCrowd: any;
  57785. /**
  57786. * One transform per agent
  57787. */
  57788. transforms: TransformNode[];
  57789. /**
  57790. * All agents created
  57791. */
  57792. agents: number[];
  57793. /**
  57794. * Link to the scene is kept to unregister the crowd from the scene
  57795. */
  57796. private _scene;
  57797. /**
  57798. * Observer for crowd updates
  57799. */
  57800. private _onBeforeAnimationsObserver;
  57801. /**
  57802. * Constructor
  57803. * @param plugin recastJS plugin
  57804. * @param maxAgents the maximum agent count in the crowd
  57805. * @param maxAgentRadius the maximum radius an agent can have
  57806. * @param scene to attach the crowd to
  57807. * @returns the crowd you can add agents to
  57808. */
  57809. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57810. /**
  57811. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57812. * You can attach anything to that node. The node position is updated in the scene update tick.
  57813. * @param pos world position that will be constrained by the navigation mesh
  57814. * @param parameters agent parameters
  57815. * @param transform hooked to the agent that will be update by the scene
  57816. * @returns agent index
  57817. */
  57818. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57819. /**
  57820. * Returns the agent position in world space
  57821. * @param index agent index returned by addAgent
  57822. * @returns world space position
  57823. */
  57824. getAgentPosition(index: number): Vector3;
  57825. /**
  57826. * Returns the agent velocity in world space
  57827. * @param index agent index returned by addAgent
  57828. * @returns world space velocity
  57829. */
  57830. getAgentVelocity(index: number): Vector3;
  57831. /**
  57832. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57833. * @param index agent index returned by addAgent
  57834. * @param destination targeted world position
  57835. */
  57836. agentGoto(index: number, destination: Vector3): void;
  57837. /**
  57838. * remove a particular agent previously created
  57839. * @param index agent index returned by addAgent
  57840. */
  57841. removeAgent(index: number): void;
  57842. /**
  57843. * get the list of all agents attached to this crowd
  57844. * @returns list of agent indices
  57845. */
  57846. getAgents(): number[];
  57847. /**
  57848. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57849. * @param deltaTime in seconds
  57850. */
  57851. update(deltaTime: number): void;
  57852. /**
  57853. * Release all resources
  57854. */
  57855. dispose(): void;
  57856. }
  57857. }
  57858. declare module "babylonjs/Navigation/Plugins/index" {
  57859. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  57860. }
  57861. declare module "babylonjs/Navigation/index" {
  57862. export * from "babylonjs/Navigation/INavigationEngine";
  57863. export * from "babylonjs/Navigation/Plugins/index";
  57864. }
  57865. declare module "babylonjs/Offline/database" {
  57866. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57867. /**
  57868. * Class used to enable access to IndexedDB
  57869. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57870. */
  57871. export class Database implements IOfflineProvider {
  57872. private _callbackManifestChecked;
  57873. private _currentSceneUrl;
  57874. private _db;
  57875. private _enableSceneOffline;
  57876. private _enableTexturesOffline;
  57877. private _manifestVersionFound;
  57878. private _mustUpdateRessources;
  57879. private _hasReachedQuota;
  57880. private _isSupported;
  57881. private _idbFactory;
  57882. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57883. private static IsUASupportingBlobStorage;
  57884. /**
  57885. * Gets a boolean indicating if Database storate is enabled (off by default)
  57886. */
  57887. static IDBStorageEnabled: boolean;
  57888. /**
  57889. * Gets a boolean indicating if scene must be saved in the database
  57890. */
  57891. readonly enableSceneOffline: boolean;
  57892. /**
  57893. * Gets a boolean indicating if textures must be saved in the database
  57894. */
  57895. readonly enableTexturesOffline: boolean;
  57896. /**
  57897. * Creates a new Database
  57898. * @param urlToScene defines the url to load the scene
  57899. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57900. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57901. */
  57902. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57903. private static _ParseURL;
  57904. private static _ReturnFullUrlLocation;
  57905. private _checkManifestFile;
  57906. /**
  57907. * Open the database and make it available
  57908. * @param successCallback defines the callback to call on success
  57909. * @param errorCallback defines the callback to call on error
  57910. */
  57911. open(successCallback: () => void, errorCallback: () => void): void;
  57912. /**
  57913. * Loads an image from the database
  57914. * @param url defines the url to load from
  57915. * @param image defines the target DOM image
  57916. */
  57917. loadImage(url: string, image: HTMLImageElement): void;
  57918. private _loadImageFromDBAsync;
  57919. private _saveImageIntoDBAsync;
  57920. private _checkVersionFromDB;
  57921. private _loadVersionFromDBAsync;
  57922. private _saveVersionIntoDBAsync;
  57923. /**
  57924. * Loads a file from database
  57925. * @param url defines the URL to load from
  57926. * @param sceneLoaded defines a callback to call on success
  57927. * @param progressCallBack defines a callback to call when progress changed
  57928. * @param errorCallback defines a callback to call on error
  57929. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57930. */
  57931. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57932. private _loadFileAsync;
  57933. private _saveFileAsync;
  57934. /**
  57935. * Validates if xhr data is correct
  57936. * @param xhr defines the request to validate
  57937. * @param dataType defines the expected data type
  57938. * @returns true if data is correct
  57939. */
  57940. private static _ValidateXHRData;
  57941. }
  57942. }
  57943. declare module "babylonjs/Offline/index" {
  57944. export * from "babylonjs/Offline/database";
  57945. export * from "babylonjs/Offline/IOfflineProvider";
  57946. }
  57947. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57948. /** @hidden */
  57949. export var gpuUpdateParticlesPixelShader: {
  57950. name: string;
  57951. shader: string;
  57952. };
  57953. }
  57954. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57955. /** @hidden */
  57956. export var gpuUpdateParticlesVertexShader: {
  57957. name: string;
  57958. shader: string;
  57959. };
  57960. }
  57961. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57962. /** @hidden */
  57963. export var clipPlaneFragmentDeclaration2: {
  57964. name: string;
  57965. shader: string;
  57966. };
  57967. }
  57968. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57969. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57970. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57972. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57973. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57974. /** @hidden */
  57975. export var gpuRenderParticlesPixelShader: {
  57976. name: string;
  57977. shader: string;
  57978. };
  57979. }
  57980. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57981. /** @hidden */
  57982. export var clipPlaneVertexDeclaration2: {
  57983. name: string;
  57984. shader: string;
  57985. };
  57986. }
  57987. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57988. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57989. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57990. /** @hidden */
  57991. export var gpuRenderParticlesVertexShader: {
  57992. name: string;
  57993. shader: string;
  57994. };
  57995. }
  57996. declare module "babylonjs/Particles/gpuParticleSystem" {
  57997. import { Nullable } from "babylonjs/types";
  57998. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57999. import { Observable } from "babylonjs/Misc/observable";
  58000. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58001. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58002. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58003. import { Scene, IDisposable } from "babylonjs/scene";
  58004. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58006. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58007. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58008. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58009. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58010. /**
  58011. * This represents a GPU particle system in Babylon
  58012. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58013. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58014. */
  58015. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58016. /**
  58017. * The layer mask we are rendering the particles through.
  58018. */
  58019. layerMask: number;
  58020. private _capacity;
  58021. private _activeCount;
  58022. private _currentActiveCount;
  58023. private _accumulatedCount;
  58024. private _renderEffect;
  58025. private _updateEffect;
  58026. private _buffer0;
  58027. private _buffer1;
  58028. private _spriteBuffer;
  58029. private _updateVAO;
  58030. private _renderVAO;
  58031. private _targetIndex;
  58032. private _sourceBuffer;
  58033. private _targetBuffer;
  58034. private _engine;
  58035. private _currentRenderId;
  58036. private _started;
  58037. private _stopped;
  58038. private _timeDelta;
  58039. private _randomTexture;
  58040. private _randomTexture2;
  58041. private _attributesStrideSize;
  58042. private _updateEffectOptions;
  58043. private _randomTextureSize;
  58044. private _actualFrame;
  58045. private readonly _rawTextureWidth;
  58046. /**
  58047. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58048. */
  58049. static readonly IsSupported: boolean;
  58050. /**
  58051. * An event triggered when the system is disposed.
  58052. */
  58053. onDisposeObservable: Observable<GPUParticleSystem>;
  58054. /**
  58055. * Gets the maximum number of particles active at the same time.
  58056. * @returns The max number of active particles.
  58057. */
  58058. getCapacity(): number;
  58059. /**
  58060. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58061. * to override the particles.
  58062. */
  58063. forceDepthWrite: boolean;
  58064. /**
  58065. * Gets or set the number of active particles
  58066. */
  58067. activeParticleCount: number;
  58068. private _preWarmDone;
  58069. /**
  58070. * Is this system ready to be used/rendered
  58071. * @return true if the system is ready
  58072. */
  58073. isReady(): boolean;
  58074. /**
  58075. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58076. * @returns True if it has been started, otherwise false.
  58077. */
  58078. isStarted(): boolean;
  58079. /**
  58080. * Starts the particle system and begins to emit
  58081. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58082. */
  58083. start(delay?: number): void;
  58084. /**
  58085. * Stops the particle system.
  58086. */
  58087. stop(): void;
  58088. /**
  58089. * Remove all active particles
  58090. */
  58091. reset(): void;
  58092. /**
  58093. * Returns the string "GPUParticleSystem"
  58094. * @returns a string containing the class name
  58095. */
  58096. getClassName(): string;
  58097. private _colorGradientsTexture;
  58098. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58099. /**
  58100. * Adds a new color gradient
  58101. * @param gradient defines the gradient to use (between 0 and 1)
  58102. * @param color1 defines the color to affect to the specified gradient
  58103. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58104. * @returns the current particle system
  58105. */
  58106. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58107. /**
  58108. * Remove a specific color gradient
  58109. * @param gradient defines the gradient to remove
  58110. * @returns the current particle system
  58111. */
  58112. removeColorGradient(gradient: number): GPUParticleSystem;
  58113. private _angularSpeedGradientsTexture;
  58114. private _sizeGradientsTexture;
  58115. private _velocityGradientsTexture;
  58116. private _limitVelocityGradientsTexture;
  58117. private _dragGradientsTexture;
  58118. private _addFactorGradient;
  58119. /**
  58120. * Adds a new size gradient
  58121. * @param gradient defines the gradient to use (between 0 and 1)
  58122. * @param factor defines the size factor to affect to the specified gradient
  58123. * @returns the current particle system
  58124. */
  58125. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58126. /**
  58127. * Remove a specific size gradient
  58128. * @param gradient defines the gradient to remove
  58129. * @returns the current particle system
  58130. */
  58131. removeSizeGradient(gradient: number): GPUParticleSystem;
  58132. /**
  58133. * Adds a new angular speed gradient
  58134. * @param gradient defines the gradient to use (between 0 and 1)
  58135. * @param factor defines the angular speed to affect to the specified gradient
  58136. * @returns the current particle system
  58137. */
  58138. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58139. /**
  58140. * Remove a specific angular speed gradient
  58141. * @param gradient defines the gradient to remove
  58142. * @returns the current particle system
  58143. */
  58144. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58145. /**
  58146. * Adds a new velocity gradient
  58147. * @param gradient defines the gradient to use (between 0 and 1)
  58148. * @param factor defines the velocity to affect to the specified gradient
  58149. * @returns the current particle system
  58150. */
  58151. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58152. /**
  58153. * Remove a specific velocity gradient
  58154. * @param gradient defines the gradient to remove
  58155. * @returns the current particle system
  58156. */
  58157. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58158. /**
  58159. * Adds a new limit velocity gradient
  58160. * @param gradient defines the gradient to use (between 0 and 1)
  58161. * @param factor defines the limit velocity value to affect to the specified gradient
  58162. * @returns the current particle system
  58163. */
  58164. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58165. /**
  58166. * Remove a specific limit velocity gradient
  58167. * @param gradient defines the gradient to remove
  58168. * @returns the current particle system
  58169. */
  58170. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58171. /**
  58172. * Adds a new drag gradient
  58173. * @param gradient defines the gradient to use (between 0 and 1)
  58174. * @param factor defines the drag value to affect to the specified gradient
  58175. * @returns the current particle system
  58176. */
  58177. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58178. /**
  58179. * Remove a specific drag gradient
  58180. * @param gradient defines the gradient to remove
  58181. * @returns the current particle system
  58182. */
  58183. removeDragGradient(gradient: number): GPUParticleSystem;
  58184. /**
  58185. * Not supported by GPUParticleSystem
  58186. * @param gradient defines the gradient to use (between 0 and 1)
  58187. * @param factor defines the emit rate value to affect to the specified gradient
  58188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58189. * @returns the current particle system
  58190. */
  58191. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58192. /**
  58193. * Not supported by GPUParticleSystem
  58194. * @param gradient defines the gradient to remove
  58195. * @returns the current particle system
  58196. */
  58197. removeEmitRateGradient(gradient: number): IParticleSystem;
  58198. /**
  58199. * Not supported by GPUParticleSystem
  58200. * @param gradient defines the gradient to use (between 0 and 1)
  58201. * @param factor defines the start size value to affect to the specified gradient
  58202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58203. * @returns the current particle system
  58204. */
  58205. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58206. /**
  58207. * Not supported by GPUParticleSystem
  58208. * @param gradient defines the gradient to remove
  58209. * @returns the current particle system
  58210. */
  58211. removeStartSizeGradient(gradient: number): IParticleSystem;
  58212. /**
  58213. * Not supported by GPUParticleSystem
  58214. * @param gradient defines the gradient to use (between 0 and 1)
  58215. * @param min defines the color remap minimal range
  58216. * @param max defines the color remap maximal range
  58217. * @returns the current particle system
  58218. */
  58219. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58220. /**
  58221. * Not supported by GPUParticleSystem
  58222. * @param gradient defines the gradient to remove
  58223. * @returns the current particle system
  58224. */
  58225. removeColorRemapGradient(): IParticleSystem;
  58226. /**
  58227. * Not supported by GPUParticleSystem
  58228. * @param gradient defines the gradient to use (between 0 and 1)
  58229. * @param min defines the alpha remap minimal range
  58230. * @param max defines the alpha remap maximal range
  58231. * @returns the current particle system
  58232. */
  58233. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58234. /**
  58235. * Not supported by GPUParticleSystem
  58236. * @param gradient defines the gradient to remove
  58237. * @returns the current particle system
  58238. */
  58239. removeAlphaRemapGradient(): IParticleSystem;
  58240. /**
  58241. * Not supported by GPUParticleSystem
  58242. * @param gradient defines the gradient to use (between 0 and 1)
  58243. * @param color defines the color to affect to the specified gradient
  58244. * @returns the current particle system
  58245. */
  58246. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58247. /**
  58248. * Not supported by GPUParticleSystem
  58249. * @param gradient defines the gradient to remove
  58250. * @returns the current particle system
  58251. */
  58252. removeRampGradient(): IParticleSystem;
  58253. /**
  58254. * Not supported by GPUParticleSystem
  58255. * @returns the list of ramp gradients
  58256. */
  58257. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58258. /**
  58259. * Not supported by GPUParticleSystem
  58260. * Gets or sets a boolean indicating that ramp gradients must be used
  58261. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58262. */
  58263. useRampGradients: boolean;
  58264. /**
  58265. * Not supported by GPUParticleSystem
  58266. * @param gradient defines the gradient to use (between 0 and 1)
  58267. * @param factor defines the life time factor to affect to the specified gradient
  58268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58269. * @returns the current particle system
  58270. */
  58271. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58272. /**
  58273. * Not supported by GPUParticleSystem
  58274. * @param gradient defines the gradient to remove
  58275. * @returns the current particle system
  58276. */
  58277. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58278. /**
  58279. * Instantiates a GPU particle system.
  58280. * 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.
  58281. * @param name The name of the particle system
  58282. * @param options The options used to create the system
  58283. * @param scene The scene the particle system belongs to
  58284. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58285. */
  58286. constructor(name: string, options: Partial<{
  58287. capacity: number;
  58288. randomTextureSize: number;
  58289. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58290. protected _reset(): void;
  58291. private _createUpdateVAO;
  58292. private _createRenderVAO;
  58293. private _initialize;
  58294. /** @hidden */
  58295. _recreateUpdateEffect(): void;
  58296. /** @hidden */
  58297. _recreateRenderEffect(): void;
  58298. /**
  58299. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58300. * @param preWarm defines if we are in the pre-warmimg phase
  58301. */
  58302. animate(preWarm?: boolean): void;
  58303. private _createFactorGradientTexture;
  58304. private _createSizeGradientTexture;
  58305. private _createAngularSpeedGradientTexture;
  58306. private _createVelocityGradientTexture;
  58307. private _createLimitVelocityGradientTexture;
  58308. private _createDragGradientTexture;
  58309. private _createColorGradientTexture;
  58310. /**
  58311. * Renders the particle system in its current state
  58312. * @param preWarm defines if the system should only update the particles but not render them
  58313. * @returns the current number of particles
  58314. */
  58315. render(preWarm?: boolean): number;
  58316. /**
  58317. * Rebuilds the particle system
  58318. */
  58319. rebuild(): void;
  58320. private _releaseBuffers;
  58321. private _releaseVAOs;
  58322. /**
  58323. * Disposes the particle system and free the associated resources
  58324. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58325. */
  58326. dispose(disposeTexture?: boolean): void;
  58327. /**
  58328. * Clones the particle system.
  58329. * @param name The name of the cloned object
  58330. * @param newEmitter The new emitter to use
  58331. * @returns the cloned particle system
  58332. */
  58333. clone(name: string, newEmitter: any): GPUParticleSystem;
  58334. /**
  58335. * Serializes the particle system to a JSON object.
  58336. * @returns the JSON object
  58337. */
  58338. serialize(): any;
  58339. /**
  58340. * Parses a JSON object to create a GPU particle system.
  58341. * @param parsedParticleSystem The JSON object to parse
  58342. * @param scene The scene to create the particle system in
  58343. * @param rootUrl The root url to use to load external dependencies like texture
  58344. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58345. * @returns the parsed GPU particle system
  58346. */
  58347. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58348. }
  58349. }
  58350. declare module "babylonjs/Particles/particleSystemSet" {
  58351. import { Nullable } from "babylonjs/types";
  58352. import { Color3 } from "babylonjs/Maths/math.color";
  58353. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58356. import { Scene, IDisposable } from "babylonjs/scene";
  58357. /**
  58358. * Represents a set of particle systems working together to create a specific effect
  58359. */
  58360. export class ParticleSystemSet implements IDisposable {
  58361. private _emitterCreationOptions;
  58362. private _emitterNode;
  58363. /**
  58364. * Gets the particle system list
  58365. */
  58366. systems: IParticleSystem[];
  58367. /**
  58368. * Gets the emitter node used with this set
  58369. */
  58370. readonly emitterNode: Nullable<TransformNode>;
  58371. /**
  58372. * Creates a new emitter mesh as a sphere
  58373. * @param options defines the options used to create the sphere
  58374. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58375. * @param scene defines the hosting scene
  58376. */
  58377. setEmitterAsSphere(options: {
  58378. diameter: number;
  58379. segments: number;
  58380. color: Color3;
  58381. }, renderingGroupId: number, scene: Scene): void;
  58382. /**
  58383. * Starts all particle systems of the set
  58384. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58385. */
  58386. start(emitter?: AbstractMesh): void;
  58387. /**
  58388. * Release all associated resources
  58389. */
  58390. dispose(): void;
  58391. /**
  58392. * Serialize the set into a JSON compatible object
  58393. * @returns a JSON compatible representation of the set
  58394. */
  58395. serialize(): any;
  58396. /**
  58397. * Parse a new ParticleSystemSet from a serialized source
  58398. * @param data defines a JSON compatible representation of the set
  58399. * @param scene defines the hosting scene
  58400. * @param gpu defines if we want GPU particles or CPU particles
  58401. * @returns a new ParticleSystemSet
  58402. */
  58403. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58404. }
  58405. }
  58406. declare module "babylonjs/Particles/particleHelper" {
  58407. import { Nullable } from "babylonjs/types";
  58408. import { Scene } from "babylonjs/scene";
  58409. import { Vector3 } from "babylonjs/Maths/math.vector";
  58410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58411. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58412. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58413. /**
  58414. * This class is made for on one-liner static method to help creating particle system set.
  58415. */
  58416. export class ParticleHelper {
  58417. /**
  58418. * Gets or sets base Assets URL
  58419. */
  58420. static BaseAssetsUrl: string;
  58421. /**
  58422. * Create a default particle system that you can tweak
  58423. * @param emitter defines the emitter to use
  58424. * @param capacity defines the system capacity (default is 500 particles)
  58425. * @param scene defines the hosting scene
  58426. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58427. * @returns the new Particle system
  58428. */
  58429. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58430. /**
  58431. * This is the main static method (one-liner) of this helper to create different particle systems
  58432. * @param type This string represents the type to the particle system to create
  58433. * @param scene The scene where the particle system should live
  58434. * @param gpu If the system will use gpu
  58435. * @returns the ParticleSystemSet created
  58436. */
  58437. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58438. /**
  58439. * Static function used to export a particle system to a ParticleSystemSet variable.
  58440. * Please note that the emitter shape is not exported
  58441. * @param systems defines the particle systems to export
  58442. * @returns the created particle system set
  58443. */
  58444. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58445. }
  58446. }
  58447. declare module "babylonjs/Particles/particleSystemComponent" {
  58448. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58449. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58450. import "babylonjs/Shaders/particles.vertex";
  58451. module "babylonjs/Engines/engine" {
  58452. interface Engine {
  58453. /**
  58454. * Create an effect to use with particle systems.
  58455. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58456. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58457. * @param uniformsNames defines a list of attribute names
  58458. * @param samplers defines an array of string used to represent textures
  58459. * @param defines defines the string containing the defines to use to compile the shaders
  58460. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58461. * @param onCompiled defines a function to call when the effect creation is successful
  58462. * @param onError defines a function to call when the effect creation has failed
  58463. * @returns the new Effect
  58464. */
  58465. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58466. }
  58467. }
  58468. module "babylonjs/Meshes/mesh" {
  58469. interface Mesh {
  58470. /**
  58471. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58472. * @returns an array of IParticleSystem
  58473. */
  58474. getEmittedParticleSystems(): IParticleSystem[];
  58475. /**
  58476. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58477. * @returns an array of IParticleSystem
  58478. */
  58479. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58480. }
  58481. }
  58482. /**
  58483. * @hidden
  58484. */
  58485. export var _IDoNeedToBeInTheBuild: number;
  58486. }
  58487. declare module "babylonjs/Particles/index" {
  58488. export * from "babylonjs/Particles/baseParticleSystem";
  58489. export * from "babylonjs/Particles/EmitterTypes/index";
  58490. export * from "babylonjs/Particles/gpuParticleSystem";
  58491. export * from "babylonjs/Particles/IParticleSystem";
  58492. export * from "babylonjs/Particles/particle";
  58493. export * from "babylonjs/Particles/particleHelper";
  58494. export * from "babylonjs/Particles/particleSystem";
  58495. export * from "babylonjs/Particles/particleSystemComponent";
  58496. export * from "babylonjs/Particles/particleSystemSet";
  58497. export * from "babylonjs/Particles/solidParticle";
  58498. export * from "babylonjs/Particles/solidParticleSystem";
  58499. export * from "babylonjs/Particles/subEmitter";
  58500. }
  58501. declare module "babylonjs/Physics/physicsEngineComponent" {
  58502. import { Nullable } from "babylonjs/types";
  58503. import { Observable, Observer } from "babylonjs/Misc/observable";
  58504. import { Vector3 } from "babylonjs/Maths/math.vector";
  58505. import { Mesh } from "babylonjs/Meshes/mesh";
  58506. import { ISceneComponent } from "babylonjs/sceneComponent";
  58507. import { Scene } from "babylonjs/scene";
  58508. import { Node } from "babylonjs/node";
  58509. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58510. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58511. module "babylonjs/scene" {
  58512. interface Scene {
  58513. /** @hidden (Backing field) */
  58514. _physicsEngine: Nullable<IPhysicsEngine>;
  58515. /**
  58516. * Gets the current physics engine
  58517. * @returns a IPhysicsEngine or null if none attached
  58518. */
  58519. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58520. /**
  58521. * Enables physics to the current scene
  58522. * @param gravity defines the scene's gravity for the physics engine
  58523. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58524. * @return a boolean indicating if the physics engine was initialized
  58525. */
  58526. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58527. /**
  58528. * Disables and disposes the physics engine associated with the scene
  58529. */
  58530. disablePhysicsEngine(): void;
  58531. /**
  58532. * Gets a boolean indicating if there is an active physics engine
  58533. * @returns a boolean indicating if there is an active physics engine
  58534. */
  58535. isPhysicsEnabled(): boolean;
  58536. /**
  58537. * Deletes a physics compound impostor
  58538. * @param compound defines the compound to delete
  58539. */
  58540. deleteCompoundImpostor(compound: any): void;
  58541. /**
  58542. * An event triggered when physic simulation is about to be run
  58543. */
  58544. onBeforePhysicsObservable: Observable<Scene>;
  58545. /**
  58546. * An event triggered when physic simulation has been done
  58547. */
  58548. onAfterPhysicsObservable: Observable<Scene>;
  58549. }
  58550. }
  58551. module "babylonjs/Meshes/abstractMesh" {
  58552. interface AbstractMesh {
  58553. /** @hidden */
  58554. _physicsImpostor: Nullable<PhysicsImpostor>;
  58555. /**
  58556. * Gets or sets impostor used for physic simulation
  58557. * @see http://doc.babylonjs.com/features/physics_engine
  58558. */
  58559. physicsImpostor: Nullable<PhysicsImpostor>;
  58560. /**
  58561. * Gets the current physics impostor
  58562. * @see http://doc.babylonjs.com/features/physics_engine
  58563. * @returns a physics impostor or null
  58564. */
  58565. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58566. /** Apply a physic impulse to the mesh
  58567. * @param force defines the force to apply
  58568. * @param contactPoint defines where to apply the force
  58569. * @returns the current mesh
  58570. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58571. */
  58572. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58573. /**
  58574. * Creates a physic joint between two meshes
  58575. * @param otherMesh defines the other mesh to use
  58576. * @param pivot1 defines the pivot to use on this mesh
  58577. * @param pivot2 defines the pivot to use on the other mesh
  58578. * @param options defines additional options (can be plugin dependent)
  58579. * @returns the current mesh
  58580. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58581. */
  58582. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58583. /** @hidden */
  58584. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58585. }
  58586. }
  58587. /**
  58588. * Defines the physics engine scene component responsible to manage a physics engine
  58589. */
  58590. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58591. /**
  58592. * The component name helpful to identify the component in the list of scene components.
  58593. */
  58594. readonly name: string;
  58595. /**
  58596. * The scene the component belongs to.
  58597. */
  58598. scene: Scene;
  58599. /**
  58600. * Creates a new instance of the component for the given scene
  58601. * @param scene Defines the scene to register the component in
  58602. */
  58603. constructor(scene: Scene);
  58604. /**
  58605. * Registers the component in a given scene
  58606. */
  58607. register(): void;
  58608. /**
  58609. * Rebuilds the elements related to this component in case of
  58610. * context lost for instance.
  58611. */
  58612. rebuild(): void;
  58613. /**
  58614. * Disposes the component and the associated ressources
  58615. */
  58616. dispose(): void;
  58617. }
  58618. }
  58619. declare module "babylonjs/Physics/physicsHelper" {
  58620. import { Nullable } from "babylonjs/types";
  58621. import { Vector3 } from "babylonjs/Maths/math.vector";
  58622. import { Mesh } from "babylonjs/Meshes/mesh";
  58623. import { Scene } from "babylonjs/scene";
  58624. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58625. /**
  58626. * A helper for physics simulations
  58627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58628. */
  58629. export class PhysicsHelper {
  58630. private _scene;
  58631. private _physicsEngine;
  58632. /**
  58633. * Initializes the Physics helper
  58634. * @param scene Babylon.js scene
  58635. */
  58636. constructor(scene: Scene);
  58637. /**
  58638. * Applies a radial explosion impulse
  58639. * @param origin the origin of the explosion
  58640. * @param radiusOrEventOptions the radius or the options of radial explosion
  58641. * @param strength the explosion strength
  58642. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58643. * @returns A physics radial explosion event, or null
  58644. */
  58645. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58646. /**
  58647. * Applies a radial explosion force
  58648. * @param origin the origin of the explosion
  58649. * @param radiusOrEventOptions the radius or the options of radial explosion
  58650. * @param strength the explosion strength
  58651. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58652. * @returns A physics radial explosion event, or null
  58653. */
  58654. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58655. /**
  58656. * Creates a gravitational field
  58657. * @param origin the origin of the explosion
  58658. * @param radiusOrEventOptions the radius or the options of radial explosion
  58659. * @param strength the explosion strength
  58660. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58661. * @returns A physics gravitational field event, or null
  58662. */
  58663. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58664. /**
  58665. * Creates a physics updraft event
  58666. * @param origin the origin of the updraft
  58667. * @param radiusOrEventOptions the radius or the options of the updraft
  58668. * @param strength the strength of the updraft
  58669. * @param height the height of the updraft
  58670. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58671. * @returns A physics updraft event, or null
  58672. */
  58673. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58674. /**
  58675. * Creates a physics vortex event
  58676. * @param origin the of the vortex
  58677. * @param radiusOrEventOptions the radius or the options of the vortex
  58678. * @param strength the strength of the vortex
  58679. * @param height the height of the vortex
  58680. * @returns a Physics vortex event, or null
  58681. * A physics vortex event or null
  58682. */
  58683. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58684. }
  58685. /**
  58686. * Represents a physics radial explosion event
  58687. */
  58688. class PhysicsRadialExplosionEvent {
  58689. private _scene;
  58690. private _options;
  58691. private _sphere;
  58692. private _dataFetched;
  58693. /**
  58694. * Initializes a radial explosioin event
  58695. * @param _scene BabylonJS scene
  58696. * @param _options The options for the vortex event
  58697. */
  58698. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58699. /**
  58700. * Returns the data related to the radial explosion event (sphere).
  58701. * @returns The radial explosion event data
  58702. */
  58703. getData(): PhysicsRadialExplosionEventData;
  58704. /**
  58705. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58706. * @param impostor A physics imposter
  58707. * @param origin the origin of the explosion
  58708. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58709. */
  58710. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58711. /**
  58712. * Triggers affecterd impostors callbacks
  58713. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58714. */
  58715. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58716. /**
  58717. * Disposes the sphere.
  58718. * @param force Specifies if the sphere should be disposed by force
  58719. */
  58720. dispose(force?: boolean): void;
  58721. /*** Helpers ***/
  58722. private _prepareSphere;
  58723. private _intersectsWithSphere;
  58724. }
  58725. /**
  58726. * Represents a gravitational field event
  58727. */
  58728. class PhysicsGravitationalFieldEvent {
  58729. private _physicsHelper;
  58730. private _scene;
  58731. private _origin;
  58732. private _options;
  58733. private _tickCallback;
  58734. private _sphere;
  58735. private _dataFetched;
  58736. /**
  58737. * Initializes the physics gravitational field event
  58738. * @param _physicsHelper A physics helper
  58739. * @param _scene BabylonJS scene
  58740. * @param _origin The origin position of the gravitational field event
  58741. * @param _options The options for the vortex event
  58742. */
  58743. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58744. /**
  58745. * Returns the data related to the gravitational field event (sphere).
  58746. * @returns A gravitational field event
  58747. */
  58748. getData(): PhysicsGravitationalFieldEventData;
  58749. /**
  58750. * Enables the gravitational field.
  58751. */
  58752. enable(): void;
  58753. /**
  58754. * Disables the gravitational field.
  58755. */
  58756. disable(): void;
  58757. /**
  58758. * Disposes the sphere.
  58759. * @param force The force to dispose from the gravitational field event
  58760. */
  58761. dispose(force?: boolean): void;
  58762. private _tick;
  58763. }
  58764. /**
  58765. * Represents a physics updraft event
  58766. */
  58767. class PhysicsUpdraftEvent {
  58768. private _scene;
  58769. private _origin;
  58770. private _options;
  58771. private _physicsEngine;
  58772. private _originTop;
  58773. private _originDirection;
  58774. private _tickCallback;
  58775. private _cylinder;
  58776. private _cylinderPosition;
  58777. private _dataFetched;
  58778. /**
  58779. * Initializes the physics updraft event
  58780. * @param _scene BabylonJS scene
  58781. * @param _origin The origin position of the updraft
  58782. * @param _options The options for the updraft event
  58783. */
  58784. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58785. /**
  58786. * Returns the data related to the updraft event (cylinder).
  58787. * @returns A physics updraft event
  58788. */
  58789. getData(): PhysicsUpdraftEventData;
  58790. /**
  58791. * Enables the updraft.
  58792. */
  58793. enable(): void;
  58794. /**
  58795. * Disables the updraft.
  58796. */
  58797. disable(): void;
  58798. /**
  58799. * Disposes the cylinder.
  58800. * @param force Specifies if the updraft should be disposed by force
  58801. */
  58802. dispose(force?: boolean): void;
  58803. private getImpostorHitData;
  58804. private _tick;
  58805. /*** Helpers ***/
  58806. private _prepareCylinder;
  58807. private _intersectsWithCylinder;
  58808. }
  58809. /**
  58810. * Represents a physics vortex event
  58811. */
  58812. class PhysicsVortexEvent {
  58813. private _scene;
  58814. private _origin;
  58815. private _options;
  58816. private _physicsEngine;
  58817. private _originTop;
  58818. private _tickCallback;
  58819. private _cylinder;
  58820. private _cylinderPosition;
  58821. private _dataFetched;
  58822. /**
  58823. * Initializes the physics vortex event
  58824. * @param _scene The BabylonJS scene
  58825. * @param _origin The origin position of the vortex
  58826. * @param _options The options for the vortex event
  58827. */
  58828. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58829. /**
  58830. * Returns the data related to the vortex event (cylinder).
  58831. * @returns The physics vortex event data
  58832. */
  58833. getData(): PhysicsVortexEventData;
  58834. /**
  58835. * Enables the vortex.
  58836. */
  58837. enable(): void;
  58838. /**
  58839. * Disables the cortex.
  58840. */
  58841. disable(): void;
  58842. /**
  58843. * Disposes the sphere.
  58844. * @param force
  58845. */
  58846. dispose(force?: boolean): void;
  58847. private getImpostorHitData;
  58848. private _tick;
  58849. /*** Helpers ***/
  58850. private _prepareCylinder;
  58851. private _intersectsWithCylinder;
  58852. }
  58853. /**
  58854. * Options fot the radial explosion event
  58855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58856. */
  58857. export class PhysicsRadialExplosionEventOptions {
  58858. /**
  58859. * The radius of the sphere for the radial explosion.
  58860. */
  58861. radius: number;
  58862. /**
  58863. * The strenth of the explosion.
  58864. */
  58865. strength: number;
  58866. /**
  58867. * The strenght of the force in correspondence to the distance of the affected object
  58868. */
  58869. falloff: PhysicsRadialImpulseFalloff;
  58870. /**
  58871. * Sphere options for the radial explosion.
  58872. */
  58873. sphere: {
  58874. segments: number;
  58875. diameter: number;
  58876. };
  58877. /**
  58878. * Sphere options for the radial explosion.
  58879. */
  58880. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58881. }
  58882. /**
  58883. * Options fot the updraft event
  58884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58885. */
  58886. export class PhysicsUpdraftEventOptions {
  58887. /**
  58888. * The radius of the cylinder for the vortex
  58889. */
  58890. radius: number;
  58891. /**
  58892. * The strenth of the updraft.
  58893. */
  58894. strength: number;
  58895. /**
  58896. * The height of the cylinder for the updraft.
  58897. */
  58898. height: number;
  58899. /**
  58900. * The mode for the the updraft.
  58901. */
  58902. updraftMode: PhysicsUpdraftMode;
  58903. }
  58904. /**
  58905. * Options fot the vortex event
  58906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58907. */
  58908. export class PhysicsVortexEventOptions {
  58909. /**
  58910. * The radius of the cylinder for the vortex
  58911. */
  58912. radius: number;
  58913. /**
  58914. * The strenth of the vortex.
  58915. */
  58916. strength: number;
  58917. /**
  58918. * The height of the cylinder for the vortex.
  58919. */
  58920. height: number;
  58921. /**
  58922. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58923. */
  58924. centripetalForceThreshold: number;
  58925. /**
  58926. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58927. */
  58928. centripetalForceMultiplier: number;
  58929. /**
  58930. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58931. */
  58932. centrifugalForceMultiplier: number;
  58933. /**
  58934. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58935. */
  58936. updraftForceMultiplier: number;
  58937. }
  58938. /**
  58939. * The strenght of the force in correspondence to the distance of the affected object
  58940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58941. */
  58942. export enum PhysicsRadialImpulseFalloff {
  58943. /** Defines that impulse is constant in strength across it's whole radius */
  58944. Constant = 0,
  58945. /** Defines that impulse gets weaker if it's further from the origin */
  58946. Linear = 1
  58947. }
  58948. /**
  58949. * The strength of the force in correspondence to the distance of the affected object
  58950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58951. */
  58952. export enum PhysicsUpdraftMode {
  58953. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58954. Center = 0,
  58955. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58956. Perpendicular = 1
  58957. }
  58958. /**
  58959. * Interface for a physics hit data
  58960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58961. */
  58962. export interface PhysicsHitData {
  58963. /**
  58964. * The force applied at the contact point
  58965. */
  58966. force: Vector3;
  58967. /**
  58968. * The contact point
  58969. */
  58970. contactPoint: Vector3;
  58971. /**
  58972. * The distance from the origin to the contact point
  58973. */
  58974. distanceFromOrigin: number;
  58975. }
  58976. /**
  58977. * Interface for radial explosion event data
  58978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58979. */
  58980. export interface PhysicsRadialExplosionEventData {
  58981. /**
  58982. * A sphere used for the radial explosion event
  58983. */
  58984. sphere: Mesh;
  58985. }
  58986. /**
  58987. * Interface for gravitational field event data
  58988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58989. */
  58990. export interface PhysicsGravitationalFieldEventData {
  58991. /**
  58992. * A sphere mesh used for the gravitational field event
  58993. */
  58994. sphere: Mesh;
  58995. }
  58996. /**
  58997. * Interface for updraft event data
  58998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58999. */
  59000. export interface PhysicsUpdraftEventData {
  59001. /**
  59002. * A cylinder used for the updraft event
  59003. */
  59004. cylinder: Mesh;
  59005. }
  59006. /**
  59007. * Interface for vortex event data
  59008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59009. */
  59010. export interface PhysicsVortexEventData {
  59011. /**
  59012. * A cylinder used for the vortex event
  59013. */
  59014. cylinder: Mesh;
  59015. }
  59016. /**
  59017. * Interface for an affected physics impostor
  59018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59019. */
  59020. export interface PhysicsAffectedImpostorWithData {
  59021. /**
  59022. * The impostor affected by the effect
  59023. */
  59024. impostor: PhysicsImpostor;
  59025. /**
  59026. * The data about the hit/horce from the explosion
  59027. */
  59028. hitData: PhysicsHitData;
  59029. }
  59030. }
  59031. declare module "babylonjs/Physics/Plugins/index" {
  59032. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59033. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59034. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59035. }
  59036. declare module "babylonjs/Physics/index" {
  59037. export * from "babylonjs/Physics/IPhysicsEngine";
  59038. export * from "babylonjs/Physics/physicsEngine";
  59039. export * from "babylonjs/Physics/physicsEngineComponent";
  59040. export * from "babylonjs/Physics/physicsHelper";
  59041. export * from "babylonjs/Physics/physicsImpostor";
  59042. export * from "babylonjs/Physics/physicsJoint";
  59043. export * from "babylonjs/Physics/Plugins/index";
  59044. }
  59045. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59046. /** @hidden */
  59047. export var blackAndWhitePixelShader: {
  59048. name: string;
  59049. shader: string;
  59050. };
  59051. }
  59052. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59054. import { Camera } from "babylonjs/Cameras/camera";
  59055. import { Engine } from "babylonjs/Engines/engine";
  59056. import "babylonjs/Shaders/blackAndWhite.fragment";
  59057. /**
  59058. * Post process used to render in black and white
  59059. */
  59060. export class BlackAndWhitePostProcess extends PostProcess {
  59061. /**
  59062. * Linear about to convert he result to black and white (default: 1)
  59063. */
  59064. degree: number;
  59065. /**
  59066. * Creates a black and white post process
  59067. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59068. * @param name The name of the effect.
  59069. * @param options The required width/height ratio to downsize to before computing the render pass.
  59070. * @param camera The camera to apply the render pass to.
  59071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59072. * @param engine The engine which the post process will be applied. (default: current engine)
  59073. * @param reusable If the post process can be reused on the same frame. (default: false)
  59074. */
  59075. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59076. }
  59077. }
  59078. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59079. import { Nullable } from "babylonjs/types";
  59080. import { Camera } from "babylonjs/Cameras/camera";
  59081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59082. import { Engine } from "babylonjs/Engines/engine";
  59083. /**
  59084. * This represents a set of one or more post processes in Babylon.
  59085. * A post process can be used to apply a shader to a texture after it is rendered.
  59086. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59087. */
  59088. export class PostProcessRenderEffect {
  59089. private _postProcesses;
  59090. private _getPostProcesses;
  59091. private _singleInstance;
  59092. private _cameras;
  59093. private _indicesForCamera;
  59094. /**
  59095. * Name of the effect
  59096. * @hidden
  59097. */
  59098. _name: string;
  59099. /**
  59100. * Instantiates a post process render effect.
  59101. * A post process can be used to apply a shader to a texture after it is rendered.
  59102. * @param engine The engine the effect is tied to
  59103. * @param name The name of the effect
  59104. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59105. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59106. */
  59107. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59108. /**
  59109. * Checks if all the post processes in the effect are supported.
  59110. */
  59111. readonly isSupported: boolean;
  59112. /**
  59113. * Updates the current state of the effect
  59114. * @hidden
  59115. */
  59116. _update(): void;
  59117. /**
  59118. * Attaches the effect on cameras
  59119. * @param cameras The camera to attach to.
  59120. * @hidden
  59121. */
  59122. _attachCameras(cameras: Camera): void;
  59123. /**
  59124. * Attaches the effect on cameras
  59125. * @param cameras The camera to attach to.
  59126. * @hidden
  59127. */
  59128. _attachCameras(cameras: Camera[]): void;
  59129. /**
  59130. * Detaches the effect on cameras
  59131. * @param cameras The camera to detatch from.
  59132. * @hidden
  59133. */
  59134. _detachCameras(cameras: Camera): void;
  59135. /**
  59136. * Detatches the effect on cameras
  59137. * @param cameras The camera to detatch from.
  59138. * @hidden
  59139. */
  59140. _detachCameras(cameras: Camera[]): void;
  59141. /**
  59142. * Enables the effect on given cameras
  59143. * @param cameras The camera to enable.
  59144. * @hidden
  59145. */
  59146. _enable(cameras: Camera): void;
  59147. /**
  59148. * Enables the effect on given cameras
  59149. * @param cameras The camera to enable.
  59150. * @hidden
  59151. */
  59152. _enable(cameras: Nullable<Camera[]>): void;
  59153. /**
  59154. * Disables the effect on the given cameras
  59155. * @param cameras The camera to disable.
  59156. * @hidden
  59157. */
  59158. _disable(cameras: Camera): void;
  59159. /**
  59160. * Disables the effect on the given cameras
  59161. * @param cameras The camera to disable.
  59162. * @hidden
  59163. */
  59164. _disable(cameras: Nullable<Camera[]>): void;
  59165. /**
  59166. * Gets a list of the post processes contained in the effect.
  59167. * @param camera The camera to get the post processes on.
  59168. * @returns The list of the post processes in the effect.
  59169. */
  59170. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59171. }
  59172. }
  59173. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59174. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59175. /** @hidden */
  59176. export var extractHighlightsPixelShader: {
  59177. name: string;
  59178. shader: string;
  59179. };
  59180. }
  59181. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59182. import { Nullable } from "babylonjs/types";
  59183. import { Camera } from "babylonjs/Cameras/camera";
  59184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59185. import { Engine } from "babylonjs/Engines/engine";
  59186. import "babylonjs/Shaders/extractHighlights.fragment";
  59187. /**
  59188. * 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.
  59189. */
  59190. export class ExtractHighlightsPostProcess extends PostProcess {
  59191. /**
  59192. * The luminance threshold, pixels below this value will be set to black.
  59193. */
  59194. threshold: number;
  59195. /** @hidden */
  59196. _exposure: number;
  59197. /**
  59198. * Post process which has the input texture to be used when performing highlight extraction
  59199. * @hidden
  59200. */
  59201. _inputPostProcess: Nullable<PostProcess>;
  59202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59203. }
  59204. }
  59205. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59206. /** @hidden */
  59207. export var bloomMergePixelShader: {
  59208. name: string;
  59209. shader: string;
  59210. };
  59211. }
  59212. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59213. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59214. import { Nullable } from "babylonjs/types";
  59215. import { Engine } from "babylonjs/Engines/engine";
  59216. import { Camera } from "babylonjs/Cameras/camera";
  59217. import "babylonjs/Shaders/bloomMerge.fragment";
  59218. /**
  59219. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59220. */
  59221. export class BloomMergePostProcess extends PostProcess {
  59222. /** Weight of the bloom to be added to the original input. */
  59223. weight: number;
  59224. /**
  59225. * Creates a new instance of @see BloomMergePostProcess
  59226. * @param name The name of the effect.
  59227. * @param originalFromInput Post process which's input will be used for the merge.
  59228. * @param blurred Blurred highlights post process which's output will be used.
  59229. * @param weight Weight of the bloom to be added to the original input.
  59230. * @param options The required width/height ratio to downsize to before computing the render pass.
  59231. * @param camera The camera to apply the render pass to.
  59232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59233. * @param engine The engine which the post process will be applied. (default: current engine)
  59234. * @param reusable If the post process can be reused on the same frame. (default: false)
  59235. * @param textureType Type of textures used when performing the post process. (default: 0)
  59236. * @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)
  59237. */
  59238. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59239. /** Weight of the bloom to be added to the original input. */
  59240. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59241. }
  59242. }
  59243. declare module "babylonjs/PostProcesses/bloomEffect" {
  59244. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59245. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59246. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59247. import { Camera } from "babylonjs/Cameras/camera";
  59248. import { Scene } from "babylonjs/scene";
  59249. /**
  59250. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59251. */
  59252. export class BloomEffect extends PostProcessRenderEffect {
  59253. private bloomScale;
  59254. /**
  59255. * @hidden Internal
  59256. */
  59257. _effects: Array<PostProcess>;
  59258. /**
  59259. * @hidden Internal
  59260. */
  59261. _downscale: ExtractHighlightsPostProcess;
  59262. private _blurX;
  59263. private _blurY;
  59264. private _merge;
  59265. /**
  59266. * The luminance threshold to find bright areas of the image to bloom.
  59267. */
  59268. threshold: number;
  59269. /**
  59270. * The strength of the bloom.
  59271. */
  59272. weight: number;
  59273. /**
  59274. * Specifies the size of the bloom blur kernel, relative to the final output size
  59275. */
  59276. kernel: number;
  59277. /**
  59278. * Creates a new instance of @see BloomEffect
  59279. * @param scene The scene the effect belongs to.
  59280. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59281. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59282. * @param bloomWeight The the strength of bloom.
  59283. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59284. * @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)
  59285. */
  59286. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59287. /**
  59288. * Disposes each of the internal effects for a given camera.
  59289. * @param camera The camera to dispose the effect on.
  59290. */
  59291. disposeEffects(camera: Camera): void;
  59292. /**
  59293. * @hidden Internal
  59294. */
  59295. _updateEffects(): void;
  59296. /**
  59297. * Internal
  59298. * @returns if all the contained post processes are ready.
  59299. * @hidden
  59300. */
  59301. _isReady(): boolean;
  59302. }
  59303. }
  59304. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59305. /** @hidden */
  59306. export var chromaticAberrationPixelShader: {
  59307. name: string;
  59308. shader: string;
  59309. };
  59310. }
  59311. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59312. import { Vector2 } from "babylonjs/Maths/math.vector";
  59313. import { Nullable } from "babylonjs/types";
  59314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59315. import { Camera } from "babylonjs/Cameras/camera";
  59316. import { Engine } from "babylonjs/Engines/engine";
  59317. import "babylonjs/Shaders/chromaticAberration.fragment";
  59318. /**
  59319. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59320. */
  59321. export class ChromaticAberrationPostProcess extends PostProcess {
  59322. /**
  59323. * The amount of seperation of rgb channels (default: 30)
  59324. */
  59325. aberrationAmount: number;
  59326. /**
  59327. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59328. */
  59329. radialIntensity: number;
  59330. /**
  59331. * 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))
  59332. */
  59333. direction: Vector2;
  59334. /**
  59335. * 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))
  59336. */
  59337. centerPosition: Vector2;
  59338. /**
  59339. * Creates a new instance ChromaticAberrationPostProcess
  59340. * @param name The name of the effect.
  59341. * @param screenWidth The width of the screen to apply the effect on.
  59342. * @param screenHeight The height of the screen to apply the effect on.
  59343. * @param options The required width/height ratio to downsize to before computing the render pass.
  59344. * @param camera The camera to apply the render pass to.
  59345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59346. * @param engine The engine which the post process will be applied. (default: current engine)
  59347. * @param reusable If the post process can be reused on the same frame. (default: false)
  59348. * @param textureType Type of textures used when performing the post process. (default: 0)
  59349. * @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)
  59350. */
  59351. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59352. }
  59353. }
  59354. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59355. /** @hidden */
  59356. export var circleOfConfusionPixelShader: {
  59357. name: string;
  59358. shader: string;
  59359. };
  59360. }
  59361. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59362. import { Nullable } from "babylonjs/types";
  59363. import { Engine } from "babylonjs/Engines/engine";
  59364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59366. import { Camera } from "babylonjs/Cameras/camera";
  59367. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59368. /**
  59369. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59370. */
  59371. export class CircleOfConfusionPostProcess extends PostProcess {
  59372. /**
  59373. * 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.
  59374. */
  59375. lensSize: number;
  59376. /**
  59377. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59378. */
  59379. fStop: number;
  59380. /**
  59381. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59382. */
  59383. focusDistance: number;
  59384. /**
  59385. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59386. */
  59387. focalLength: number;
  59388. private _depthTexture;
  59389. /**
  59390. * Creates a new instance CircleOfConfusionPostProcess
  59391. * @param name The name of the effect.
  59392. * @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.
  59393. * @param options The required width/height ratio to downsize to before computing the render pass.
  59394. * @param camera The camera to apply the render pass to.
  59395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59396. * @param engine The engine which the post process will be applied. (default: current engine)
  59397. * @param reusable If the post process can be reused on the same frame. (default: false)
  59398. * @param textureType Type of textures used when performing the post process. (default: 0)
  59399. * @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)
  59400. */
  59401. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59402. /**
  59403. * 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.
  59404. */
  59405. depthTexture: RenderTargetTexture;
  59406. }
  59407. }
  59408. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59409. /** @hidden */
  59410. export var colorCorrectionPixelShader: {
  59411. name: string;
  59412. shader: string;
  59413. };
  59414. }
  59415. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59416. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59417. import { Engine } from "babylonjs/Engines/engine";
  59418. import { Camera } from "babylonjs/Cameras/camera";
  59419. import "babylonjs/Shaders/colorCorrection.fragment";
  59420. /**
  59421. *
  59422. * This post-process allows the modification of rendered colors by using
  59423. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59424. *
  59425. * The object needs to be provided an url to a texture containing the color
  59426. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59427. * Use an image editing software to tweak the LUT to match your needs.
  59428. *
  59429. * For an example of a color LUT, see here:
  59430. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59431. * For explanations on color grading, see here:
  59432. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59433. *
  59434. */
  59435. export class ColorCorrectionPostProcess extends PostProcess {
  59436. private _colorTableTexture;
  59437. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59438. }
  59439. }
  59440. declare module "babylonjs/Shaders/convolution.fragment" {
  59441. /** @hidden */
  59442. export var convolutionPixelShader: {
  59443. name: string;
  59444. shader: string;
  59445. };
  59446. }
  59447. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59448. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59449. import { Nullable } from "babylonjs/types";
  59450. import { Camera } from "babylonjs/Cameras/camera";
  59451. import { Engine } from "babylonjs/Engines/engine";
  59452. import "babylonjs/Shaders/convolution.fragment";
  59453. /**
  59454. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59455. * input texture to perform effects such as edge detection or sharpening
  59456. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59457. */
  59458. export class ConvolutionPostProcess extends PostProcess {
  59459. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59460. kernel: number[];
  59461. /**
  59462. * Creates a new instance ConvolutionPostProcess
  59463. * @param name The name of the effect.
  59464. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59465. * @param options The required width/height ratio to downsize to before computing the render pass.
  59466. * @param camera The camera to apply the render pass to.
  59467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59468. * @param engine The engine which the post process will be applied. (default: current engine)
  59469. * @param reusable If the post process can be reused on the same frame. (default: false)
  59470. * @param textureType Type of textures used when performing the post process. (default: 0)
  59471. */
  59472. constructor(name: string,
  59473. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59474. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59475. /**
  59476. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59477. */
  59478. static EdgeDetect0Kernel: number[];
  59479. /**
  59480. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59481. */
  59482. static EdgeDetect1Kernel: number[];
  59483. /**
  59484. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59485. */
  59486. static EdgeDetect2Kernel: number[];
  59487. /**
  59488. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59489. */
  59490. static SharpenKernel: number[];
  59491. /**
  59492. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59493. */
  59494. static EmbossKernel: number[];
  59495. /**
  59496. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59497. */
  59498. static GaussianKernel: number[];
  59499. }
  59500. }
  59501. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59502. import { Nullable } from "babylonjs/types";
  59503. import { Vector2 } from "babylonjs/Maths/math.vector";
  59504. import { Camera } from "babylonjs/Cameras/camera";
  59505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59506. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59507. import { Engine } from "babylonjs/Engines/engine";
  59508. import { Scene } from "babylonjs/scene";
  59509. /**
  59510. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59511. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59512. * based on samples that have a large difference in distance than the center pixel.
  59513. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59514. */
  59515. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59516. direction: Vector2;
  59517. /**
  59518. * Creates a new instance CircleOfConfusionPostProcess
  59519. * @param name The name of the effect.
  59520. * @param scene The scene the effect belongs to.
  59521. * @param direction The direction the blur should be applied.
  59522. * @param kernel The size of the kernel used to blur.
  59523. * @param options The required width/height ratio to downsize to before computing the render pass.
  59524. * @param camera The camera to apply the render pass to.
  59525. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59526. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59528. * @param engine The engine which the post process will be applied. (default: current engine)
  59529. * @param reusable If the post process can be reused on the same frame. (default: false)
  59530. * @param textureType Type of textures used when performing the post process. (default: 0)
  59531. * @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)
  59532. */
  59533. 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);
  59534. }
  59535. }
  59536. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59537. /** @hidden */
  59538. export var depthOfFieldMergePixelShader: {
  59539. name: string;
  59540. shader: string;
  59541. };
  59542. }
  59543. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59544. import { Nullable } from "babylonjs/types";
  59545. import { Camera } from "babylonjs/Cameras/camera";
  59546. import { Effect } from "babylonjs/Materials/effect";
  59547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59548. import { Engine } from "babylonjs/Engines/engine";
  59549. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59550. /**
  59551. * Options to be set when merging outputs from the default pipeline.
  59552. */
  59553. export class DepthOfFieldMergePostProcessOptions {
  59554. /**
  59555. * The original image to merge on top of
  59556. */
  59557. originalFromInput: PostProcess;
  59558. /**
  59559. * Parameters to perform the merge of the depth of field effect
  59560. */
  59561. depthOfField?: {
  59562. circleOfConfusion: PostProcess;
  59563. blurSteps: Array<PostProcess>;
  59564. };
  59565. /**
  59566. * Parameters to perform the merge of bloom effect
  59567. */
  59568. bloom?: {
  59569. blurred: PostProcess;
  59570. weight: number;
  59571. };
  59572. }
  59573. /**
  59574. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59575. */
  59576. export class DepthOfFieldMergePostProcess extends PostProcess {
  59577. private blurSteps;
  59578. /**
  59579. * Creates a new instance of DepthOfFieldMergePostProcess
  59580. * @param name The name of the effect.
  59581. * @param originalFromInput Post process which's input will be used for the merge.
  59582. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59583. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59584. * @param options The required width/height ratio to downsize to before computing the render pass.
  59585. * @param camera The camera to apply the render pass to.
  59586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59587. * @param engine The engine which the post process will be applied. (default: current engine)
  59588. * @param reusable If the post process can be reused on the same frame. (default: false)
  59589. * @param textureType Type of textures used when performing the post process. (default: 0)
  59590. * @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)
  59591. */
  59592. 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);
  59593. /**
  59594. * Updates the effect with the current post process compile time values and recompiles the shader.
  59595. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59596. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59597. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59598. * @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
  59599. * @param onCompiled Called when the shader has been compiled.
  59600. * @param onError Called if there is an error when compiling a shader.
  59601. */
  59602. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59603. }
  59604. }
  59605. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59606. import { Nullable } from "babylonjs/types";
  59607. import { Camera } from "babylonjs/Cameras/camera";
  59608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59609. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59610. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59611. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59612. import { Scene } from "babylonjs/scene";
  59613. /**
  59614. * Specifies the level of max blur that should be applied when using the depth of field effect
  59615. */
  59616. export enum DepthOfFieldEffectBlurLevel {
  59617. /**
  59618. * Subtle blur
  59619. */
  59620. Low = 0,
  59621. /**
  59622. * Medium blur
  59623. */
  59624. Medium = 1,
  59625. /**
  59626. * Large blur
  59627. */
  59628. High = 2
  59629. }
  59630. /**
  59631. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59632. */
  59633. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59634. private _circleOfConfusion;
  59635. /**
  59636. * @hidden Internal, blurs from high to low
  59637. */
  59638. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59639. private _depthOfFieldBlurY;
  59640. private _dofMerge;
  59641. /**
  59642. * @hidden Internal post processes in depth of field effect
  59643. */
  59644. _effects: Array<PostProcess>;
  59645. /**
  59646. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59647. */
  59648. focalLength: number;
  59649. /**
  59650. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59651. */
  59652. fStop: number;
  59653. /**
  59654. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59655. */
  59656. focusDistance: number;
  59657. /**
  59658. * 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.
  59659. */
  59660. lensSize: number;
  59661. /**
  59662. * Creates a new instance DepthOfFieldEffect
  59663. * @param scene The scene the effect belongs to.
  59664. * @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.
  59665. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59666. * @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)
  59667. */
  59668. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59669. /**
  59670. * Get the current class name of the current effet
  59671. * @returns "DepthOfFieldEffect"
  59672. */
  59673. getClassName(): string;
  59674. /**
  59675. * 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.
  59676. */
  59677. depthTexture: RenderTargetTexture;
  59678. /**
  59679. * Disposes each of the internal effects for a given camera.
  59680. * @param camera The camera to dispose the effect on.
  59681. */
  59682. disposeEffects(camera: Camera): void;
  59683. /**
  59684. * @hidden Internal
  59685. */
  59686. _updateEffects(): void;
  59687. /**
  59688. * Internal
  59689. * @returns if all the contained post processes are ready.
  59690. * @hidden
  59691. */
  59692. _isReady(): boolean;
  59693. }
  59694. }
  59695. declare module "babylonjs/Shaders/displayPass.fragment" {
  59696. /** @hidden */
  59697. export var displayPassPixelShader: {
  59698. name: string;
  59699. shader: string;
  59700. };
  59701. }
  59702. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59703. import { Nullable } from "babylonjs/types";
  59704. import { Camera } from "babylonjs/Cameras/camera";
  59705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59706. import { Engine } from "babylonjs/Engines/engine";
  59707. import "babylonjs/Shaders/displayPass.fragment";
  59708. /**
  59709. * DisplayPassPostProcess which produces an output the same as it's input
  59710. */
  59711. export class DisplayPassPostProcess extends PostProcess {
  59712. /**
  59713. * Creates the DisplayPassPostProcess
  59714. * @param name The name of the effect.
  59715. * @param options The required width/height ratio to downsize to before computing the render pass.
  59716. * @param camera The camera to apply the render pass to.
  59717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59718. * @param engine The engine which the post process will be applied. (default: current engine)
  59719. * @param reusable If the post process can be reused on the same frame. (default: false)
  59720. */
  59721. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59722. }
  59723. }
  59724. declare module "babylonjs/Shaders/filter.fragment" {
  59725. /** @hidden */
  59726. export var filterPixelShader: {
  59727. name: string;
  59728. shader: string;
  59729. };
  59730. }
  59731. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59732. import { Nullable } from "babylonjs/types";
  59733. import { Matrix } from "babylonjs/Maths/math.vector";
  59734. import { Camera } from "babylonjs/Cameras/camera";
  59735. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59736. import { Engine } from "babylonjs/Engines/engine";
  59737. import "babylonjs/Shaders/filter.fragment";
  59738. /**
  59739. * Applies a kernel filter to the image
  59740. */
  59741. export class FilterPostProcess extends PostProcess {
  59742. /** The matrix to be applied to the image */
  59743. kernelMatrix: Matrix;
  59744. /**
  59745. *
  59746. * @param name The name of the effect.
  59747. * @param kernelMatrix The matrix to be applied to the image
  59748. * @param options The required width/height ratio to downsize to before computing the render pass.
  59749. * @param camera The camera to apply the render pass to.
  59750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59751. * @param engine The engine which the post process will be applied. (default: current engine)
  59752. * @param reusable If the post process can be reused on the same frame. (default: false)
  59753. */
  59754. constructor(name: string,
  59755. /** The matrix to be applied to the image */
  59756. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59757. }
  59758. }
  59759. declare module "babylonjs/Shaders/fxaa.fragment" {
  59760. /** @hidden */
  59761. export var fxaaPixelShader: {
  59762. name: string;
  59763. shader: string;
  59764. };
  59765. }
  59766. declare module "babylonjs/Shaders/fxaa.vertex" {
  59767. /** @hidden */
  59768. export var fxaaVertexShader: {
  59769. name: string;
  59770. shader: string;
  59771. };
  59772. }
  59773. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59774. import { Nullable } from "babylonjs/types";
  59775. import { Camera } from "babylonjs/Cameras/camera";
  59776. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59777. import { Engine } from "babylonjs/Engines/engine";
  59778. import "babylonjs/Shaders/fxaa.fragment";
  59779. import "babylonjs/Shaders/fxaa.vertex";
  59780. /**
  59781. * Fxaa post process
  59782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59783. */
  59784. export class FxaaPostProcess extends PostProcess {
  59785. /** @hidden */
  59786. texelWidth: number;
  59787. /** @hidden */
  59788. texelHeight: number;
  59789. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59790. private _getDefines;
  59791. }
  59792. }
  59793. declare module "babylonjs/Shaders/grain.fragment" {
  59794. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59795. /** @hidden */
  59796. export var grainPixelShader: {
  59797. name: string;
  59798. shader: string;
  59799. };
  59800. }
  59801. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59802. import { Nullable } from "babylonjs/types";
  59803. import { Camera } from "babylonjs/Cameras/camera";
  59804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59805. import { Engine } from "babylonjs/Engines/engine";
  59806. import "babylonjs/Shaders/grain.fragment";
  59807. /**
  59808. * The GrainPostProcess adds noise to the image at mid luminance levels
  59809. */
  59810. export class GrainPostProcess extends PostProcess {
  59811. /**
  59812. * The intensity of the grain added (default: 30)
  59813. */
  59814. intensity: number;
  59815. /**
  59816. * If the grain should be randomized on every frame
  59817. */
  59818. animated: boolean;
  59819. /**
  59820. * Creates a new instance of @see GrainPostProcess
  59821. * @param name The name of the effect.
  59822. * @param options The required width/height ratio to downsize to before computing the render pass.
  59823. * @param camera The camera to apply the render pass to.
  59824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59825. * @param engine The engine which the post process will be applied. (default: current engine)
  59826. * @param reusable If the post process can be reused on the same frame. (default: false)
  59827. * @param textureType Type of textures used when performing the post process. (default: 0)
  59828. * @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)
  59829. */
  59830. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59831. }
  59832. }
  59833. declare module "babylonjs/Shaders/highlights.fragment" {
  59834. /** @hidden */
  59835. export var highlightsPixelShader: {
  59836. name: string;
  59837. shader: string;
  59838. };
  59839. }
  59840. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59841. import { Nullable } from "babylonjs/types";
  59842. import { Camera } from "babylonjs/Cameras/camera";
  59843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59844. import { Engine } from "babylonjs/Engines/engine";
  59845. import "babylonjs/Shaders/highlights.fragment";
  59846. /**
  59847. * Extracts highlights from the image
  59848. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59849. */
  59850. export class HighlightsPostProcess extends PostProcess {
  59851. /**
  59852. * Extracts highlights from the image
  59853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59854. * @param name The name of the effect.
  59855. * @param options The required width/height ratio to downsize to before computing the render pass.
  59856. * @param camera The camera to apply the render pass to.
  59857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59858. * @param engine The engine which the post process will be applied. (default: current engine)
  59859. * @param reusable If the post process can be reused on the same frame. (default: false)
  59860. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59861. */
  59862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59863. }
  59864. }
  59865. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59866. /** @hidden */
  59867. export var mrtFragmentDeclaration: {
  59868. name: string;
  59869. shader: string;
  59870. };
  59871. }
  59872. declare module "babylonjs/Shaders/geometry.fragment" {
  59873. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59874. /** @hidden */
  59875. export var geometryPixelShader: {
  59876. name: string;
  59877. shader: string;
  59878. };
  59879. }
  59880. declare module "babylonjs/Shaders/geometry.vertex" {
  59881. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59883. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59884. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59886. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59887. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59888. /** @hidden */
  59889. export var geometryVertexShader: {
  59890. name: string;
  59891. shader: string;
  59892. };
  59893. }
  59894. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59895. import { Matrix } from "babylonjs/Maths/math.vector";
  59896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59897. import { Mesh } from "babylonjs/Meshes/mesh";
  59898. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59899. import { Effect } from "babylonjs/Materials/effect";
  59900. import { Scene } from "babylonjs/scene";
  59901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59902. import "babylonjs/Shaders/geometry.fragment";
  59903. import "babylonjs/Shaders/geometry.vertex";
  59904. /** @hidden */
  59905. interface ISavedTransformationMatrix {
  59906. world: Matrix;
  59907. viewProjection: Matrix;
  59908. }
  59909. /**
  59910. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59911. */
  59912. export class GeometryBufferRenderer {
  59913. /**
  59914. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59915. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59916. */
  59917. static readonly POSITION_TEXTURE_TYPE: number;
  59918. /**
  59919. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59920. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59921. */
  59922. static readonly VELOCITY_TEXTURE_TYPE: number;
  59923. /**
  59924. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59925. * in order to compute objects velocities when enableVelocity is set to "true"
  59926. * @hidden
  59927. */
  59928. _previousTransformationMatrices: {
  59929. [index: number]: ISavedTransformationMatrix;
  59930. };
  59931. /**
  59932. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59933. * in order to compute objects velocities when enableVelocity is set to "true"
  59934. * @hidden
  59935. */
  59936. _previousBonesTransformationMatrices: {
  59937. [index: number]: Float32Array;
  59938. };
  59939. /**
  59940. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59941. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59942. */
  59943. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59944. private _scene;
  59945. private _multiRenderTarget;
  59946. private _ratio;
  59947. private _enablePosition;
  59948. private _enableVelocity;
  59949. private _positionIndex;
  59950. private _velocityIndex;
  59951. protected _effect: Effect;
  59952. protected _cachedDefines: string;
  59953. /**
  59954. * Set the render list (meshes to be rendered) used in the G buffer.
  59955. */
  59956. renderList: Mesh[];
  59957. /**
  59958. * Gets wether or not G buffer are supported by the running hardware.
  59959. * This requires draw buffer supports
  59960. */
  59961. readonly isSupported: boolean;
  59962. /**
  59963. * Returns the index of the given texture type in the G-Buffer textures array
  59964. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59965. * @returns the index of the given texture type in the G-Buffer textures array
  59966. */
  59967. getTextureIndex(textureType: number): number;
  59968. /**
  59969. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59970. */
  59971. /**
  59972. * Sets whether or not objects positions are enabled for the G buffer.
  59973. */
  59974. enablePosition: boolean;
  59975. /**
  59976. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59977. */
  59978. /**
  59979. * Sets wether or not objects velocities are enabled for the G buffer.
  59980. */
  59981. enableVelocity: boolean;
  59982. /**
  59983. * Gets the scene associated with the buffer.
  59984. */
  59985. readonly scene: Scene;
  59986. /**
  59987. * Gets the ratio used by the buffer during its creation.
  59988. * How big is the buffer related to the main canvas.
  59989. */
  59990. readonly ratio: number;
  59991. /** @hidden */
  59992. static _SceneComponentInitialization: (scene: Scene) => void;
  59993. /**
  59994. * Creates a new G Buffer for the scene
  59995. * @param scene The scene the buffer belongs to
  59996. * @param ratio How big is the buffer related to the main canvas.
  59997. */
  59998. constructor(scene: Scene, ratio?: number);
  59999. /**
  60000. * Checks wether everything is ready to render a submesh to the G buffer.
  60001. * @param subMesh the submesh to check readiness for
  60002. * @param useInstances is the mesh drawn using instance or not
  60003. * @returns true if ready otherwise false
  60004. */
  60005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60006. /**
  60007. * Gets the current underlying G Buffer.
  60008. * @returns the buffer
  60009. */
  60010. getGBuffer(): MultiRenderTarget;
  60011. /**
  60012. * Gets the number of samples used to render the buffer (anti aliasing).
  60013. */
  60014. /**
  60015. * Sets the number of samples used to render the buffer (anti aliasing).
  60016. */
  60017. samples: number;
  60018. /**
  60019. * Disposes the renderer and frees up associated resources.
  60020. */
  60021. dispose(): void;
  60022. protected _createRenderTargets(): void;
  60023. private _copyBonesTransformationMatrices;
  60024. }
  60025. }
  60026. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60027. import { Nullable } from "babylonjs/types";
  60028. import { Scene } from "babylonjs/scene";
  60029. import { ISceneComponent } from "babylonjs/sceneComponent";
  60030. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60031. module "babylonjs/scene" {
  60032. interface Scene {
  60033. /** @hidden (Backing field) */
  60034. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60035. /**
  60036. * Gets or Sets the current geometry buffer associated to the scene.
  60037. */
  60038. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60039. /**
  60040. * Enables a GeometryBufferRender and associates it with the scene
  60041. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60042. * @returns the GeometryBufferRenderer
  60043. */
  60044. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60045. /**
  60046. * Disables the GeometryBufferRender associated with the scene
  60047. */
  60048. disableGeometryBufferRenderer(): void;
  60049. }
  60050. }
  60051. /**
  60052. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60053. * in several rendering techniques.
  60054. */
  60055. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60056. /**
  60057. * The component name helpful to identify the component in the list of scene components.
  60058. */
  60059. readonly name: string;
  60060. /**
  60061. * The scene the component belongs to.
  60062. */
  60063. scene: Scene;
  60064. /**
  60065. * Creates a new instance of the component for the given scene
  60066. * @param scene Defines the scene to register the component in
  60067. */
  60068. constructor(scene: Scene);
  60069. /**
  60070. * Registers the component in a given scene
  60071. */
  60072. register(): void;
  60073. /**
  60074. * Rebuilds the elements related to this component in case of
  60075. * context lost for instance.
  60076. */
  60077. rebuild(): void;
  60078. /**
  60079. * Disposes the component and the associated ressources
  60080. */
  60081. dispose(): void;
  60082. private _gatherRenderTargets;
  60083. }
  60084. }
  60085. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60086. /** @hidden */
  60087. export var motionBlurPixelShader: {
  60088. name: string;
  60089. shader: string;
  60090. };
  60091. }
  60092. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60093. import { Nullable } from "babylonjs/types";
  60094. import { Camera } from "babylonjs/Cameras/camera";
  60095. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60096. import { Scene } from "babylonjs/scene";
  60097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60098. import "babylonjs/Animations/animatable";
  60099. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60100. import "babylonjs/Shaders/motionBlur.fragment";
  60101. import { Engine } from "babylonjs/Engines/engine";
  60102. /**
  60103. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60104. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60105. * As an example, all you have to do is to create the post-process:
  60106. * var mb = new BABYLON.MotionBlurPostProcess(
  60107. * 'mb', // The name of the effect.
  60108. * scene, // The scene containing the objects to blur according to their velocity.
  60109. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60110. * camera // The camera to apply the render pass to.
  60111. * );
  60112. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60113. */
  60114. export class MotionBlurPostProcess extends PostProcess {
  60115. /**
  60116. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60117. */
  60118. motionStrength: number;
  60119. /**
  60120. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60121. */
  60122. /**
  60123. * Sets the number of iterations to be used for motion blur quality
  60124. */
  60125. motionBlurSamples: number;
  60126. private _motionBlurSamples;
  60127. private _geometryBufferRenderer;
  60128. /**
  60129. * Creates a new instance MotionBlurPostProcess
  60130. * @param name The name of the effect.
  60131. * @param scene The scene containing the objects to blur according to their velocity.
  60132. * @param options The required width/height ratio to downsize to before computing the render pass.
  60133. * @param camera The camera to apply the render pass to.
  60134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60135. * @param engine The engine which the post process will be applied. (default: current engine)
  60136. * @param reusable If the post process can be reused on the same frame. (default: false)
  60137. * @param textureType Type of textures used when performing the post process. (default: 0)
  60138. * @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)
  60139. */
  60140. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60141. /**
  60142. * Excludes the given skinned mesh from computing bones velocities.
  60143. * 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.
  60144. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60145. */
  60146. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60147. /**
  60148. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60149. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60150. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60151. */
  60152. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60153. /**
  60154. * Disposes the post process.
  60155. * @param camera The camera to dispose the post process on.
  60156. */
  60157. dispose(camera?: Camera): void;
  60158. }
  60159. }
  60160. declare module "babylonjs/Shaders/refraction.fragment" {
  60161. /** @hidden */
  60162. export var refractionPixelShader: {
  60163. name: string;
  60164. shader: string;
  60165. };
  60166. }
  60167. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60168. import { Color3 } from "babylonjs/Maths/math.color";
  60169. import { Camera } from "babylonjs/Cameras/camera";
  60170. import { Texture } from "babylonjs/Materials/Textures/texture";
  60171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60172. import { Engine } from "babylonjs/Engines/engine";
  60173. import "babylonjs/Shaders/refraction.fragment";
  60174. /**
  60175. * Post process which applies a refractin texture
  60176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60177. */
  60178. export class RefractionPostProcess extends PostProcess {
  60179. /** the base color of the refraction (used to taint the rendering) */
  60180. color: Color3;
  60181. /** simulated refraction depth */
  60182. depth: number;
  60183. /** the coefficient of the base color (0 to remove base color tainting) */
  60184. colorLevel: number;
  60185. private _refTexture;
  60186. private _ownRefractionTexture;
  60187. /**
  60188. * Gets or sets the refraction texture
  60189. * Please note that you are responsible for disposing the texture if you set it manually
  60190. */
  60191. refractionTexture: Texture;
  60192. /**
  60193. * Initializes the RefractionPostProcess
  60194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60195. * @param name The name of the effect.
  60196. * @param refractionTextureUrl Url of the refraction texture to use
  60197. * @param color the base color of the refraction (used to taint the rendering)
  60198. * @param depth simulated refraction depth
  60199. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60200. * @param camera The camera to apply the render pass to.
  60201. * @param options The required width/height ratio to downsize to before computing the render pass.
  60202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60203. * @param engine The engine which the post process will be applied. (default: current engine)
  60204. * @param reusable If the post process can be reused on the same frame. (default: false)
  60205. */
  60206. constructor(name: string, refractionTextureUrl: string,
  60207. /** the base color of the refraction (used to taint the rendering) */
  60208. color: Color3,
  60209. /** simulated refraction depth */
  60210. depth: number,
  60211. /** the coefficient of the base color (0 to remove base color tainting) */
  60212. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60213. /**
  60214. * Disposes of the post process
  60215. * @param camera Camera to dispose post process on
  60216. */
  60217. dispose(camera: Camera): void;
  60218. }
  60219. }
  60220. declare module "babylonjs/Shaders/sharpen.fragment" {
  60221. /** @hidden */
  60222. export var sharpenPixelShader: {
  60223. name: string;
  60224. shader: string;
  60225. };
  60226. }
  60227. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60228. import { Nullable } from "babylonjs/types";
  60229. import { Camera } from "babylonjs/Cameras/camera";
  60230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60231. import "babylonjs/Shaders/sharpen.fragment";
  60232. import { Engine } from "babylonjs/Engines/engine";
  60233. /**
  60234. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60235. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60236. */
  60237. export class SharpenPostProcess extends PostProcess {
  60238. /**
  60239. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60240. */
  60241. colorAmount: number;
  60242. /**
  60243. * How much sharpness should be applied (default: 0.3)
  60244. */
  60245. edgeAmount: number;
  60246. /**
  60247. * Creates a new instance ConvolutionPostProcess
  60248. * @param name The name of the effect.
  60249. * @param options The required width/height ratio to downsize to before computing the render pass.
  60250. * @param camera The camera to apply the render pass to.
  60251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60252. * @param engine The engine which the post process will be applied. (default: current engine)
  60253. * @param reusable If the post process can be reused on the same frame. (default: false)
  60254. * @param textureType Type of textures used when performing the post process. (default: 0)
  60255. * @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)
  60256. */
  60257. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60258. }
  60259. }
  60260. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60261. import { Nullable } from "babylonjs/types";
  60262. import { Camera } from "babylonjs/Cameras/camera";
  60263. import { Engine } from "babylonjs/Engines/engine";
  60264. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60265. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60266. /**
  60267. * PostProcessRenderPipeline
  60268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60269. */
  60270. export class PostProcessRenderPipeline {
  60271. private engine;
  60272. private _renderEffects;
  60273. private _renderEffectsForIsolatedPass;
  60274. /**
  60275. * List of inspectable custom properties (used by the Inspector)
  60276. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60277. */
  60278. inspectableCustomProperties: IInspectable[];
  60279. /**
  60280. * @hidden
  60281. */
  60282. protected _cameras: Camera[];
  60283. /** @hidden */
  60284. _name: string;
  60285. /**
  60286. * Gets pipeline name
  60287. */
  60288. readonly name: string;
  60289. /**
  60290. * Initializes a PostProcessRenderPipeline
  60291. * @param engine engine to add the pipeline to
  60292. * @param name name of the pipeline
  60293. */
  60294. constructor(engine: Engine, name: string);
  60295. /**
  60296. * Gets the class name
  60297. * @returns "PostProcessRenderPipeline"
  60298. */
  60299. getClassName(): string;
  60300. /**
  60301. * If all the render effects in the pipeline are supported
  60302. */
  60303. readonly isSupported: boolean;
  60304. /**
  60305. * Adds an effect to the pipeline
  60306. * @param renderEffect the effect to add
  60307. */
  60308. addEffect(renderEffect: PostProcessRenderEffect): void;
  60309. /** @hidden */
  60310. _rebuild(): void;
  60311. /** @hidden */
  60312. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60313. /** @hidden */
  60314. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60315. /** @hidden */
  60316. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60317. /** @hidden */
  60318. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60319. /** @hidden */
  60320. _attachCameras(cameras: Camera, unique: boolean): void;
  60321. /** @hidden */
  60322. _attachCameras(cameras: Camera[], unique: boolean): void;
  60323. /** @hidden */
  60324. _detachCameras(cameras: Camera): void;
  60325. /** @hidden */
  60326. _detachCameras(cameras: Nullable<Camera[]>): void;
  60327. /** @hidden */
  60328. _update(): void;
  60329. /** @hidden */
  60330. _reset(): void;
  60331. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60332. /**
  60333. * Disposes of the pipeline
  60334. */
  60335. dispose(): void;
  60336. }
  60337. }
  60338. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60339. import { Camera } from "babylonjs/Cameras/camera";
  60340. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60341. /**
  60342. * PostProcessRenderPipelineManager class
  60343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60344. */
  60345. export class PostProcessRenderPipelineManager {
  60346. private _renderPipelines;
  60347. /**
  60348. * Initializes a PostProcessRenderPipelineManager
  60349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60350. */
  60351. constructor();
  60352. /**
  60353. * Gets the list of supported render pipelines
  60354. */
  60355. readonly supportedPipelines: PostProcessRenderPipeline[];
  60356. /**
  60357. * Adds a pipeline to the manager
  60358. * @param renderPipeline The pipeline to add
  60359. */
  60360. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60361. /**
  60362. * Attaches a camera to the pipeline
  60363. * @param renderPipelineName The name of the pipeline to attach to
  60364. * @param cameras the camera to attach
  60365. * @param unique if the camera can be attached multiple times to the pipeline
  60366. */
  60367. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60368. /**
  60369. * Detaches a camera from the pipeline
  60370. * @param renderPipelineName The name of the pipeline to detach from
  60371. * @param cameras the camera to detach
  60372. */
  60373. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60374. /**
  60375. * Enables an effect by name on a pipeline
  60376. * @param renderPipelineName the name of the pipeline to enable the effect in
  60377. * @param renderEffectName the name of the effect to enable
  60378. * @param cameras the cameras that the effect should be enabled on
  60379. */
  60380. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60381. /**
  60382. * Disables an effect by name on a pipeline
  60383. * @param renderPipelineName the name of the pipeline to disable the effect in
  60384. * @param renderEffectName the name of the effect to disable
  60385. * @param cameras the cameras that the effect should be disabled on
  60386. */
  60387. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60388. /**
  60389. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60390. */
  60391. update(): void;
  60392. /** @hidden */
  60393. _rebuild(): void;
  60394. /**
  60395. * Disposes of the manager and pipelines
  60396. */
  60397. dispose(): void;
  60398. }
  60399. }
  60400. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60401. import { ISceneComponent } from "babylonjs/sceneComponent";
  60402. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60403. import { Scene } from "babylonjs/scene";
  60404. module "babylonjs/scene" {
  60405. interface Scene {
  60406. /** @hidden (Backing field) */
  60407. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60408. /**
  60409. * Gets the postprocess render pipeline manager
  60410. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60411. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60412. */
  60413. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60414. }
  60415. }
  60416. /**
  60417. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60418. */
  60419. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60420. /**
  60421. * The component name helpfull to identify the component in the list of scene components.
  60422. */
  60423. readonly name: string;
  60424. /**
  60425. * The scene the component belongs to.
  60426. */
  60427. scene: Scene;
  60428. /**
  60429. * Creates a new instance of the component for the given scene
  60430. * @param scene Defines the scene to register the component in
  60431. */
  60432. constructor(scene: Scene);
  60433. /**
  60434. * Registers the component in a given scene
  60435. */
  60436. register(): void;
  60437. /**
  60438. * Rebuilds the elements related to this component in case of
  60439. * context lost for instance.
  60440. */
  60441. rebuild(): void;
  60442. /**
  60443. * Disposes the component and the associated ressources
  60444. */
  60445. dispose(): void;
  60446. private _gatherRenderTargets;
  60447. }
  60448. }
  60449. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60450. import { Nullable } from "babylonjs/types";
  60451. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60452. import { Camera } from "babylonjs/Cameras/camera";
  60453. import { IDisposable } from "babylonjs/scene";
  60454. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60455. import { Scene } from "babylonjs/scene";
  60456. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60457. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60458. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60459. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60460. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60461. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60462. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60463. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60464. import { Animation } from "babylonjs/Animations/animation";
  60465. /**
  60466. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60467. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60468. */
  60469. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60470. private _scene;
  60471. private _camerasToBeAttached;
  60472. /**
  60473. * ID of the sharpen post process,
  60474. */
  60475. private readonly SharpenPostProcessId;
  60476. /**
  60477. * @ignore
  60478. * ID of the image processing post process;
  60479. */
  60480. readonly ImageProcessingPostProcessId: string;
  60481. /**
  60482. * @ignore
  60483. * ID of the Fast Approximate Anti-Aliasing post process;
  60484. */
  60485. readonly FxaaPostProcessId: string;
  60486. /**
  60487. * ID of the chromatic aberration post process,
  60488. */
  60489. private readonly ChromaticAberrationPostProcessId;
  60490. /**
  60491. * ID of the grain post process
  60492. */
  60493. private readonly GrainPostProcessId;
  60494. /**
  60495. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60496. */
  60497. sharpen: SharpenPostProcess;
  60498. private _sharpenEffect;
  60499. private bloom;
  60500. /**
  60501. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60502. */
  60503. depthOfField: DepthOfFieldEffect;
  60504. /**
  60505. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60506. */
  60507. fxaa: FxaaPostProcess;
  60508. /**
  60509. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60510. */
  60511. imageProcessing: ImageProcessingPostProcess;
  60512. /**
  60513. * Chromatic aberration post process which will shift rgb colors in the image
  60514. */
  60515. chromaticAberration: ChromaticAberrationPostProcess;
  60516. private _chromaticAberrationEffect;
  60517. /**
  60518. * Grain post process which add noise to the image
  60519. */
  60520. grain: GrainPostProcess;
  60521. private _grainEffect;
  60522. /**
  60523. * Glow post process which adds a glow to emissive areas of the image
  60524. */
  60525. private _glowLayer;
  60526. /**
  60527. * Animations which can be used to tweak settings over a period of time
  60528. */
  60529. animations: Animation[];
  60530. private _imageProcessingConfigurationObserver;
  60531. private _sharpenEnabled;
  60532. private _bloomEnabled;
  60533. private _depthOfFieldEnabled;
  60534. private _depthOfFieldBlurLevel;
  60535. private _fxaaEnabled;
  60536. private _imageProcessingEnabled;
  60537. private _defaultPipelineTextureType;
  60538. private _bloomScale;
  60539. private _chromaticAberrationEnabled;
  60540. private _grainEnabled;
  60541. private _buildAllowed;
  60542. /**
  60543. * Gets active scene
  60544. */
  60545. readonly scene: Scene;
  60546. /**
  60547. * Enable or disable the sharpen process from the pipeline
  60548. */
  60549. sharpenEnabled: boolean;
  60550. private _resizeObserver;
  60551. private _hardwareScaleLevel;
  60552. private _bloomKernel;
  60553. /**
  60554. * Specifies the size of the bloom blur kernel, relative to the final output size
  60555. */
  60556. bloomKernel: number;
  60557. /**
  60558. * Specifies the weight of the bloom in the final rendering
  60559. */
  60560. private _bloomWeight;
  60561. /**
  60562. * Specifies the luma threshold for the area that will be blurred by the bloom
  60563. */
  60564. private _bloomThreshold;
  60565. private _hdr;
  60566. /**
  60567. * The strength of the bloom.
  60568. */
  60569. bloomWeight: number;
  60570. /**
  60571. * The strength of the bloom.
  60572. */
  60573. bloomThreshold: number;
  60574. /**
  60575. * The scale of the bloom, lower value will provide better performance.
  60576. */
  60577. bloomScale: number;
  60578. /**
  60579. * Enable or disable the bloom from the pipeline
  60580. */
  60581. bloomEnabled: boolean;
  60582. private _rebuildBloom;
  60583. /**
  60584. * If the depth of field is enabled.
  60585. */
  60586. depthOfFieldEnabled: boolean;
  60587. /**
  60588. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60589. */
  60590. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60591. /**
  60592. * If the anti aliasing is enabled.
  60593. */
  60594. fxaaEnabled: boolean;
  60595. private _samples;
  60596. /**
  60597. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60598. */
  60599. samples: number;
  60600. /**
  60601. * If image processing is enabled.
  60602. */
  60603. imageProcessingEnabled: boolean;
  60604. /**
  60605. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60606. */
  60607. glowLayerEnabled: boolean;
  60608. /**
  60609. * Gets the glow layer (or null if not defined)
  60610. */
  60611. readonly glowLayer: Nullable<GlowLayer>;
  60612. /**
  60613. * Enable or disable the chromaticAberration process from the pipeline
  60614. */
  60615. chromaticAberrationEnabled: boolean;
  60616. /**
  60617. * Enable or disable the grain process from the pipeline
  60618. */
  60619. grainEnabled: boolean;
  60620. /**
  60621. * @constructor
  60622. * @param name - The rendering pipeline name (default: "")
  60623. * @param hdr - If high dynamic range textures should be used (default: true)
  60624. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60625. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60626. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60627. */
  60628. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60629. /**
  60630. * Get the class name
  60631. * @returns "DefaultRenderingPipeline"
  60632. */
  60633. getClassName(): string;
  60634. /**
  60635. * Force the compilation of the entire pipeline.
  60636. */
  60637. prepare(): void;
  60638. private _hasCleared;
  60639. private _prevPostProcess;
  60640. private _prevPrevPostProcess;
  60641. private _setAutoClearAndTextureSharing;
  60642. private _depthOfFieldSceneObserver;
  60643. private _buildPipeline;
  60644. private _disposePostProcesses;
  60645. /**
  60646. * Adds a camera to the pipeline
  60647. * @param camera the camera to be added
  60648. */
  60649. addCamera(camera: Camera): void;
  60650. /**
  60651. * Removes a camera from the pipeline
  60652. * @param camera the camera to remove
  60653. */
  60654. removeCamera(camera: Camera): void;
  60655. /**
  60656. * Dispose of the pipeline and stop all post processes
  60657. */
  60658. dispose(): void;
  60659. /**
  60660. * Serialize the rendering pipeline (Used when exporting)
  60661. * @returns the serialized object
  60662. */
  60663. serialize(): any;
  60664. /**
  60665. * Parse the serialized pipeline
  60666. * @param source Source pipeline.
  60667. * @param scene The scene to load the pipeline to.
  60668. * @param rootUrl The URL of the serialized pipeline.
  60669. * @returns An instantiated pipeline from the serialized object.
  60670. */
  60671. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60672. }
  60673. }
  60674. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60675. /** @hidden */
  60676. export var lensHighlightsPixelShader: {
  60677. name: string;
  60678. shader: string;
  60679. };
  60680. }
  60681. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60682. /** @hidden */
  60683. export var depthOfFieldPixelShader: {
  60684. name: string;
  60685. shader: string;
  60686. };
  60687. }
  60688. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60689. import { Camera } from "babylonjs/Cameras/camera";
  60690. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60691. import { Scene } from "babylonjs/scene";
  60692. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60693. import "babylonjs/Shaders/chromaticAberration.fragment";
  60694. import "babylonjs/Shaders/lensHighlights.fragment";
  60695. import "babylonjs/Shaders/depthOfField.fragment";
  60696. /**
  60697. * BABYLON.JS Chromatic Aberration GLSL Shader
  60698. * Author: Olivier Guyot
  60699. * Separates very slightly R, G and B colors on the edges of the screen
  60700. * Inspired by Francois Tarlier & Martins Upitis
  60701. */
  60702. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60703. /**
  60704. * @ignore
  60705. * The chromatic aberration PostProcess id in the pipeline
  60706. */
  60707. LensChromaticAberrationEffect: string;
  60708. /**
  60709. * @ignore
  60710. * The highlights enhancing PostProcess id in the pipeline
  60711. */
  60712. HighlightsEnhancingEffect: string;
  60713. /**
  60714. * @ignore
  60715. * The depth-of-field PostProcess id in the pipeline
  60716. */
  60717. LensDepthOfFieldEffect: string;
  60718. private _scene;
  60719. private _depthTexture;
  60720. private _grainTexture;
  60721. private _chromaticAberrationPostProcess;
  60722. private _highlightsPostProcess;
  60723. private _depthOfFieldPostProcess;
  60724. private _edgeBlur;
  60725. private _grainAmount;
  60726. private _chromaticAberration;
  60727. private _distortion;
  60728. private _highlightsGain;
  60729. private _highlightsThreshold;
  60730. private _dofDistance;
  60731. private _dofAperture;
  60732. private _dofDarken;
  60733. private _dofPentagon;
  60734. private _blurNoise;
  60735. /**
  60736. * @constructor
  60737. *
  60738. * Effect parameters are as follow:
  60739. * {
  60740. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60741. * edge_blur: number; // from 0 to x (1 for realism)
  60742. * distortion: number; // from 0 to x (1 for realism)
  60743. * grain_amount: number; // from 0 to 1
  60744. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60745. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60746. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60747. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60748. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60749. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60750. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60751. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60752. * }
  60753. * Note: if an effect parameter is unset, effect is disabled
  60754. *
  60755. * @param name The rendering pipeline name
  60756. * @param parameters - An object containing all parameters (see above)
  60757. * @param scene The scene linked to this pipeline
  60758. * @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)
  60759. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60760. */
  60761. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60762. /**
  60763. * Get the class name
  60764. * @returns "LensRenderingPipeline"
  60765. */
  60766. getClassName(): string;
  60767. /**
  60768. * Gets associated scene
  60769. */
  60770. readonly scene: Scene;
  60771. /**
  60772. * Gets or sets the edge blur
  60773. */
  60774. edgeBlur: number;
  60775. /**
  60776. * Gets or sets the grain amount
  60777. */
  60778. grainAmount: number;
  60779. /**
  60780. * Gets or sets the chromatic aberration amount
  60781. */
  60782. chromaticAberration: number;
  60783. /**
  60784. * Gets or sets the depth of field aperture
  60785. */
  60786. dofAperture: number;
  60787. /**
  60788. * Gets or sets the edge distortion
  60789. */
  60790. edgeDistortion: number;
  60791. /**
  60792. * Gets or sets the depth of field distortion
  60793. */
  60794. dofDistortion: number;
  60795. /**
  60796. * Gets or sets the darken out of focus amount
  60797. */
  60798. darkenOutOfFocus: number;
  60799. /**
  60800. * Gets or sets a boolean indicating if blur noise is enabled
  60801. */
  60802. blurNoise: boolean;
  60803. /**
  60804. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60805. */
  60806. pentagonBokeh: boolean;
  60807. /**
  60808. * Gets or sets the highlight grain amount
  60809. */
  60810. highlightsGain: number;
  60811. /**
  60812. * Gets or sets the highlight threshold
  60813. */
  60814. highlightsThreshold: number;
  60815. /**
  60816. * Sets the amount of blur at the edges
  60817. * @param amount blur amount
  60818. */
  60819. setEdgeBlur(amount: number): void;
  60820. /**
  60821. * Sets edge blur to 0
  60822. */
  60823. disableEdgeBlur(): void;
  60824. /**
  60825. * Sets the amout of grain
  60826. * @param amount Amount of grain
  60827. */
  60828. setGrainAmount(amount: number): void;
  60829. /**
  60830. * Set grain amount to 0
  60831. */
  60832. disableGrain(): void;
  60833. /**
  60834. * Sets the chromatic aberration amount
  60835. * @param amount amount of chromatic aberration
  60836. */
  60837. setChromaticAberration(amount: number): void;
  60838. /**
  60839. * Sets chromatic aberration amount to 0
  60840. */
  60841. disableChromaticAberration(): void;
  60842. /**
  60843. * Sets the EdgeDistortion amount
  60844. * @param amount amount of EdgeDistortion
  60845. */
  60846. setEdgeDistortion(amount: number): void;
  60847. /**
  60848. * Sets edge distortion to 0
  60849. */
  60850. disableEdgeDistortion(): void;
  60851. /**
  60852. * Sets the FocusDistance amount
  60853. * @param amount amount of FocusDistance
  60854. */
  60855. setFocusDistance(amount: number): void;
  60856. /**
  60857. * Disables depth of field
  60858. */
  60859. disableDepthOfField(): void;
  60860. /**
  60861. * Sets the Aperture amount
  60862. * @param amount amount of Aperture
  60863. */
  60864. setAperture(amount: number): void;
  60865. /**
  60866. * Sets the DarkenOutOfFocus amount
  60867. * @param amount amount of DarkenOutOfFocus
  60868. */
  60869. setDarkenOutOfFocus(amount: number): void;
  60870. private _pentagonBokehIsEnabled;
  60871. /**
  60872. * Creates a pentagon bokeh effect
  60873. */
  60874. enablePentagonBokeh(): void;
  60875. /**
  60876. * Disables the pentagon bokeh effect
  60877. */
  60878. disablePentagonBokeh(): void;
  60879. /**
  60880. * Enables noise blur
  60881. */
  60882. enableNoiseBlur(): void;
  60883. /**
  60884. * Disables noise blur
  60885. */
  60886. disableNoiseBlur(): void;
  60887. /**
  60888. * Sets the HighlightsGain amount
  60889. * @param amount amount of HighlightsGain
  60890. */
  60891. setHighlightsGain(amount: number): void;
  60892. /**
  60893. * Sets the HighlightsThreshold amount
  60894. * @param amount amount of HighlightsThreshold
  60895. */
  60896. setHighlightsThreshold(amount: number): void;
  60897. /**
  60898. * Disables highlights
  60899. */
  60900. disableHighlights(): void;
  60901. /**
  60902. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60903. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60904. */
  60905. dispose(disableDepthRender?: boolean): void;
  60906. private _createChromaticAberrationPostProcess;
  60907. private _createHighlightsPostProcess;
  60908. private _createDepthOfFieldPostProcess;
  60909. private _createGrainTexture;
  60910. }
  60911. }
  60912. declare module "babylonjs/Shaders/ssao2.fragment" {
  60913. /** @hidden */
  60914. export var ssao2PixelShader: {
  60915. name: string;
  60916. shader: string;
  60917. };
  60918. }
  60919. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60920. /** @hidden */
  60921. export var ssaoCombinePixelShader: {
  60922. name: string;
  60923. shader: string;
  60924. };
  60925. }
  60926. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60927. import { Camera } from "babylonjs/Cameras/camera";
  60928. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60929. import { Scene } from "babylonjs/scene";
  60930. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60931. import "babylonjs/Shaders/ssao2.fragment";
  60932. import "babylonjs/Shaders/ssaoCombine.fragment";
  60933. /**
  60934. * Render pipeline to produce ssao effect
  60935. */
  60936. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60937. /**
  60938. * @ignore
  60939. * The PassPostProcess id in the pipeline that contains the original scene color
  60940. */
  60941. SSAOOriginalSceneColorEffect: string;
  60942. /**
  60943. * @ignore
  60944. * The SSAO PostProcess id in the pipeline
  60945. */
  60946. SSAORenderEffect: string;
  60947. /**
  60948. * @ignore
  60949. * The horizontal blur PostProcess id in the pipeline
  60950. */
  60951. SSAOBlurHRenderEffect: string;
  60952. /**
  60953. * @ignore
  60954. * The vertical blur PostProcess id in the pipeline
  60955. */
  60956. SSAOBlurVRenderEffect: string;
  60957. /**
  60958. * @ignore
  60959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60960. */
  60961. SSAOCombineRenderEffect: string;
  60962. /**
  60963. * The output strength of the SSAO post-process. Default value is 1.0.
  60964. */
  60965. totalStrength: number;
  60966. /**
  60967. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60968. */
  60969. maxZ: number;
  60970. /**
  60971. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60972. */
  60973. minZAspect: number;
  60974. private _samples;
  60975. /**
  60976. * Number of samples used for the SSAO calculations. Default value is 8
  60977. */
  60978. samples: number;
  60979. private _textureSamples;
  60980. /**
  60981. * Number of samples to use for antialiasing
  60982. */
  60983. textureSamples: number;
  60984. /**
  60985. * Ratio object used for SSAO ratio and blur ratio
  60986. */
  60987. private _ratio;
  60988. /**
  60989. * Dynamically generated sphere sampler.
  60990. */
  60991. private _sampleSphere;
  60992. /**
  60993. * Blur filter offsets
  60994. */
  60995. private _samplerOffsets;
  60996. private _expensiveBlur;
  60997. /**
  60998. * If bilateral blur should be used
  60999. */
  61000. expensiveBlur: boolean;
  61001. /**
  61002. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61003. */
  61004. radius: number;
  61005. /**
  61006. * The base color of the SSAO post-process
  61007. * The final result is "base + ssao" between [0, 1]
  61008. */
  61009. base: number;
  61010. /**
  61011. * Support test.
  61012. */
  61013. static readonly IsSupported: boolean;
  61014. private _scene;
  61015. private _depthTexture;
  61016. private _normalTexture;
  61017. private _randomTexture;
  61018. private _originalColorPostProcess;
  61019. private _ssaoPostProcess;
  61020. private _blurHPostProcess;
  61021. private _blurVPostProcess;
  61022. private _ssaoCombinePostProcess;
  61023. private _firstUpdate;
  61024. /**
  61025. * Gets active scene
  61026. */
  61027. readonly scene: Scene;
  61028. /**
  61029. * @constructor
  61030. * @param name The rendering pipeline name
  61031. * @param scene The scene linked to this pipeline
  61032. * @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 }
  61033. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61034. */
  61035. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61036. /**
  61037. * Get the class name
  61038. * @returns "SSAO2RenderingPipeline"
  61039. */
  61040. getClassName(): string;
  61041. /**
  61042. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61043. */
  61044. dispose(disableGeometryBufferRenderer?: boolean): void;
  61045. private _createBlurPostProcess;
  61046. /** @hidden */
  61047. _rebuild(): void;
  61048. private _bits;
  61049. private _radicalInverse_VdC;
  61050. private _hammersley;
  61051. private _hemisphereSample_uniform;
  61052. private _generateHemisphere;
  61053. private _createSSAOPostProcess;
  61054. private _createSSAOCombinePostProcess;
  61055. private _createRandomTexture;
  61056. /**
  61057. * Serialize the rendering pipeline (Used when exporting)
  61058. * @returns the serialized object
  61059. */
  61060. serialize(): any;
  61061. /**
  61062. * Parse the serialized pipeline
  61063. * @param source Source pipeline.
  61064. * @param scene The scene to load the pipeline to.
  61065. * @param rootUrl The URL of the serialized pipeline.
  61066. * @returns An instantiated pipeline from the serialized object.
  61067. */
  61068. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61069. }
  61070. }
  61071. declare module "babylonjs/Shaders/ssao.fragment" {
  61072. /** @hidden */
  61073. export var ssaoPixelShader: {
  61074. name: string;
  61075. shader: string;
  61076. };
  61077. }
  61078. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61079. import { Camera } from "babylonjs/Cameras/camera";
  61080. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61081. import { Scene } from "babylonjs/scene";
  61082. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61083. import "babylonjs/Shaders/ssao.fragment";
  61084. import "babylonjs/Shaders/ssaoCombine.fragment";
  61085. /**
  61086. * Render pipeline to produce ssao effect
  61087. */
  61088. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61089. /**
  61090. * @ignore
  61091. * The PassPostProcess id in the pipeline that contains the original scene color
  61092. */
  61093. SSAOOriginalSceneColorEffect: string;
  61094. /**
  61095. * @ignore
  61096. * The SSAO PostProcess id in the pipeline
  61097. */
  61098. SSAORenderEffect: string;
  61099. /**
  61100. * @ignore
  61101. * The horizontal blur PostProcess id in the pipeline
  61102. */
  61103. SSAOBlurHRenderEffect: string;
  61104. /**
  61105. * @ignore
  61106. * The vertical blur PostProcess id in the pipeline
  61107. */
  61108. SSAOBlurVRenderEffect: string;
  61109. /**
  61110. * @ignore
  61111. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61112. */
  61113. SSAOCombineRenderEffect: string;
  61114. /**
  61115. * The output strength of the SSAO post-process. Default value is 1.0.
  61116. */
  61117. totalStrength: number;
  61118. /**
  61119. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61120. */
  61121. radius: number;
  61122. /**
  61123. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61124. * Must not be equal to fallOff and superior to fallOff.
  61125. * Default value is 0.0075
  61126. */
  61127. area: number;
  61128. /**
  61129. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61130. * Must not be equal to area and inferior to area.
  61131. * Default value is 0.000001
  61132. */
  61133. fallOff: number;
  61134. /**
  61135. * The base color of the SSAO post-process
  61136. * The final result is "base + ssao" between [0, 1]
  61137. */
  61138. base: number;
  61139. private _scene;
  61140. private _depthTexture;
  61141. private _randomTexture;
  61142. private _originalColorPostProcess;
  61143. private _ssaoPostProcess;
  61144. private _blurHPostProcess;
  61145. private _blurVPostProcess;
  61146. private _ssaoCombinePostProcess;
  61147. private _firstUpdate;
  61148. /**
  61149. * Gets active scene
  61150. */
  61151. readonly scene: Scene;
  61152. /**
  61153. * @constructor
  61154. * @param name - The rendering pipeline name
  61155. * @param scene - The scene linked to this pipeline
  61156. * @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 }
  61157. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61158. */
  61159. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61160. /**
  61161. * Get the class name
  61162. * @returns "SSAORenderingPipeline"
  61163. */
  61164. getClassName(): string;
  61165. /**
  61166. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61167. */
  61168. dispose(disableDepthRender?: boolean): void;
  61169. private _createBlurPostProcess;
  61170. /** @hidden */
  61171. _rebuild(): void;
  61172. private _createSSAOPostProcess;
  61173. private _createSSAOCombinePostProcess;
  61174. private _createRandomTexture;
  61175. }
  61176. }
  61177. declare module "babylonjs/Shaders/standard.fragment" {
  61178. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61179. /** @hidden */
  61180. export var standardPixelShader: {
  61181. name: string;
  61182. shader: string;
  61183. };
  61184. }
  61185. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61186. import { Nullable } from "babylonjs/types";
  61187. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61188. import { Camera } from "babylonjs/Cameras/camera";
  61189. import { Texture } from "babylonjs/Materials/Textures/texture";
  61190. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61191. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61192. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61193. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61194. import { IDisposable } from "babylonjs/scene";
  61195. import { SpotLight } from "babylonjs/Lights/spotLight";
  61196. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61197. import { Scene } from "babylonjs/scene";
  61198. import { Animation } from "babylonjs/Animations/animation";
  61199. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61200. import "babylonjs/Shaders/standard.fragment";
  61201. /**
  61202. * Standard rendering pipeline
  61203. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61204. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61205. */
  61206. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61207. /**
  61208. * Public members
  61209. */
  61210. /**
  61211. * Post-process which contains the original scene color before the pipeline applies all the effects
  61212. */
  61213. originalPostProcess: Nullable<PostProcess>;
  61214. /**
  61215. * Post-process used to down scale an image x4
  61216. */
  61217. downSampleX4PostProcess: Nullable<PostProcess>;
  61218. /**
  61219. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61220. */
  61221. brightPassPostProcess: Nullable<PostProcess>;
  61222. /**
  61223. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61224. */
  61225. blurHPostProcesses: PostProcess[];
  61226. /**
  61227. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61228. */
  61229. blurVPostProcesses: PostProcess[];
  61230. /**
  61231. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61232. */
  61233. textureAdderPostProcess: Nullable<PostProcess>;
  61234. /**
  61235. * Post-process used to create volumetric lighting effect
  61236. */
  61237. volumetricLightPostProcess: Nullable<PostProcess>;
  61238. /**
  61239. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61240. */
  61241. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61242. /**
  61243. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61244. */
  61245. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61246. /**
  61247. * Post-process used to merge the volumetric light effect and the real scene color
  61248. */
  61249. volumetricLightMergePostProces: Nullable<PostProcess>;
  61250. /**
  61251. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61252. */
  61253. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61254. /**
  61255. * Base post-process used to calculate the average luminance of the final image for HDR
  61256. */
  61257. luminancePostProcess: Nullable<PostProcess>;
  61258. /**
  61259. * Post-processes used to create down sample post-processes in order to get
  61260. * the average luminance of the final image for HDR
  61261. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61262. */
  61263. luminanceDownSamplePostProcesses: PostProcess[];
  61264. /**
  61265. * Post-process used to create a HDR effect (light adaptation)
  61266. */
  61267. hdrPostProcess: Nullable<PostProcess>;
  61268. /**
  61269. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61270. */
  61271. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61272. /**
  61273. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61274. */
  61275. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61276. /**
  61277. * Post-process used to merge the final HDR post-process and the real scene color
  61278. */
  61279. hdrFinalPostProcess: Nullable<PostProcess>;
  61280. /**
  61281. * Post-process used to create a lens flare effect
  61282. */
  61283. lensFlarePostProcess: Nullable<PostProcess>;
  61284. /**
  61285. * Post-process that merges the result of the lens flare post-process and the real scene color
  61286. */
  61287. lensFlareComposePostProcess: Nullable<PostProcess>;
  61288. /**
  61289. * Post-process used to create a motion blur effect
  61290. */
  61291. motionBlurPostProcess: Nullable<PostProcess>;
  61292. /**
  61293. * Post-process used to create a depth of field effect
  61294. */
  61295. depthOfFieldPostProcess: Nullable<PostProcess>;
  61296. /**
  61297. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61298. */
  61299. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61300. /**
  61301. * Represents the brightness threshold in order to configure the illuminated surfaces
  61302. */
  61303. brightThreshold: number;
  61304. /**
  61305. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61306. */
  61307. blurWidth: number;
  61308. /**
  61309. * Sets if the blur for highlighted surfaces must be only horizontal
  61310. */
  61311. horizontalBlur: boolean;
  61312. /**
  61313. * Gets the overall exposure used by the pipeline
  61314. */
  61315. /**
  61316. * Sets the overall exposure used by the pipeline
  61317. */
  61318. exposure: number;
  61319. /**
  61320. * Texture used typically to simulate "dirty" on camera lens
  61321. */
  61322. lensTexture: Nullable<Texture>;
  61323. /**
  61324. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61325. */
  61326. volumetricLightCoefficient: number;
  61327. /**
  61328. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61329. */
  61330. volumetricLightPower: number;
  61331. /**
  61332. * Used the set the blur intensity to smooth the volumetric lights
  61333. */
  61334. volumetricLightBlurScale: number;
  61335. /**
  61336. * Light (spot or directional) used to generate the volumetric lights rays
  61337. * The source light must have a shadow generate so the pipeline can get its
  61338. * depth map
  61339. */
  61340. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61341. /**
  61342. * For eye adaptation, represents the minimum luminance the eye can see
  61343. */
  61344. hdrMinimumLuminance: number;
  61345. /**
  61346. * For eye adaptation, represents the decrease luminance speed
  61347. */
  61348. hdrDecreaseRate: number;
  61349. /**
  61350. * For eye adaptation, represents the increase luminance speed
  61351. */
  61352. hdrIncreaseRate: number;
  61353. /**
  61354. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61355. */
  61356. /**
  61357. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61358. */
  61359. hdrAutoExposure: boolean;
  61360. /**
  61361. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61362. */
  61363. lensColorTexture: Nullable<Texture>;
  61364. /**
  61365. * The overall strengh for the lens flare effect
  61366. */
  61367. lensFlareStrength: number;
  61368. /**
  61369. * Dispersion coefficient for lens flare ghosts
  61370. */
  61371. lensFlareGhostDispersal: number;
  61372. /**
  61373. * Main lens flare halo width
  61374. */
  61375. lensFlareHaloWidth: number;
  61376. /**
  61377. * Based on the lens distortion effect, defines how much the lens flare result
  61378. * is distorted
  61379. */
  61380. lensFlareDistortionStrength: number;
  61381. /**
  61382. * Lens star texture must be used to simulate rays on the flares and is available
  61383. * in the documentation
  61384. */
  61385. lensStarTexture: Nullable<Texture>;
  61386. /**
  61387. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61388. * flare effect by taking account of the dirt texture
  61389. */
  61390. lensFlareDirtTexture: Nullable<Texture>;
  61391. /**
  61392. * Represents the focal length for the depth of field effect
  61393. */
  61394. depthOfFieldDistance: number;
  61395. /**
  61396. * Represents the blur intensity for the blurred part of the depth of field effect
  61397. */
  61398. depthOfFieldBlurWidth: number;
  61399. /**
  61400. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61401. */
  61402. /**
  61403. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61404. */
  61405. motionStrength: number;
  61406. /**
  61407. * Gets wether or not the motion blur post-process is object based or screen based.
  61408. */
  61409. /**
  61410. * Sets wether or not the motion blur post-process should be object based or screen based
  61411. */
  61412. objectBasedMotionBlur: boolean;
  61413. /**
  61414. * List of animations for the pipeline (IAnimatable implementation)
  61415. */
  61416. animations: Animation[];
  61417. /**
  61418. * Private members
  61419. */
  61420. private _scene;
  61421. private _currentDepthOfFieldSource;
  61422. private _basePostProcess;
  61423. private _fixedExposure;
  61424. private _currentExposure;
  61425. private _hdrAutoExposure;
  61426. private _hdrCurrentLuminance;
  61427. private _motionStrength;
  61428. private _isObjectBasedMotionBlur;
  61429. private _floatTextureType;
  61430. private _ratio;
  61431. private _bloomEnabled;
  61432. private _depthOfFieldEnabled;
  61433. private _vlsEnabled;
  61434. private _lensFlareEnabled;
  61435. private _hdrEnabled;
  61436. private _motionBlurEnabled;
  61437. private _fxaaEnabled;
  61438. private _motionBlurSamples;
  61439. private _volumetricLightStepsCount;
  61440. private _samples;
  61441. /**
  61442. * @ignore
  61443. * Specifies if the bloom pipeline is enabled
  61444. */
  61445. BloomEnabled: boolean;
  61446. /**
  61447. * @ignore
  61448. * Specifies if the depth of field pipeline is enabed
  61449. */
  61450. DepthOfFieldEnabled: boolean;
  61451. /**
  61452. * @ignore
  61453. * Specifies if the lens flare pipeline is enabed
  61454. */
  61455. LensFlareEnabled: boolean;
  61456. /**
  61457. * @ignore
  61458. * Specifies if the HDR pipeline is enabled
  61459. */
  61460. HDREnabled: boolean;
  61461. /**
  61462. * @ignore
  61463. * Specifies if the volumetric lights scattering effect is enabled
  61464. */
  61465. VLSEnabled: boolean;
  61466. /**
  61467. * @ignore
  61468. * Specifies if the motion blur effect is enabled
  61469. */
  61470. MotionBlurEnabled: boolean;
  61471. /**
  61472. * Specifies if anti-aliasing is enabled
  61473. */
  61474. fxaaEnabled: boolean;
  61475. /**
  61476. * Specifies the number of steps used to calculate the volumetric lights
  61477. * Typically in interval [50, 200]
  61478. */
  61479. volumetricLightStepsCount: number;
  61480. /**
  61481. * Specifies the number of samples used for the motion blur effect
  61482. * Typically in interval [16, 64]
  61483. */
  61484. motionBlurSamples: number;
  61485. /**
  61486. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61487. */
  61488. samples: number;
  61489. /**
  61490. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61491. * @constructor
  61492. * @param name The rendering pipeline name
  61493. * @param scene The scene linked to this pipeline
  61494. * @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)
  61495. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61496. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61497. */
  61498. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61499. private _buildPipeline;
  61500. private _createDownSampleX4PostProcess;
  61501. private _createBrightPassPostProcess;
  61502. private _createBlurPostProcesses;
  61503. private _createTextureAdderPostProcess;
  61504. private _createVolumetricLightPostProcess;
  61505. private _createLuminancePostProcesses;
  61506. private _createHdrPostProcess;
  61507. private _createLensFlarePostProcess;
  61508. private _createDepthOfFieldPostProcess;
  61509. private _createMotionBlurPostProcess;
  61510. private _getDepthTexture;
  61511. private _disposePostProcesses;
  61512. /**
  61513. * Dispose of the pipeline and stop all post processes
  61514. */
  61515. dispose(): void;
  61516. /**
  61517. * Serialize the rendering pipeline (Used when exporting)
  61518. * @returns the serialized object
  61519. */
  61520. serialize(): any;
  61521. /**
  61522. * Parse the serialized pipeline
  61523. * @param source Source pipeline.
  61524. * @param scene The scene to load the pipeline to.
  61525. * @param rootUrl The URL of the serialized pipeline.
  61526. * @returns An instantiated pipeline from the serialized object.
  61527. */
  61528. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61529. /**
  61530. * Luminance steps
  61531. */
  61532. static LuminanceSteps: number;
  61533. }
  61534. }
  61535. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61536. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61537. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61538. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61539. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61540. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61541. }
  61542. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61543. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61544. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61545. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61546. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61547. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61548. }
  61549. declare module "babylonjs/Shaders/tonemap.fragment" {
  61550. /** @hidden */
  61551. export var tonemapPixelShader: {
  61552. name: string;
  61553. shader: string;
  61554. };
  61555. }
  61556. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61557. import { Camera } from "babylonjs/Cameras/camera";
  61558. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61559. import "babylonjs/Shaders/tonemap.fragment";
  61560. import { Engine } from "babylonjs/Engines/engine";
  61561. /** Defines operator used for tonemapping */
  61562. export enum TonemappingOperator {
  61563. /** Hable */
  61564. Hable = 0,
  61565. /** Reinhard */
  61566. Reinhard = 1,
  61567. /** HejiDawson */
  61568. HejiDawson = 2,
  61569. /** Photographic */
  61570. Photographic = 3
  61571. }
  61572. /**
  61573. * Defines a post process to apply tone mapping
  61574. */
  61575. export class TonemapPostProcess extends PostProcess {
  61576. private _operator;
  61577. /** Defines the required exposure adjustement */
  61578. exposureAdjustment: number;
  61579. /**
  61580. * Creates a new TonemapPostProcess
  61581. * @param name defines the name of the postprocess
  61582. * @param _operator defines the operator to use
  61583. * @param exposureAdjustment defines the required exposure adjustement
  61584. * @param camera defines the camera to use (can be null)
  61585. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61586. * @param engine defines the hosting engine (can be ignore if camera is set)
  61587. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61588. */
  61589. constructor(name: string, _operator: TonemappingOperator,
  61590. /** Defines the required exposure adjustement */
  61591. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61592. }
  61593. }
  61594. declare module "babylonjs/Shaders/depth.vertex" {
  61595. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61596. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61597. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61598. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61599. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61600. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61601. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61602. /** @hidden */
  61603. export var depthVertexShader: {
  61604. name: string;
  61605. shader: string;
  61606. };
  61607. }
  61608. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61609. /** @hidden */
  61610. export var volumetricLightScatteringPixelShader: {
  61611. name: string;
  61612. shader: string;
  61613. };
  61614. }
  61615. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  61616. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61617. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61618. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61619. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61620. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61621. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61622. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61623. /** @hidden */
  61624. export var volumetricLightScatteringPassVertexShader: {
  61625. name: string;
  61626. shader: string;
  61627. };
  61628. }
  61629. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61630. /** @hidden */
  61631. export var volumetricLightScatteringPassPixelShader: {
  61632. name: string;
  61633. shader: string;
  61634. };
  61635. }
  61636. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61637. import { Vector3 } from "babylonjs/Maths/math.vector";
  61638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61639. import { Mesh } from "babylonjs/Meshes/mesh";
  61640. import { Camera } from "babylonjs/Cameras/camera";
  61641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61642. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61643. import { Scene } from "babylonjs/scene";
  61644. import "babylonjs/Meshes/Builders/planeBuilder";
  61645. import "babylonjs/Shaders/depth.vertex";
  61646. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61647. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  61648. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61649. import { Engine } from "babylonjs/Engines/engine";
  61650. /**
  61651. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61652. */
  61653. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61654. private _volumetricLightScatteringPass;
  61655. private _volumetricLightScatteringRTT;
  61656. private _viewPort;
  61657. private _screenCoordinates;
  61658. private _cachedDefines;
  61659. /**
  61660. * If not undefined, the mesh position is computed from the attached node position
  61661. */
  61662. attachedNode: {
  61663. position: Vector3;
  61664. };
  61665. /**
  61666. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61667. */
  61668. customMeshPosition: Vector3;
  61669. /**
  61670. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61671. */
  61672. useCustomMeshPosition: boolean;
  61673. /**
  61674. * If the post-process should inverse the light scattering direction
  61675. */
  61676. invert: boolean;
  61677. /**
  61678. * The internal mesh used by the post-process
  61679. */
  61680. mesh: Mesh;
  61681. /**
  61682. * @hidden
  61683. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61684. */
  61685. useDiffuseColor: boolean;
  61686. /**
  61687. * Array containing the excluded meshes not rendered in the internal pass
  61688. */
  61689. excludedMeshes: AbstractMesh[];
  61690. /**
  61691. * Controls the overall intensity of the post-process
  61692. */
  61693. exposure: number;
  61694. /**
  61695. * Dissipates each sample's contribution in range [0, 1]
  61696. */
  61697. decay: number;
  61698. /**
  61699. * Controls the overall intensity of each sample
  61700. */
  61701. weight: number;
  61702. /**
  61703. * Controls the density of each sample
  61704. */
  61705. density: number;
  61706. /**
  61707. * @constructor
  61708. * @param name The post-process name
  61709. * @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)
  61710. * @param camera The camera that the post-process will be attached to
  61711. * @param mesh The mesh used to create the light scattering
  61712. * @param samples The post-process quality, default 100
  61713. * @param samplingModeThe post-process filtering mode
  61714. * @param engine The babylon engine
  61715. * @param reusable If the post-process is reusable
  61716. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61717. */
  61718. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61719. /**
  61720. * Returns the string "VolumetricLightScatteringPostProcess"
  61721. * @returns "VolumetricLightScatteringPostProcess"
  61722. */
  61723. getClassName(): string;
  61724. private _isReady;
  61725. /**
  61726. * Sets the new light position for light scattering effect
  61727. * @param position The new custom light position
  61728. */
  61729. setCustomMeshPosition(position: Vector3): void;
  61730. /**
  61731. * Returns the light position for light scattering effect
  61732. * @return Vector3 The custom light position
  61733. */
  61734. getCustomMeshPosition(): Vector3;
  61735. /**
  61736. * Disposes the internal assets and detaches the post-process from the camera
  61737. */
  61738. dispose(camera: Camera): void;
  61739. /**
  61740. * Returns the render target texture used by the post-process
  61741. * @return the render target texture used by the post-process
  61742. */
  61743. getPass(): RenderTargetTexture;
  61744. private _meshExcluded;
  61745. private _createPass;
  61746. private _updateMeshScreenCoordinates;
  61747. /**
  61748. * Creates a default mesh for the Volumeric Light Scattering post-process
  61749. * @param name The mesh name
  61750. * @param scene The scene where to create the mesh
  61751. * @return the default mesh
  61752. */
  61753. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61754. }
  61755. }
  61756. declare module "babylonjs/PostProcesses/index" {
  61757. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61758. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61759. export * from "babylonjs/PostProcesses/bloomEffect";
  61760. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61761. export * from "babylonjs/PostProcesses/blurPostProcess";
  61762. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61763. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61764. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61765. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61766. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61767. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61768. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61769. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61770. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61771. export * from "babylonjs/PostProcesses/filterPostProcess";
  61772. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61773. export * from "babylonjs/PostProcesses/grainPostProcess";
  61774. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61775. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61776. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61777. export * from "babylonjs/PostProcesses/passPostProcess";
  61778. export * from "babylonjs/PostProcesses/postProcess";
  61779. export * from "babylonjs/PostProcesses/postProcessManager";
  61780. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61781. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61782. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61783. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61784. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61785. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61786. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61787. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61788. }
  61789. declare module "babylonjs/Probes/index" {
  61790. export * from "babylonjs/Probes/reflectionProbe";
  61791. }
  61792. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61793. import { Scene } from "babylonjs/scene";
  61794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61795. import { SmartArray } from "babylonjs/Misc/smartArray";
  61796. import { ISceneComponent } from "babylonjs/sceneComponent";
  61797. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61798. import "babylonjs/Meshes/Builders/boxBuilder";
  61799. import "babylonjs/Shaders/color.fragment";
  61800. import "babylonjs/Shaders/color.vertex";
  61801. import { Color3 } from "babylonjs/Maths/math.color";
  61802. module "babylonjs/scene" {
  61803. interface Scene {
  61804. /** @hidden (Backing field) */
  61805. _boundingBoxRenderer: BoundingBoxRenderer;
  61806. /** @hidden (Backing field) */
  61807. _forceShowBoundingBoxes: boolean;
  61808. /**
  61809. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61810. */
  61811. forceShowBoundingBoxes: boolean;
  61812. /**
  61813. * Gets the bounding box renderer associated with the scene
  61814. * @returns a BoundingBoxRenderer
  61815. */
  61816. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61817. }
  61818. }
  61819. module "babylonjs/Meshes/abstractMesh" {
  61820. interface AbstractMesh {
  61821. /** @hidden (Backing field) */
  61822. _showBoundingBox: boolean;
  61823. /**
  61824. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61825. */
  61826. showBoundingBox: boolean;
  61827. }
  61828. }
  61829. /**
  61830. * Component responsible of rendering the bounding box of the meshes in a scene.
  61831. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61832. */
  61833. export class BoundingBoxRenderer implements ISceneComponent {
  61834. /**
  61835. * The component name helpfull to identify the component in the list of scene components.
  61836. */
  61837. readonly name: string;
  61838. /**
  61839. * The scene the component belongs to.
  61840. */
  61841. scene: Scene;
  61842. /**
  61843. * Color of the bounding box lines placed in front of an object
  61844. */
  61845. frontColor: Color3;
  61846. /**
  61847. * Color of the bounding box lines placed behind an object
  61848. */
  61849. backColor: Color3;
  61850. /**
  61851. * Defines if the renderer should show the back lines or not
  61852. */
  61853. showBackLines: boolean;
  61854. /**
  61855. * @hidden
  61856. */
  61857. renderList: SmartArray<BoundingBox>;
  61858. private _colorShader;
  61859. private _vertexBuffers;
  61860. private _indexBuffer;
  61861. private _fillIndexBuffer;
  61862. private _fillIndexData;
  61863. /**
  61864. * Instantiates a new bounding box renderer in a scene.
  61865. * @param scene the scene the renderer renders in
  61866. */
  61867. constructor(scene: Scene);
  61868. /**
  61869. * Registers the component in a given scene
  61870. */
  61871. register(): void;
  61872. private _evaluateSubMesh;
  61873. private _activeMesh;
  61874. private _prepareRessources;
  61875. private _createIndexBuffer;
  61876. /**
  61877. * Rebuilds the elements related to this component in case of
  61878. * context lost for instance.
  61879. */
  61880. rebuild(): void;
  61881. /**
  61882. * @hidden
  61883. */
  61884. reset(): void;
  61885. /**
  61886. * Render the bounding boxes of a specific rendering group
  61887. * @param renderingGroupId defines the rendering group to render
  61888. */
  61889. render(renderingGroupId: number): void;
  61890. /**
  61891. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61892. * @param mesh Define the mesh to render the occlusion bounding box for
  61893. */
  61894. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61895. /**
  61896. * Dispose and release the resources attached to this renderer.
  61897. */
  61898. dispose(): void;
  61899. }
  61900. }
  61901. declare module "babylonjs/Shaders/depth.fragment" {
  61902. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61903. /** @hidden */
  61904. export var depthPixelShader: {
  61905. name: string;
  61906. shader: string;
  61907. };
  61908. }
  61909. declare module "babylonjs/Rendering/depthRenderer" {
  61910. import { Nullable } from "babylonjs/types";
  61911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61912. import { Scene } from "babylonjs/scene";
  61913. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61914. import { Camera } from "babylonjs/Cameras/camera";
  61915. import "babylonjs/Shaders/depth.fragment";
  61916. import "babylonjs/Shaders/depth.vertex";
  61917. /**
  61918. * This represents a depth renderer in Babylon.
  61919. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61920. */
  61921. export class DepthRenderer {
  61922. private _scene;
  61923. private _depthMap;
  61924. private _effect;
  61925. private readonly _storeNonLinearDepth;
  61926. private readonly _clearColor;
  61927. /** Get if the depth renderer is using packed depth or not */
  61928. readonly isPacked: boolean;
  61929. private _cachedDefines;
  61930. private _camera;
  61931. /**
  61932. * Specifiess that the depth renderer will only be used within
  61933. * the camera it is created for.
  61934. * This can help forcing its rendering during the camera processing.
  61935. */
  61936. useOnlyInActiveCamera: boolean;
  61937. /** @hidden */
  61938. static _SceneComponentInitialization: (scene: Scene) => void;
  61939. /**
  61940. * Instantiates a depth renderer
  61941. * @param scene The scene the renderer belongs to
  61942. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61943. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61944. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61945. */
  61946. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61947. /**
  61948. * Creates the depth rendering effect and checks if the effect is ready.
  61949. * @param subMesh The submesh to be used to render the depth map of
  61950. * @param useInstances If multiple world instances should be used
  61951. * @returns if the depth renderer is ready to render the depth map
  61952. */
  61953. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61954. /**
  61955. * Gets the texture which the depth map will be written to.
  61956. * @returns The depth map texture
  61957. */
  61958. getDepthMap(): RenderTargetTexture;
  61959. /**
  61960. * Disposes of the depth renderer.
  61961. */
  61962. dispose(): void;
  61963. }
  61964. }
  61965. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61966. import { Nullable } from "babylonjs/types";
  61967. import { Scene } from "babylonjs/scene";
  61968. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61969. import { Camera } from "babylonjs/Cameras/camera";
  61970. import { ISceneComponent } from "babylonjs/sceneComponent";
  61971. module "babylonjs/scene" {
  61972. interface Scene {
  61973. /** @hidden (Backing field) */
  61974. _depthRenderer: {
  61975. [id: string]: DepthRenderer;
  61976. };
  61977. /**
  61978. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61979. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61980. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61981. * @returns the created depth renderer
  61982. */
  61983. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61984. /**
  61985. * Disables a depth renderer for a given camera
  61986. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61987. */
  61988. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61989. }
  61990. }
  61991. /**
  61992. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61993. * in several rendering techniques.
  61994. */
  61995. export class DepthRendererSceneComponent implements ISceneComponent {
  61996. /**
  61997. * The component name helpfull to identify the component in the list of scene components.
  61998. */
  61999. readonly name: string;
  62000. /**
  62001. * The scene the component belongs to.
  62002. */
  62003. scene: Scene;
  62004. /**
  62005. * Creates a new instance of the component for the given scene
  62006. * @param scene Defines the scene to register the component in
  62007. */
  62008. constructor(scene: Scene);
  62009. /**
  62010. * Registers the component in a given scene
  62011. */
  62012. register(): void;
  62013. /**
  62014. * Rebuilds the elements related to this component in case of
  62015. * context lost for instance.
  62016. */
  62017. rebuild(): void;
  62018. /**
  62019. * Disposes the component and the associated ressources
  62020. */
  62021. dispose(): void;
  62022. private _gatherRenderTargets;
  62023. private _gatherActiveCameraRenderTargets;
  62024. }
  62025. }
  62026. declare module "babylonjs/Shaders/outline.fragment" {
  62027. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62028. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62029. /** @hidden */
  62030. export var outlinePixelShader: {
  62031. name: string;
  62032. shader: string;
  62033. };
  62034. }
  62035. declare module "babylonjs/Shaders/outline.vertex" {
  62036. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62038. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62039. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62040. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62041. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62042. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62043. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62044. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62045. /** @hidden */
  62046. export var outlineVertexShader: {
  62047. name: string;
  62048. shader: string;
  62049. };
  62050. }
  62051. declare module "babylonjs/Rendering/outlineRenderer" {
  62052. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62053. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62054. import { Scene } from "babylonjs/scene";
  62055. import { ISceneComponent } from "babylonjs/sceneComponent";
  62056. import "babylonjs/Shaders/outline.fragment";
  62057. import "babylonjs/Shaders/outline.vertex";
  62058. module "babylonjs/scene" {
  62059. interface Scene {
  62060. /** @hidden */
  62061. _outlineRenderer: OutlineRenderer;
  62062. /**
  62063. * Gets the outline renderer associated with the scene
  62064. * @returns a OutlineRenderer
  62065. */
  62066. getOutlineRenderer(): OutlineRenderer;
  62067. }
  62068. }
  62069. module "babylonjs/Meshes/abstractMesh" {
  62070. interface AbstractMesh {
  62071. /** @hidden (Backing field) */
  62072. _renderOutline: boolean;
  62073. /**
  62074. * Gets or sets a boolean indicating if the outline must be rendered as well
  62075. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62076. */
  62077. renderOutline: boolean;
  62078. /** @hidden (Backing field) */
  62079. _renderOverlay: boolean;
  62080. /**
  62081. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62082. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62083. */
  62084. renderOverlay: boolean;
  62085. }
  62086. }
  62087. /**
  62088. * This class is responsible to draw bothe outline/overlay of meshes.
  62089. * It should not be used directly but through the available method on mesh.
  62090. */
  62091. export class OutlineRenderer implements ISceneComponent {
  62092. /**
  62093. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62094. */
  62095. private static _StencilReference;
  62096. /**
  62097. * The name of the component. Each component must have a unique name.
  62098. */
  62099. name: string;
  62100. /**
  62101. * The scene the component belongs to.
  62102. */
  62103. scene: Scene;
  62104. /**
  62105. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62106. */
  62107. zOffset: number;
  62108. private _engine;
  62109. private _effect;
  62110. private _cachedDefines;
  62111. private _savedDepthWrite;
  62112. /**
  62113. * Instantiates a new outline renderer. (There could be only one per scene).
  62114. * @param scene Defines the scene it belongs to
  62115. */
  62116. constructor(scene: Scene);
  62117. /**
  62118. * Register the component to one instance of a scene.
  62119. */
  62120. register(): void;
  62121. /**
  62122. * Rebuilds the elements related to this component in case of
  62123. * context lost for instance.
  62124. */
  62125. rebuild(): void;
  62126. /**
  62127. * Disposes the component and the associated ressources.
  62128. */
  62129. dispose(): void;
  62130. /**
  62131. * Renders the outline in the canvas.
  62132. * @param subMesh Defines the sumesh to render
  62133. * @param batch Defines the batch of meshes in case of instances
  62134. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62135. */
  62136. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62137. /**
  62138. * Returns whether or not the outline renderer is ready for a given submesh.
  62139. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62140. * @param subMesh Defines the submesh to check readyness for
  62141. * @param useInstances Defines wheter wee are trying to render instances or not
  62142. * @returns true if ready otherwise false
  62143. */
  62144. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62145. private _beforeRenderingMesh;
  62146. private _afterRenderingMesh;
  62147. }
  62148. }
  62149. declare module "babylonjs/Rendering/index" {
  62150. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62151. export * from "babylonjs/Rendering/depthRenderer";
  62152. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62153. export * from "babylonjs/Rendering/edgesRenderer";
  62154. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62155. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62156. export * from "babylonjs/Rendering/outlineRenderer";
  62157. export * from "babylonjs/Rendering/renderingGroup";
  62158. export * from "babylonjs/Rendering/renderingManager";
  62159. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62160. }
  62161. declare module "babylonjs/Sprites/index" {
  62162. export * from "babylonjs/Sprites/sprite";
  62163. export * from "babylonjs/Sprites/spriteManager";
  62164. export * from "babylonjs/Sprites/spriteSceneComponent";
  62165. }
  62166. declare module "babylonjs/Misc/assetsManager" {
  62167. import { Scene } from "babylonjs/scene";
  62168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62169. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62170. import { Skeleton } from "babylonjs/Bones/skeleton";
  62171. import { Observable } from "babylonjs/Misc/observable";
  62172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62173. import { Texture } from "babylonjs/Materials/Textures/texture";
  62174. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62175. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62176. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62177. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62178. /**
  62179. * Defines the list of states available for a task inside a AssetsManager
  62180. */
  62181. export enum AssetTaskState {
  62182. /**
  62183. * Initialization
  62184. */
  62185. INIT = 0,
  62186. /**
  62187. * Running
  62188. */
  62189. RUNNING = 1,
  62190. /**
  62191. * Done
  62192. */
  62193. DONE = 2,
  62194. /**
  62195. * Error
  62196. */
  62197. ERROR = 3
  62198. }
  62199. /**
  62200. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62201. */
  62202. export abstract class AbstractAssetTask {
  62203. /**
  62204. * Task name
  62205. */ name: string;
  62206. /**
  62207. * Callback called when the task is successful
  62208. */
  62209. onSuccess: (task: any) => void;
  62210. /**
  62211. * Callback called when the task is not successful
  62212. */
  62213. onError: (task: any, message?: string, exception?: any) => void;
  62214. /**
  62215. * Creates a new AssetsManager
  62216. * @param name defines the name of the task
  62217. */
  62218. constructor(
  62219. /**
  62220. * Task name
  62221. */ name: string);
  62222. private _isCompleted;
  62223. private _taskState;
  62224. private _errorObject;
  62225. /**
  62226. * Get if the task is completed
  62227. */
  62228. readonly isCompleted: boolean;
  62229. /**
  62230. * Gets the current state of the task
  62231. */
  62232. readonly taskState: AssetTaskState;
  62233. /**
  62234. * Gets the current error object (if task is in error)
  62235. */
  62236. readonly errorObject: {
  62237. message?: string;
  62238. exception?: any;
  62239. };
  62240. /**
  62241. * Internal only
  62242. * @hidden
  62243. */
  62244. _setErrorObject(message?: string, exception?: any): void;
  62245. /**
  62246. * Execute the current task
  62247. * @param scene defines the scene where you want your assets to be loaded
  62248. * @param onSuccess is a callback called when the task is successfully executed
  62249. * @param onError is a callback called if an error occurs
  62250. */
  62251. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62252. /**
  62253. * Execute the current task
  62254. * @param scene defines the scene where you want your assets to be loaded
  62255. * @param onSuccess is a callback called when the task is successfully executed
  62256. * @param onError is a callback called if an error occurs
  62257. */
  62258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62259. /**
  62260. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62261. * This can be used with failed tasks that have the reason for failure fixed.
  62262. */
  62263. reset(): void;
  62264. private onErrorCallback;
  62265. private onDoneCallback;
  62266. }
  62267. /**
  62268. * Define the interface used by progress events raised during assets loading
  62269. */
  62270. export interface IAssetsProgressEvent {
  62271. /**
  62272. * Defines the number of remaining tasks to process
  62273. */
  62274. remainingCount: number;
  62275. /**
  62276. * Defines the total number of tasks
  62277. */
  62278. totalCount: number;
  62279. /**
  62280. * Defines the task that was just processed
  62281. */
  62282. task: AbstractAssetTask;
  62283. }
  62284. /**
  62285. * Class used to share progress information about assets loading
  62286. */
  62287. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62288. /**
  62289. * Defines the number of remaining tasks to process
  62290. */
  62291. remainingCount: number;
  62292. /**
  62293. * Defines the total number of tasks
  62294. */
  62295. totalCount: number;
  62296. /**
  62297. * Defines the task that was just processed
  62298. */
  62299. task: AbstractAssetTask;
  62300. /**
  62301. * Creates a AssetsProgressEvent
  62302. * @param remainingCount defines the number of remaining tasks to process
  62303. * @param totalCount defines the total number of tasks
  62304. * @param task defines the task that was just processed
  62305. */
  62306. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62307. }
  62308. /**
  62309. * Define a task used by AssetsManager to load meshes
  62310. */
  62311. export class MeshAssetTask extends AbstractAssetTask {
  62312. /**
  62313. * Defines the name of the task
  62314. */
  62315. name: string;
  62316. /**
  62317. * Defines the list of mesh's names you want to load
  62318. */
  62319. meshesNames: any;
  62320. /**
  62321. * Defines the root url to use as a base to load your meshes and associated resources
  62322. */
  62323. rootUrl: string;
  62324. /**
  62325. * Defines the filename of the scene to load from
  62326. */
  62327. sceneFilename: string;
  62328. /**
  62329. * Gets the list of loaded meshes
  62330. */
  62331. loadedMeshes: Array<AbstractMesh>;
  62332. /**
  62333. * Gets the list of loaded particle systems
  62334. */
  62335. loadedParticleSystems: Array<IParticleSystem>;
  62336. /**
  62337. * Gets the list of loaded skeletons
  62338. */
  62339. loadedSkeletons: Array<Skeleton>;
  62340. /**
  62341. * Gets the list of loaded animation groups
  62342. */
  62343. loadedAnimationGroups: Array<AnimationGroup>;
  62344. /**
  62345. * Callback called when the task is successful
  62346. */
  62347. onSuccess: (task: MeshAssetTask) => void;
  62348. /**
  62349. * Callback called when the task is successful
  62350. */
  62351. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62352. /**
  62353. * Creates a new MeshAssetTask
  62354. * @param name defines the name of the task
  62355. * @param meshesNames defines the list of mesh's names you want to load
  62356. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62357. * @param sceneFilename defines the filename of the scene to load from
  62358. */
  62359. constructor(
  62360. /**
  62361. * Defines the name of the task
  62362. */
  62363. name: string,
  62364. /**
  62365. * Defines the list of mesh's names you want to load
  62366. */
  62367. meshesNames: any,
  62368. /**
  62369. * Defines the root url to use as a base to load your meshes and associated resources
  62370. */
  62371. rootUrl: string,
  62372. /**
  62373. * Defines the filename of the scene to load from
  62374. */
  62375. sceneFilename: string);
  62376. /**
  62377. * Execute the current task
  62378. * @param scene defines the scene where you want your assets to be loaded
  62379. * @param onSuccess is a callback called when the task is successfully executed
  62380. * @param onError is a callback called if an error occurs
  62381. */
  62382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62383. }
  62384. /**
  62385. * Define a task used by AssetsManager to load text content
  62386. */
  62387. export class TextFileAssetTask extends AbstractAssetTask {
  62388. /**
  62389. * Defines the name of the task
  62390. */
  62391. name: string;
  62392. /**
  62393. * Defines the location of the file to load
  62394. */
  62395. url: string;
  62396. /**
  62397. * Gets the loaded text string
  62398. */
  62399. text: string;
  62400. /**
  62401. * Callback called when the task is successful
  62402. */
  62403. onSuccess: (task: TextFileAssetTask) => void;
  62404. /**
  62405. * Callback called when the task is successful
  62406. */
  62407. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62408. /**
  62409. * Creates a new TextFileAssetTask object
  62410. * @param name defines the name of the task
  62411. * @param url defines the location of the file to load
  62412. */
  62413. constructor(
  62414. /**
  62415. * Defines the name of the task
  62416. */
  62417. name: string,
  62418. /**
  62419. * Defines the location of the file to load
  62420. */
  62421. url: string);
  62422. /**
  62423. * Execute the current task
  62424. * @param scene defines the scene where you want your assets to be loaded
  62425. * @param onSuccess is a callback called when the task is successfully executed
  62426. * @param onError is a callback called if an error occurs
  62427. */
  62428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62429. }
  62430. /**
  62431. * Define a task used by AssetsManager to load binary data
  62432. */
  62433. export class BinaryFileAssetTask extends AbstractAssetTask {
  62434. /**
  62435. * Defines the name of the task
  62436. */
  62437. name: string;
  62438. /**
  62439. * Defines the location of the file to load
  62440. */
  62441. url: string;
  62442. /**
  62443. * Gets the lodaded data (as an array buffer)
  62444. */
  62445. data: ArrayBuffer;
  62446. /**
  62447. * Callback called when the task is successful
  62448. */
  62449. onSuccess: (task: BinaryFileAssetTask) => void;
  62450. /**
  62451. * Callback called when the task is successful
  62452. */
  62453. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62454. /**
  62455. * Creates a new BinaryFileAssetTask object
  62456. * @param name defines the name of the new task
  62457. * @param url defines the location of the file to load
  62458. */
  62459. constructor(
  62460. /**
  62461. * Defines the name of the task
  62462. */
  62463. name: string,
  62464. /**
  62465. * Defines the location of the file to load
  62466. */
  62467. url: string);
  62468. /**
  62469. * Execute the current task
  62470. * @param scene defines the scene where you want your assets to be loaded
  62471. * @param onSuccess is a callback called when the task is successfully executed
  62472. * @param onError is a callback called if an error occurs
  62473. */
  62474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62475. }
  62476. /**
  62477. * Define a task used by AssetsManager to load images
  62478. */
  62479. export class ImageAssetTask extends AbstractAssetTask {
  62480. /**
  62481. * Defines the name of the task
  62482. */
  62483. name: string;
  62484. /**
  62485. * Defines the location of the image to load
  62486. */
  62487. url: string;
  62488. /**
  62489. * Gets the loaded images
  62490. */
  62491. image: HTMLImageElement;
  62492. /**
  62493. * Callback called when the task is successful
  62494. */
  62495. onSuccess: (task: ImageAssetTask) => void;
  62496. /**
  62497. * Callback called when the task is successful
  62498. */
  62499. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62500. /**
  62501. * Creates a new ImageAssetTask
  62502. * @param name defines the name of the task
  62503. * @param url defines the location of the image to load
  62504. */
  62505. constructor(
  62506. /**
  62507. * Defines the name of the task
  62508. */
  62509. name: string,
  62510. /**
  62511. * Defines the location of the image to load
  62512. */
  62513. url: string);
  62514. /**
  62515. * Execute the current task
  62516. * @param scene defines the scene where you want your assets to be loaded
  62517. * @param onSuccess is a callback called when the task is successfully executed
  62518. * @param onError is a callback called if an error occurs
  62519. */
  62520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62521. }
  62522. /**
  62523. * Defines the interface used by texture loading tasks
  62524. */
  62525. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62526. /**
  62527. * Gets the loaded texture
  62528. */
  62529. texture: TEX;
  62530. }
  62531. /**
  62532. * Define a task used by AssetsManager to load 2D textures
  62533. */
  62534. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62535. /**
  62536. * Defines the name of the task
  62537. */
  62538. name: string;
  62539. /**
  62540. * Defines the location of the file to load
  62541. */
  62542. url: string;
  62543. /**
  62544. * Defines if mipmap should not be generated (default is false)
  62545. */
  62546. noMipmap?: boolean | undefined;
  62547. /**
  62548. * Defines if texture must be inverted on Y axis (default is false)
  62549. */
  62550. invertY?: boolean | undefined;
  62551. /**
  62552. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62553. */
  62554. samplingMode: number;
  62555. /**
  62556. * Gets the loaded texture
  62557. */
  62558. texture: Texture;
  62559. /**
  62560. * Callback called when the task is successful
  62561. */
  62562. onSuccess: (task: TextureAssetTask) => void;
  62563. /**
  62564. * Callback called when the task is successful
  62565. */
  62566. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62567. /**
  62568. * Creates a new TextureAssetTask object
  62569. * @param name defines the name of the task
  62570. * @param url defines the location of the file to load
  62571. * @param noMipmap defines if mipmap should not be generated (default is false)
  62572. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62573. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62574. */
  62575. constructor(
  62576. /**
  62577. * Defines the name of the task
  62578. */
  62579. name: string,
  62580. /**
  62581. * Defines the location of the file to load
  62582. */
  62583. url: string,
  62584. /**
  62585. * Defines if mipmap should not be generated (default is false)
  62586. */
  62587. noMipmap?: boolean | undefined,
  62588. /**
  62589. * Defines if texture must be inverted on Y axis (default is false)
  62590. */
  62591. invertY?: boolean | undefined,
  62592. /**
  62593. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62594. */
  62595. samplingMode?: number);
  62596. /**
  62597. * Execute the current task
  62598. * @param scene defines the scene where you want your assets to be loaded
  62599. * @param onSuccess is a callback called when the task is successfully executed
  62600. * @param onError is a callback called if an error occurs
  62601. */
  62602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62603. }
  62604. /**
  62605. * Define a task used by AssetsManager to load cube textures
  62606. */
  62607. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62608. /**
  62609. * Defines the name of the task
  62610. */
  62611. name: string;
  62612. /**
  62613. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62614. */
  62615. url: string;
  62616. /**
  62617. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62618. */
  62619. extensions?: string[] | undefined;
  62620. /**
  62621. * Defines if mipmaps should not be generated (default is false)
  62622. */
  62623. noMipmap?: boolean | undefined;
  62624. /**
  62625. * Defines the explicit list of files (undefined by default)
  62626. */
  62627. files?: string[] | undefined;
  62628. /**
  62629. * Gets the loaded texture
  62630. */
  62631. texture: CubeTexture;
  62632. /**
  62633. * Callback called when the task is successful
  62634. */
  62635. onSuccess: (task: CubeTextureAssetTask) => void;
  62636. /**
  62637. * Callback called when the task is successful
  62638. */
  62639. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62640. /**
  62641. * Creates a new CubeTextureAssetTask
  62642. * @param name defines the name of the task
  62643. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62644. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62645. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62646. * @param files defines the explicit list of files (undefined by default)
  62647. */
  62648. constructor(
  62649. /**
  62650. * Defines the name of the task
  62651. */
  62652. name: string,
  62653. /**
  62654. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62655. */
  62656. url: string,
  62657. /**
  62658. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62659. */
  62660. extensions?: string[] | undefined,
  62661. /**
  62662. * Defines if mipmaps should not be generated (default is false)
  62663. */
  62664. noMipmap?: boolean | undefined,
  62665. /**
  62666. * Defines the explicit list of files (undefined by default)
  62667. */
  62668. files?: string[] | undefined);
  62669. /**
  62670. * Execute the current task
  62671. * @param scene defines the scene where you want your assets to be loaded
  62672. * @param onSuccess is a callback called when the task is successfully executed
  62673. * @param onError is a callback called if an error occurs
  62674. */
  62675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62676. }
  62677. /**
  62678. * Define a task used by AssetsManager to load HDR cube textures
  62679. */
  62680. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62681. /**
  62682. * Defines the name of the task
  62683. */
  62684. name: string;
  62685. /**
  62686. * Defines the location of the file to load
  62687. */
  62688. url: string;
  62689. /**
  62690. * Defines the desired size (the more it increases the longer the generation will be)
  62691. */
  62692. size: number;
  62693. /**
  62694. * Defines if mipmaps should not be generated (default is false)
  62695. */
  62696. noMipmap: boolean;
  62697. /**
  62698. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62699. */
  62700. generateHarmonics: boolean;
  62701. /**
  62702. * 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)
  62703. */
  62704. gammaSpace: boolean;
  62705. /**
  62706. * Internal Use Only
  62707. */
  62708. reserved: boolean;
  62709. /**
  62710. * Gets the loaded texture
  62711. */
  62712. texture: HDRCubeTexture;
  62713. /**
  62714. * Callback called when the task is successful
  62715. */
  62716. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62717. /**
  62718. * Callback called when the task is successful
  62719. */
  62720. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62721. /**
  62722. * Creates a new HDRCubeTextureAssetTask object
  62723. * @param name defines the name of the task
  62724. * @param url defines the location of the file to load
  62725. * @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.
  62726. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62727. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62728. * @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)
  62729. * @param reserved Internal use only
  62730. */
  62731. constructor(
  62732. /**
  62733. * Defines the name of the task
  62734. */
  62735. name: string,
  62736. /**
  62737. * Defines the location of the file to load
  62738. */
  62739. url: string,
  62740. /**
  62741. * Defines the desired size (the more it increases the longer the generation will be)
  62742. */
  62743. size: number,
  62744. /**
  62745. * Defines if mipmaps should not be generated (default is false)
  62746. */
  62747. noMipmap?: boolean,
  62748. /**
  62749. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62750. */
  62751. generateHarmonics?: boolean,
  62752. /**
  62753. * 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)
  62754. */
  62755. gammaSpace?: boolean,
  62756. /**
  62757. * Internal Use Only
  62758. */
  62759. reserved?: boolean);
  62760. /**
  62761. * Execute the current task
  62762. * @param scene defines the scene where you want your assets to be loaded
  62763. * @param onSuccess is a callback called when the task is successfully executed
  62764. * @param onError is a callback called if an error occurs
  62765. */
  62766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62767. }
  62768. /**
  62769. * Define a task used by AssetsManager to load Equirectangular cube textures
  62770. */
  62771. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62772. /**
  62773. * Defines the name of the task
  62774. */
  62775. name: string;
  62776. /**
  62777. * Defines the location of the file to load
  62778. */
  62779. url: string;
  62780. /**
  62781. * Defines the desired size (the more it increases the longer the generation will be)
  62782. */
  62783. size: number;
  62784. /**
  62785. * Defines if mipmaps should not be generated (default is false)
  62786. */
  62787. noMipmap: boolean;
  62788. /**
  62789. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62790. * but the standard material would require them in Gamma space) (default is true)
  62791. */
  62792. gammaSpace: boolean;
  62793. /**
  62794. * Gets the loaded texture
  62795. */
  62796. texture: EquiRectangularCubeTexture;
  62797. /**
  62798. * Callback called when the task is successful
  62799. */
  62800. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62801. /**
  62802. * Callback called when the task is successful
  62803. */
  62804. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62805. /**
  62806. * Creates a new EquiRectangularCubeTextureAssetTask object
  62807. * @param name defines the name of the task
  62808. * @param url defines the location of the file to load
  62809. * @param size defines the desired size (the more it increases the longer the generation will be)
  62810. * If the size is omitted this implies you are using a preprocessed cubemap.
  62811. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62812. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62813. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62814. * (default is true)
  62815. */
  62816. constructor(
  62817. /**
  62818. * Defines the name of the task
  62819. */
  62820. name: string,
  62821. /**
  62822. * Defines the location of the file to load
  62823. */
  62824. url: string,
  62825. /**
  62826. * Defines the desired size (the more it increases the longer the generation will be)
  62827. */
  62828. size: number,
  62829. /**
  62830. * Defines if mipmaps should not be generated (default is false)
  62831. */
  62832. noMipmap?: boolean,
  62833. /**
  62834. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62835. * but the standard material would require them in Gamma space) (default is true)
  62836. */
  62837. gammaSpace?: boolean);
  62838. /**
  62839. * Execute the current task
  62840. * @param scene defines the scene where you want your assets to be loaded
  62841. * @param onSuccess is a callback called when the task is successfully executed
  62842. * @param onError is a callback called if an error occurs
  62843. */
  62844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62845. }
  62846. /**
  62847. * This class can be used to easily import assets into a scene
  62848. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62849. */
  62850. export class AssetsManager {
  62851. private _scene;
  62852. private _isLoading;
  62853. protected _tasks: AbstractAssetTask[];
  62854. protected _waitingTasksCount: number;
  62855. protected _totalTasksCount: number;
  62856. /**
  62857. * Callback called when all tasks are processed
  62858. */
  62859. onFinish: (tasks: AbstractAssetTask[]) => void;
  62860. /**
  62861. * Callback called when a task is successful
  62862. */
  62863. onTaskSuccess: (task: AbstractAssetTask) => void;
  62864. /**
  62865. * Callback called when a task had an error
  62866. */
  62867. onTaskError: (task: AbstractAssetTask) => void;
  62868. /**
  62869. * Callback called when a task is done (whatever the result is)
  62870. */
  62871. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62872. /**
  62873. * Observable called when all tasks are processed
  62874. */
  62875. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62876. /**
  62877. * Observable called when a task had an error
  62878. */
  62879. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62880. /**
  62881. * Observable called when all tasks were executed
  62882. */
  62883. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62884. /**
  62885. * Observable called when a task is done (whatever the result is)
  62886. */
  62887. onProgressObservable: Observable<IAssetsProgressEvent>;
  62888. /**
  62889. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62890. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62891. */
  62892. useDefaultLoadingScreen: boolean;
  62893. /**
  62894. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62895. * when all assets have been downloaded.
  62896. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62897. */
  62898. autoHideLoadingUI: boolean;
  62899. /**
  62900. * Creates a new AssetsManager
  62901. * @param scene defines the scene to work on
  62902. */
  62903. constructor(scene: Scene);
  62904. /**
  62905. * Add a MeshAssetTask to the list of active tasks
  62906. * @param taskName defines the name of the new task
  62907. * @param meshesNames defines the name of meshes to load
  62908. * @param rootUrl defines the root url to use to locate files
  62909. * @param sceneFilename defines the filename of the scene file
  62910. * @returns a new MeshAssetTask object
  62911. */
  62912. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62913. /**
  62914. * Add a TextFileAssetTask to the list of active tasks
  62915. * @param taskName defines the name of the new task
  62916. * @param url defines the url of the file to load
  62917. * @returns a new TextFileAssetTask object
  62918. */
  62919. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62920. /**
  62921. * Add a BinaryFileAssetTask to the list of active tasks
  62922. * @param taskName defines the name of the new task
  62923. * @param url defines the url of the file to load
  62924. * @returns a new BinaryFileAssetTask object
  62925. */
  62926. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62927. /**
  62928. * Add a ImageAssetTask to the list of active tasks
  62929. * @param taskName defines the name of the new task
  62930. * @param url defines the url of the file to load
  62931. * @returns a new ImageAssetTask object
  62932. */
  62933. addImageTask(taskName: string, url: string): ImageAssetTask;
  62934. /**
  62935. * Add a TextureAssetTask to the list of active tasks
  62936. * @param taskName defines the name of the new task
  62937. * @param url defines the url of the file to load
  62938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62939. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62940. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62941. * @returns a new TextureAssetTask object
  62942. */
  62943. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62944. /**
  62945. * Add a CubeTextureAssetTask to the list of active tasks
  62946. * @param taskName defines the name of the new task
  62947. * @param url defines the url of the file to load
  62948. * @param extensions defines the extension to use to load the cube map (can be null)
  62949. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62950. * @param files defines the list of files to load (can be null)
  62951. * @returns a new CubeTextureAssetTask object
  62952. */
  62953. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62954. /**
  62955. *
  62956. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62957. * @param taskName defines the name of the new task
  62958. * @param url defines the url of the file to load
  62959. * @param size defines the size you want for the cubemap (can be null)
  62960. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62961. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62962. * @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)
  62963. * @param reserved Internal use only
  62964. * @returns a new HDRCubeTextureAssetTask object
  62965. */
  62966. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62967. /**
  62968. *
  62969. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62970. * @param taskName defines the name of the new task
  62971. * @param url defines the url of the file to load
  62972. * @param size defines the size you want for the cubemap (can be null)
  62973. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62974. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62975. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62976. * @returns a new EquiRectangularCubeTextureAssetTask object
  62977. */
  62978. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62979. /**
  62980. * Remove a task from the assets manager.
  62981. * @param task the task to remove
  62982. */
  62983. removeTask(task: AbstractAssetTask): void;
  62984. private _decreaseWaitingTasksCount;
  62985. private _runTask;
  62986. /**
  62987. * Reset the AssetsManager and remove all tasks
  62988. * @return the current instance of the AssetsManager
  62989. */
  62990. reset(): AssetsManager;
  62991. /**
  62992. * Start the loading process
  62993. * @return the current instance of the AssetsManager
  62994. */
  62995. load(): AssetsManager;
  62996. /**
  62997. * Start the loading process as an async operation
  62998. * @return a promise returning the list of failed tasks
  62999. */
  63000. loadAsync(): Promise<void>;
  63001. }
  63002. }
  63003. declare module "babylonjs/Misc/deferred" {
  63004. /**
  63005. * Wrapper class for promise with external resolve and reject.
  63006. */
  63007. export class Deferred<T> {
  63008. /**
  63009. * The promise associated with this deferred object.
  63010. */
  63011. readonly promise: Promise<T>;
  63012. private _resolve;
  63013. private _reject;
  63014. /**
  63015. * The resolve method of the promise associated with this deferred object.
  63016. */
  63017. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63018. /**
  63019. * The reject method of the promise associated with this deferred object.
  63020. */
  63021. readonly reject: (reason?: any) => void;
  63022. /**
  63023. * Constructor for this deferred object.
  63024. */
  63025. constructor();
  63026. }
  63027. }
  63028. declare module "babylonjs/Misc/meshExploder" {
  63029. import { Mesh } from "babylonjs/Meshes/mesh";
  63030. /**
  63031. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63032. */
  63033. export class MeshExploder {
  63034. private _centerMesh;
  63035. private _meshes;
  63036. private _meshesOrigins;
  63037. private _toCenterVectors;
  63038. private _scaledDirection;
  63039. private _newPosition;
  63040. private _centerPosition;
  63041. /**
  63042. * Explodes meshes from a center mesh.
  63043. * @param meshes The meshes to explode.
  63044. * @param centerMesh The mesh to be center of explosion.
  63045. */
  63046. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63047. private _setCenterMesh;
  63048. /**
  63049. * Get class name
  63050. * @returns "MeshExploder"
  63051. */
  63052. getClassName(): string;
  63053. /**
  63054. * "Exploded meshes"
  63055. * @returns Array of meshes with the centerMesh at index 0.
  63056. */
  63057. getMeshes(): Array<Mesh>;
  63058. /**
  63059. * Explodes meshes giving a specific direction
  63060. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63061. */
  63062. explode(direction?: number): void;
  63063. }
  63064. }
  63065. declare module "babylonjs/Misc/filesInput" {
  63066. import { Engine } from "babylonjs/Engines/engine";
  63067. import { Scene } from "babylonjs/scene";
  63068. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63069. /**
  63070. * Class used to help managing file picking and drag'n'drop
  63071. */
  63072. export class FilesInput {
  63073. /**
  63074. * List of files ready to be loaded
  63075. */
  63076. static readonly FilesToLoad: {
  63077. [key: string]: File;
  63078. };
  63079. /**
  63080. * Callback called when a file is processed
  63081. */
  63082. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63083. private _engine;
  63084. private _currentScene;
  63085. private _sceneLoadedCallback;
  63086. private _progressCallback;
  63087. private _additionalRenderLoopLogicCallback;
  63088. private _textureLoadingCallback;
  63089. private _startingProcessingFilesCallback;
  63090. private _onReloadCallback;
  63091. private _errorCallback;
  63092. private _elementToMonitor;
  63093. private _sceneFileToLoad;
  63094. private _filesToLoad;
  63095. /**
  63096. * Creates a new FilesInput
  63097. * @param engine defines the rendering engine
  63098. * @param scene defines the hosting scene
  63099. * @param sceneLoadedCallback callback called when scene is loaded
  63100. * @param progressCallback callback called to track progress
  63101. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63102. * @param textureLoadingCallback callback called when a texture is loading
  63103. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63104. * @param onReloadCallback callback called when a reload is requested
  63105. * @param errorCallback callback call if an error occurs
  63106. */
  63107. 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);
  63108. private _dragEnterHandler;
  63109. private _dragOverHandler;
  63110. private _dropHandler;
  63111. /**
  63112. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63113. * @param elementToMonitor defines the DOM element to track
  63114. */
  63115. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63116. /**
  63117. * Release all associated resources
  63118. */
  63119. dispose(): void;
  63120. private renderFunction;
  63121. private drag;
  63122. private drop;
  63123. private _traverseFolder;
  63124. private _processFiles;
  63125. /**
  63126. * Load files from a drop event
  63127. * @param event defines the drop event to use as source
  63128. */
  63129. loadFiles(event: any): void;
  63130. private _processReload;
  63131. /**
  63132. * Reload the current scene from the loaded files
  63133. */
  63134. reload(): void;
  63135. }
  63136. }
  63137. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63138. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63139. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63140. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63141. }
  63142. declare module "babylonjs/Misc/sceneOptimizer" {
  63143. import { Scene, IDisposable } from "babylonjs/scene";
  63144. import { Observable } from "babylonjs/Misc/observable";
  63145. /**
  63146. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63148. */
  63149. export class SceneOptimization {
  63150. /**
  63151. * Defines the priority of this optimization (0 by default which means first in the list)
  63152. */
  63153. priority: number;
  63154. /**
  63155. * Gets a string describing the action executed by the current optimization
  63156. * @returns description string
  63157. */
  63158. getDescription(): string;
  63159. /**
  63160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63161. * @param scene defines the current scene where to apply this optimization
  63162. * @param optimizer defines the current optimizer
  63163. * @returns true if everything that can be done was applied
  63164. */
  63165. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63166. /**
  63167. * Creates the SceneOptimization object
  63168. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63169. * @param desc defines the description associated with the optimization
  63170. */
  63171. constructor(
  63172. /**
  63173. * Defines the priority of this optimization (0 by default which means first in the list)
  63174. */
  63175. priority?: number);
  63176. }
  63177. /**
  63178. * Defines an optimization used to reduce the size of render target textures
  63179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63180. */
  63181. export class TextureOptimization extends SceneOptimization {
  63182. /**
  63183. * Defines the priority of this optimization (0 by default which means first in the list)
  63184. */
  63185. priority: number;
  63186. /**
  63187. * 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
  63188. */
  63189. maximumSize: number;
  63190. /**
  63191. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63192. */
  63193. step: number;
  63194. /**
  63195. * Gets a string describing the action executed by the current optimization
  63196. * @returns description string
  63197. */
  63198. getDescription(): string;
  63199. /**
  63200. * Creates the TextureOptimization object
  63201. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63202. * @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
  63203. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63204. */
  63205. constructor(
  63206. /**
  63207. * Defines the priority of this optimization (0 by default which means first in the list)
  63208. */
  63209. priority?: number,
  63210. /**
  63211. * 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
  63212. */
  63213. maximumSize?: number,
  63214. /**
  63215. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63216. */
  63217. step?: number);
  63218. /**
  63219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63220. * @param scene defines the current scene where to apply this optimization
  63221. * @param optimizer defines the current optimizer
  63222. * @returns true if everything that can be done was applied
  63223. */
  63224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63225. }
  63226. /**
  63227. * Defines an optimization used to increase or decrease the rendering resolution
  63228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63229. */
  63230. export class HardwareScalingOptimization extends SceneOptimization {
  63231. /**
  63232. * Defines the priority of this optimization (0 by default which means first in the list)
  63233. */
  63234. priority: number;
  63235. /**
  63236. * Defines the maximum scale to use (2 by default)
  63237. */
  63238. maximumScale: number;
  63239. /**
  63240. * Defines the step to use between two passes (0.5 by default)
  63241. */
  63242. step: number;
  63243. private _currentScale;
  63244. private _directionOffset;
  63245. /**
  63246. * Gets a string describing the action executed by the current optimization
  63247. * @return description string
  63248. */
  63249. getDescription(): string;
  63250. /**
  63251. * Creates the HardwareScalingOptimization object
  63252. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63253. * @param maximumScale defines the maximum scale to use (2 by default)
  63254. * @param step defines the step to use between two passes (0.5 by default)
  63255. */
  63256. constructor(
  63257. /**
  63258. * Defines the priority of this optimization (0 by default which means first in the list)
  63259. */
  63260. priority?: number,
  63261. /**
  63262. * Defines the maximum scale to use (2 by default)
  63263. */
  63264. maximumScale?: number,
  63265. /**
  63266. * Defines the step to use between two passes (0.5 by default)
  63267. */
  63268. step?: number);
  63269. /**
  63270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63271. * @param scene defines the current scene where to apply this optimization
  63272. * @param optimizer defines the current optimizer
  63273. * @returns true if everything that can be done was applied
  63274. */
  63275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63276. }
  63277. /**
  63278. * Defines an optimization used to remove shadows
  63279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63280. */
  63281. export class ShadowsOptimization extends SceneOptimization {
  63282. /**
  63283. * Gets a string describing the action executed by the current optimization
  63284. * @return description string
  63285. */
  63286. getDescription(): string;
  63287. /**
  63288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63289. * @param scene defines the current scene where to apply this optimization
  63290. * @param optimizer defines the current optimizer
  63291. * @returns true if everything that can be done was applied
  63292. */
  63293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63294. }
  63295. /**
  63296. * Defines an optimization used to turn post-processes off
  63297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63298. */
  63299. export class PostProcessesOptimization extends SceneOptimization {
  63300. /**
  63301. * Gets a string describing the action executed by the current optimization
  63302. * @return description string
  63303. */
  63304. getDescription(): string;
  63305. /**
  63306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63307. * @param scene defines the current scene where to apply this optimization
  63308. * @param optimizer defines the current optimizer
  63309. * @returns true if everything that can be done was applied
  63310. */
  63311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63312. }
  63313. /**
  63314. * Defines an optimization used to turn lens flares off
  63315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63316. */
  63317. export class LensFlaresOptimization extends SceneOptimization {
  63318. /**
  63319. * Gets a string describing the action executed by the current optimization
  63320. * @return description string
  63321. */
  63322. getDescription(): string;
  63323. /**
  63324. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63325. * @param scene defines the current scene where to apply this optimization
  63326. * @param optimizer defines the current optimizer
  63327. * @returns true if everything that can be done was applied
  63328. */
  63329. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63330. }
  63331. /**
  63332. * Defines an optimization based on user defined callback.
  63333. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63334. */
  63335. export class CustomOptimization extends SceneOptimization {
  63336. /**
  63337. * Callback called to apply the custom optimization.
  63338. */
  63339. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63340. /**
  63341. * Callback called to get custom description
  63342. */
  63343. onGetDescription: () => string;
  63344. /**
  63345. * Gets a string describing the action executed by the current optimization
  63346. * @returns description string
  63347. */
  63348. getDescription(): string;
  63349. /**
  63350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63351. * @param scene defines the current scene where to apply this optimization
  63352. * @param optimizer defines the current optimizer
  63353. * @returns true if everything that can be done was applied
  63354. */
  63355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63356. }
  63357. /**
  63358. * Defines an optimization used to turn particles off
  63359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63360. */
  63361. export class ParticlesOptimization extends SceneOptimization {
  63362. /**
  63363. * Gets a string describing the action executed by the current optimization
  63364. * @return description string
  63365. */
  63366. getDescription(): string;
  63367. /**
  63368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63369. * @param scene defines the current scene where to apply this optimization
  63370. * @param optimizer defines the current optimizer
  63371. * @returns true if everything that can be done was applied
  63372. */
  63373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63374. }
  63375. /**
  63376. * Defines an optimization used to turn render targets off
  63377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63378. */
  63379. export class RenderTargetsOptimization extends SceneOptimization {
  63380. /**
  63381. * Gets a string describing the action executed by the current optimization
  63382. * @return description string
  63383. */
  63384. getDescription(): string;
  63385. /**
  63386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63387. * @param scene defines the current scene where to apply this optimization
  63388. * @param optimizer defines the current optimizer
  63389. * @returns true if everything that can be done was applied
  63390. */
  63391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63392. }
  63393. /**
  63394. * Defines an optimization used to merge meshes with compatible materials
  63395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63396. */
  63397. export class MergeMeshesOptimization extends SceneOptimization {
  63398. private static _UpdateSelectionTree;
  63399. /**
  63400. * Gets or sets a boolean which defines if optimization octree has to be updated
  63401. */
  63402. /**
  63403. * Gets or sets a boolean which defines if optimization octree has to be updated
  63404. */
  63405. static UpdateSelectionTree: boolean;
  63406. /**
  63407. * Gets a string describing the action executed by the current optimization
  63408. * @return description string
  63409. */
  63410. getDescription(): string;
  63411. private _canBeMerged;
  63412. /**
  63413. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63414. * @param scene defines the current scene where to apply this optimization
  63415. * @param optimizer defines the current optimizer
  63416. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63417. * @returns true if everything that can be done was applied
  63418. */
  63419. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63420. }
  63421. /**
  63422. * Defines a list of options used by SceneOptimizer
  63423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63424. */
  63425. export class SceneOptimizerOptions {
  63426. /**
  63427. * Defines the target frame rate to reach (60 by default)
  63428. */
  63429. targetFrameRate: number;
  63430. /**
  63431. * Defines the interval between two checkes (2000ms by default)
  63432. */
  63433. trackerDuration: number;
  63434. /**
  63435. * Gets the list of optimizations to apply
  63436. */
  63437. optimizations: SceneOptimization[];
  63438. /**
  63439. * Creates a new list of options used by SceneOptimizer
  63440. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63441. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63442. */
  63443. constructor(
  63444. /**
  63445. * Defines the target frame rate to reach (60 by default)
  63446. */
  63447. targetFrameRate?: number,
  63448. /**
  63449. * Defines the interval between two checkes (2000ms by default)
  63450. */
  63451. trackerDuration?: number);
  63452. /**
  63453. * Add a new optimization
  63454. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63455. * @returns the current SceneOptimizerOptions
  63456. */
  63457. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63458. /**
  63459. * Add a new custom optimization
  63460. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63461. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63462. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63463. * @returns the current SceneOptimizerOptions
  63464. */
  63465. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63466. /**
  63467. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63468. * @param targetFrameRate defines the target frame rate (60 by default)
  63469. * @returns a SceneOptimizerOptions object
  63470. */
  63471. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63472. /**
  63473. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63474. * @param targetFrameRate defines the target frame rate (60 by default)
  63475. * @returns a SceneOptimizerOptions object
  63476. */
  63477. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63478. /**
  63479. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63480. * @param targetFrameRate defines the target frame rate (60 by default)
  63481. * @returns a SceneOptimizerOptions object
  63482. */
  63483. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63484. }
  63485. /**
  63486. * Class used to run optimizations in order to reach a target frame rate
  63487. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63488. */
  63489. export class SceneOptimizer implements IDisposable {
  63490. private _isRunning;
  63491. private _options;
  63492. private _scene;
  63493. private _currentPriorityLevel;
  63494. private _targetFrameRate;
  63495. private _trackerDuration;
  63496. private _currentFrameRate;
  63497. private _sceneDisposeObserver;
  63498. private _improvementMode;
  63499. /**
  63500. * Defines an observable called when the optimizer reaches the target frame rate
  63501. */
  63502. onSuccessObservable: Observable<SceneOptimizer>;
  63503. /**
  63504. * Defines an observable called when the optimizer enables an optimization
  63505. */
  63506. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63507. /**
  63508. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63509. */
  63510. onFailureObservable: Observable<SceneOptimizer>;
  63511. /**
  63512. * Gets a boolean indicating if the optimizer is in improvement mode
  63513. */
  63514. readonly isInImprovementMode: boolean;
  63515. /**
  63516. * Gets the current priority level (0 at start)
  63517. */
  63518. readonly currentPriorityLevel: number;
  63519. /**
  63520. * Gets the current frame rate checked by the SceneOptimizer
  63521. */
  63522. readonly currentFrameRate: number;
  63523. /**
  63524. * Gets or sets the current target frame rate (60 by default)
  63525. */
  63526. /**
  63527. * Gets or sets the current target frame rate (60 by default)
  63528. */
  63529. targetFrameRate: number;
  63530. /**
  63531. * Gets or sets the current interval between two checks (every 2000ms by default)
  63532. */
  63533. /**
  63534. * Gets or sets the current interval between two checks (every 2000ms by default)
  63535. */
  63536. trackerDuration: number;
  63537. /**
  63538. * Gets the list of active optimizations
  63539. */
  63540. readonly optimizations: SceneOptimization[];
  63541. /**
  63542. * Creates a new SceneOptimizer
  63543. * @param scene defines the scene to work on
  63544. * @param options defines the options to use with the SceneOptimizer
  63545. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63546. * @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)
  63547. */
  63548. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63549. /**
  63550. * Stops the current optimizer
  63551. */
  63552. stop(): void;
  63553. /**
  63554. * Reset the optimizer to initial step (current priority level = 0)
  63555. */
  63556. reset(): void;
  63557. /**
  63558. * Start the optimizer. By default it will try to reach a specific framerate
  63559. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63560. */
  63561. start(): void;
  63562. private _checkCurrentState;
  63563. /**
  63564. * Release all resources
  63565. */
  63566. dispose(): void;
  63567. /**
  63568. * Helper function to create a SceneOptimizer with one single line of code
  63569. * @param scene defines the scene to work on
  63570. * @param options defines the options to use with the SceneOptimizer
  63571. * @param onSuccess defines a callback to call on success
  63572. * @param onFailure defines a callback to call on failure
  63573. * @returns the new SceneOptimizer object
  63574. */
  63575. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63576. }
  63577. }
  63578. declare module "babylonjs/Misc/sceneSerializer" {
  63579. import { Scene } from "babylonjs/scene";
  63580. /**
  63581. * Class used to serialize a scene into a string
  63582. */
  63583. export class SceneSerializer {
  63584. /**
  63585. * Clear cache used by a previous serialization
  63586. */
  63587. static ClearCache(): void;
  63588. /**
  63589. * Serialize a scene into a JSON compatible object
  63590. * @param scene defines the scene to serialize
  63591. * @returns a JSON compatible object
  63592. */
  63593. static Serialize(scene: Scene): any;
  63594. /**
  63595. * Serialize a mesh into a JSON compatible object
  63596. * @param toSerialize defines the mesh to serialize
  63597. * @param withParents defines if parents must be serialized as well
  63598. * @param withChildren defines if children must be serialized as well
  63599. * @returns a JSON compatible object
  63600. */
  63601. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63602. }
  63603. }
  63604. declare module "babylonjs/Misc/textureTools" {
  63605. import { Texture } from "babylonjs/Materials/Textures/texture";
  63606. /**
  63607. * Class used to host texture specific utilities
  63608. */
  63609. export class TextureTools {
  63610. /**
  63611. * Uses the GPU to create a copy texture rescaled at a given size
  63612. * @param texture Texture to copy from
  63613. * @param width defines the desired width
  63614. * @param height defines the desired height
  63615. * @param useBilinearMode defines if bilinear mode has to be used
  63616. * @return the generated texture
  63617. */
  63618. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63619. }
  63620. }
  63621. declare module "babylonjs/Misc/videoRecorder" {
  63622. import { Nullable } from "babylonjs/types";
  63623. import { Engine } from "babylonjs/Engines/engine";
  63624. /**
  63625. * This represents the different options available for the video capture.
  63626. */
  63627. export interface VideoRecorderOptions {
  63628. /** Defines the mime type of the video. */
  63629. mimeType: string;
  63630. /** Defines the FPS the video should be recorded at. */
  63631. fps: number;
  63632. /** Defines the chunk size for the recording data. */
  63633. recordChunckSize: number;
  63634. /** The audio tracks to attach to the recording. */
  63635. audioTracks?: MediaStreamTrack[];
  63636. }
  63637. /**
  63638. * This can help with recording videos from BabylonJS.
  63639. * This is based on the available WebRTC functionalities of the browser.
  63640. *
  63641. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63642. */
  63643. export class VideoRecorder {
  63644. private static readonly _defaultOptions;
  63645. /**
  63646. * Returns whether or not the VideoRecorder is available in your browser.
  63647. * @param engine Defines the Babylon Engine.
  63648. * @returns true if supported otherwise false.
  63649. */
  63650. static IsSupported(engine: Engine): boolean;
  63651. private readonly _options;
  63652. private _canvas;
  63653. private _mediaRecorder;
  63654. private _recordedChunks;
  63655. private _fileName;
  63656. private _resolve;
  63657. private _reject;
  63658. /**
  63659. * True when a recording is already in progress.
  63660. */
  63661. readonly isRecording: boolean;
  63662. /**
  63663. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63664. * @param engine Defines the BabylonJS Engine you wish to record.
  63665. * @param options Defines options that can be used to customize the capture.
  63666. */
  63667. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63668. /**
  63669. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63670. */
  63671. stopRecording(): void;
  63672. /**
  63673. * Starts recording the canvas for a max duration specified in parameters.
  63674. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63675. * If null no automatic download will start and you can rely on the promise to get the data back.
  63676. * @param maxDuration Defines the maximum recording time in seconds.
  63677. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63678. * @return A promise callback at the end of the recording with the video data in Blob.
  63679. */
  63680. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63681. /**
  63682. * Releases internal resources used during the recording.
  63683. */
  63684. dispose(): void;
  63685. private _handleDataAvailable;
  63686. private _handleError;
  63687. private _handleStop;
  63688. }
  63689. }
  63690. declare module "babylonjs/Misc/screenshotTools" {
  63691. import { Camera } from "babylonjs/Cameras/camera";
  63692. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  63693. import { Engine } from "babylonjs/Engines/engine";
  63694. /**
  63695. * Class containing a set of static utilities functions for screenshots
  63696. */
  63697. export class ScreenshotTools {
  63698. /**
  63699. * Captures a screenshot of the current rendering
  63700. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63701. * @param engine defines the rendering engine
  63702. * @param camera defines the source camera
  63703. * @param size This parameter can be set to a single number or to an object with the
  63704. * following (optional) properties: precision, width, height. If a single number is passed,
  63705. * it will be used for both width and height. If an object is passed, the screenshot size
  63706. * will be derived from the parameters. The precision property is a multiplier allowing
  63707. * rendering at a higher or lower resolution
  63708. * @param successCallback defines the callback receives a single parameter which contains the
  63709. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63710. * src parameter of an <img> to display it
  63711. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63712. * Check your browser for supported MIME types
  63713. */
  63714. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63715. /**
  63716. * Captures a screenshot of the current rendering
  63717. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63718. * @param engine defines the rendering engine
  63719. * @param camera defines the source camera
  63720. * @param size This parameter can be set to a single number or to an object with the
  63721. * following (optional) properties: precision, width, height. If a single number is passed,
  63722. * it will be used for both width and height. If an object is passed, the screenshot size
  63723. * will be derived from the parameters. The precision property is a multiplier allowing
  63724. * rendering at a higher or lower resolution
  63725. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63726. * Check your browser for supported MIME types
  63727. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63728. * to the src parameter of an <img> to display it
  63729. */
  63730. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63731. /**
  63732. * Generates an image screenshot from the specified camera.
  63733. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63734. * @param engine The engine to use for rendering
  63735. * @param camera The camera to use for rendering
  63736. * @param size This parameter can be set to a single number or to an object with the
  63737. * following (optional) properties: precision, width, height. If a single number is passed,
  63738. * it will be used for both width and height. If an object is passed, the screenshot size
  63739. * will be derived from the parameters. The precision property is a multiplier allowing
  63740. * rendering at a higher or lower resolution
  63741. * @param successCallback The callback receives a single parameter which contains the
  63742. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63743. * src parameter of an <img> to display it
  63744. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63745. * Check your browser for supported MIME types
  63746. * @param samples Texture samples (default: 1)
  63747. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63748. * @param fileName A name for for the downloaded file.
  63749. */
  63750. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63751. /**
  63752. * Generates an image screenshot from the specified camera.
  63753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63754. * @param engine The engine to use for rendering
  63755. * @param camera The camera to use for rendering
  63756. * @param size This parameter can be set to a single number or to an object with the
  63757. * following (optional) properties: precision, width, height. If a single number is passed,
  63758. * it will be used for both width and height. If an object is passed, the screenshot size
  63759. * will be derived from the parameters. The precision property is a multiplier allowing
  63760. * rendering at a higher or lower resolution
  63761. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63762. * Check your browser for supported MIME types
  63763. * @param samples Texture samples (default: 1)
  63764. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63765. * @param fileName A name for for the downloaded file.
  63766. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63767. * to the src parameter of an <img> to display it
  63768. */
  63769. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63770. /**
  63771. * Gets height and width for screenshot size
  63772. * @private
  63773. */
  63774. private static _getScreenshotSize;
  63775. }
  63776. }
  63777. declare module "babylonjs/Misc/index" {
  63778. export * from "babylonjs/Misc/andOrNotEvaluator";
  63779. export * from "babylonjs/Misc/assetsManager";
  63780. export * from "babylonjs/Misc/dds";
  63781. export * from "babylonjs/Misc/decorators";
  63782. export * from "babylonjs/Misc/deferred";
  63783. export * from "babylonjs/Misc/environmentTextureTools";
  63784. export * from "babylonjs/Misc/meshExploder";
  63785. export * from "babylonjs/Misc/filesInput";
  63786. export * from "babylonjs/Misc/HighDynamicRange/index";
  63787. export * from "babylonjs/Misc/khronosTextureContainer";
  63788. export * from "babylonjs/Misc/observable";
  63789. export * from "babylonjs/Misc/performanceMonitor";
  63790. export * from "babylonjs/Misc/promise";
  63791. export * from "babylonjs/Misc/sceneOptimizer";
  63792. export * from "babylonjs/Misc/sceneSerializer";
  63793. export * from "babylonjs/Misc/smartArray";
  63794. export * from "babylonjs/Misc/stringDictionary";
  63795. export * from "babylonjs/Misc/tags";
  63796. export * from "babylonjs/Misc/textureTools";
  63797. export * from "babylonjs/Misc/tga";
  63798. export * from "babylonjs/Misc/tools";
  63799. export * from "babylonjs/Misc/videoRecorder";
  63800. export * from "babylonjs/Misc/virtualJoystick";
  63801. export * from "babylonjs/Misc/workerPool";
  63802. export * from "babylonjs/Misc/logger";
  63803. export * from "babylonjs/Misc/typeStore";
  63804. export * from "babylonjs/Misc/filesInputStore";
  63805. export * from "babylonjs/Misc/deepCopier";
  63806. export * from "babylonjs/Misc/pivotTools";
  63807. export * from "babylonjs/Misc/precisionDate";
  63808. export * from "babylonjs/Misc/screenshotTools";
  63809. export * from "babylonjs/Misc/typeStore";
  63810. export * from "babylonjs/Misc/webRequest";
  63811. export * from "babylonjs/Misc/iInspectable";
  63812. export * from "babylonjs/Misc/brdfTextureTools";
  63813. export * from "babylonjs/Misc/gradients";
  63814. export * from "babylonjs/Misc/perfCounter";
  63815. export * from "babylonjs/Misc/fileRequest";
  63816. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63817. export * from "babylonjs/Misc/retryStrategy";
  63818. export * from "babylonjs/Misc/loadFileError";
  63819. }
  63820. declare module "babylonjs/index" {
  63821. export * from "babylonjs/abstractScene";
  63822. export * from "babylonjs/Actions/index";
  63823. export * from "babylonjs/Animations/index";
  63824. export * from "babylonjs/assetContainer";
  63825. export * from "babylonjs/Audio/index";
  63826. export * from "babylonjs/Behaviors/index";
  63827. export * from "babylonjs/Bones/index";
  63828. export * from "babylonjs/Cameras/index";
  63829. export * from "babylonjs/Collisions/index";
  63830. export * from "babylonjs/Culling/index";
  63831. export * from "babylonjs/Debug/index";
  63832. export * from "babylonjs/Engines/index";
  63833. export * from "babylonjs/Events/index";
  63834. export * from "babylonjs/Gamepads/index";
  63835. export * from "babylonjs/Gizmos/index";
  63836. export * from "babylonjs/Helpers/index";
  63837. export * from "babylonjs/Instrumentation/index";
  63838. export * from "babylonjs/Layers/index";
  63839. export * from "babylonjs/LensFlares/index";
  63840. export * from "babylonjs/Lights/index";
  63841. export * from "babylonjs/Loading/index";
  63842. export * from "babylonjs/Materials/index";
  63843. export * from "babylonjs/Maths/index";
  63844. export * from "babylonjs/Meshes/index";
  63845. export * from "babylonjs/Morph/index";
  63846. export * from "babylonjs/Navigation/index";
  63847. export * from "babylonjs/node";
  63848. export * from "babylonjs/Offline/index";
  63849. export * from "babylonjs/Particles/index";
  63850. export * from "babylonjs/Physics/index";
  63851. export * from "babylonjs/PostProcesses/index";
  63852. export * from "babylonjs/Probes/index";
  63853. export * from "babylonjs/Rendering/index";
  63854. export * from "babylonjs/scene";
  63855. export * from "babylonjs/sceneComponent";
  63856. export * from "babylonjs/Sprites/index";
  63857. export * from "babylonjs/States/index";
  63858. export * from "babylonjs/Misc/index";
  63859. export * from "babylonjs/types";
  63860. }
  63861. declare module "babylonjs/Animations/pathCursor" {
  63862. import { Vector3 } from "babylonjs/Maths/math.vector";
  63863. import { Path2 } from "babylonjs/Maths/math.path";
  63864. /**
  63865. * A cursor which tracks a point on a path
  63866. */
  63867. export class PathCursor {
  63868. private path;
  63869. /**
  63870. * Stores path cursor callbacks for when an onchange event is triggered
  63871. */
  63872. private _onchange;
  63873. /**
  63874. * The value of the path cursor
  63875. */
  63876. value: number;
  63877. /**
  63878. * The animation array of the path cursor
  63879. */
  63880. animations: Animation[];
  63881. /**
  63882. * Initializes the path cursor
  63883. * @param path The path to track
  63884. */
  63885. constructor(path: Path2);
  63886. /**
  63887. * Gets the cursor point on the path
  63888. * @returns A point on the path cursor at the cursor location
  63889. */
  63890. getPoint(): Vector3;
  63891. /**
  63892. * Moves the cursor ahead by the step amount
  63893. * @param step The amount to move the cursor forward
  63894. * @returns This path cursor
  63895. */
  63896. moveAhead(step?: number): PathCursor;
  63897. /**
  63898. * Moves the cursor behind by the step amount
  63899. * @param step The amount to move the cursor back
  63900. * @returns This path cursor
  63901. */
  63902. moveBack(step?: number): PathCursor;
  63903. /**
  63904. * Moves the cursor by the step amount
  63905. * If the step amount is greater than one, an exception is thrown
  63906. * @param step The amount to move the cursor
  63907. * @returns This path cursor
  63908. */
  63909. move(step: number): PathCursor;
  63910. /**
  63911. * Ensures that the value is limited between zero and one
  63912. * @returns This path cursor
  63913. */
  63914. private ensureLimits;
  63915. /**
  63916. * Runs onchange callbacks on change (used by the animation engine)
  63917. * @returns This path cursor
  63918. */
  63919. private raiseOnChange;
  63920. /**
  63921. * Executes a function on change
  63922. * @param f A path cursor onchange callback
  63923. * @returns This path cursor
  63924. */
  63925. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63926. }
  63927. }
  63928. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63929. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63930. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63931. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63932. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63933. }
  63934. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63935. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63936. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63937. }
  63938. declare module "babylonjs/Engines/Processors/index" {
  63939. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63940. export * from "babylonjs/Engines/Processors/Expressions/index";
  63941. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63942. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63943. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63944. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63945. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63946. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63947. }
  63948. declare module "babylonjs/Legacy/legacy" {
  63949. import * as Babylon from "babylonjs/index";
  63950. export * from "babylonjs/index";
  63951. }
  63952. declare module "babylonjs/Shaders/blur.fragment" {
  63953. /** @hidden */
  63954. export var blurPixelShader: {
  63955. name: string;
  63956. shader: string;
  63957. };
  63958. }
  63959. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63960. /** @hidden */
  63961. export var pointCloudVertexDeclaration: {
  63962. name: string;
  63963. shader: string;
  63964. };
  63965. }
  63966. declare module "babylonjs" {
  63967. export * from "babylonjs/Legacy/legacy";
  63968. }
  63969. declare module BABYLON {
  63970. /** Alias type for value that can be null */
  63971. export type Nullable<T> = T | null;
  63972. /**
  63973. * Alias type for number that are floats
  63974. * @ignorenaming
  63975. */
  63976. export type float = number;
  63977. /**
  63978. * Alias type for number that are doubles.
  63979. * @ignorenaming
  63980. */
  63981. export type double = number;
  63982. /**
  63983. * Alias type for number that are integer
  63984. * @ignorenaming
  63985. */
  63986. export type int = number;
  63987. /** Alias type for number array or Float32Array */
  63988. export type FloatArray = number[] | Float32Array;
  63989. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63990. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63991. /**
  63992. * Alias for types that can be used by a Buffer or VertexBuffer.
  63993. */
  63994. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63995. /**
  63996. * Alias type for primitive types
  63997. * @ignorenaming
  63998. */
  63999. type Primitive = undefined | null | boolean | string | number | Function;
  64000. /**
  64001. * Type modifier to make all the properties of an object Readonly
  64002. */
  64003. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64004. /**
  64005. * Type modifier to make all the properties of an object Readonly recursively
  64006. */
  64007. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64008. /** @hidden */
  64009. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64010. }
  64011. /** @hidden */
  64012. /** @hidden */
  64013. type DeepImmutableObject<T> = {
  64014. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64015. };
  64016. }
  64017. declare module BABYLON {
  64018. /**
  64019. * A class serves as a medium between the observable and its observers
  64020. */
  64021. export class EventState {
  64022. /**
  64023. * Create a new EventState
  64024. * @param mask defines the mask associated with this state
  64025. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64026. * @param target defines the original target of the state
  64027. * @param currentTarget defines the current target of the state
  64028. */
  64029. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64030. /**
  64031. * Initialize the current event state
  64032. * @param mask defines the mask associated with this state
  64033. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64034. * @param target defines the original target of the state
  64035. * @param currentTarget defines the current target of the state
  64036. * @returns the current event state
  64037. */
  64038. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64039. /**
  64040. * An Observer can set this property to true to prevent subsequent observers of being notified
  64041. */
  64042. skipNextObservers: boolean;
  64043. /**
  64044. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64045. */
  64046. mask: number;
  64047. /**
  64048. * The object that originally notified the event
  64049. */
  64050. target?: any;
  64051. /**
  64052. * The current object in the bubbling phase
  64053. */
  64054. currentTarget?: any;
  64055. /**
  64056. * This will be populated with the return value of the last function that was executed.
  64057. * If it is the first function in the callback chain it will be the event data.
  64058. */
  64059. lastReturnValue?: any;
  64060. }
  64061. /**
  64062. * Represent an Observer registered to a given Observable object.
  64063. */
  64064. export class Observer<T> {
  64065. /**
  64066. * Defines the callback to call when the observer is notified
  64067. */
  64068. callback: (eventData: T, eventState: EventState) => void;
  64069. /**
  64070. * Defines the mask of the observer (used to filter notifications)
  64071. */
  64072. mask: number;
  64073. /**
  64074. * Defines the current scope used to restore the JS context
  64075. */
  64076. scope: any;
  64077. /** @hidden */
  64078. _willBeUnregistered: boolean;
  64079. /**
  64080. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64081. */
  64082. unregisterOnNextCall: boolean;
  64083. /**
  64084. * Creates a new observer
  64085. * @param callback defines the callback to call when the observer is notified
  64086. * @param mask defines the mask of the observer (used to filter notifications)
  64087. * @param scope defines the current scope used to restore the JS context
  64088. */
  64089. constructor(
  64090. /**
  64091. * Defines the callback to call when the observer is notified
  64092. */
  64093. callback: (eventData: T, eventState: EventState) => void,
  64094. /**
  64095. * Defines the mask of the observer (used to filter notifications)
  64096. */
  64097. mask: number,
  64098. /**
  64099. * Defines the current scope used to restore the JS context
  64100. */
  64101. scope?: any);
  64102. }
  64103. /**
  64104. * Represent a list of observers registered to multiple Observables object.
  64105. */
  64106. export class MultiObserver<T> {
  64107. private _observers;
  64108. private _observables;
  64109. /**
  64110. * Release associated resources
  64111. */
  64112. dispose(): void;
  64113. /**
  64114. * Raise a callback when one of the observable will notify
  64115. * @param observables defines a list of observables to watch
  64116. * @param callback defines the callback to call on notification
  64117. * @param mask defines the mask used to filter notifications
  64118. * @param scope defines the current scope used to restore the JS context
  64119. * @returns the new MultiObserver
  64120. */
  64121. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64122. }
  64123. /**
  64124. * The Observable class is a simple implementation of the Observable pattern.
  64125. *
  64126. * 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.
  64127. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64128. * 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).
  64129. * 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.
  64130. */
  64131. export class Observable<T> {
  64132. private _observers;
  64133. private _eventState;
  64134. private _onObserverAdded;
  64135. /**
  64136. * Gets the list of observers
  64137. */
  64138. readonly observers: Array<Observer<T>>;
  64139. /**
  64140. * Creates a new observable
  64141. * @param onObserverAdded defines a callback to call when a new observer is added
  64142. */
  64143. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64144. /**
  64145. * Create a new Observer with the specified callback
  64146. * @param callback the callback that will be executed for that Observer
  64147. * @param mask the mask used to filter observers
  64148. * @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.
  64149. * @param scope optional scope for the callback to be called from
  64150. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64151. * @returns the new observer created for the callback
  64152. */
  64153. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64154. /**
  64155. * Create a new Observer with the specified callback and unregisters after the next notification
  64156. * @param callback the callback that will be executed for that Observer
  64157. * @returns the new observer created for the callback
  64158. */
  64159. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64160. /**
  64161. * Remove an Observer from the Observable object
  64162. * @param observer the instance of the Observer to remove
  64163. * @returns false if it doesn't belong to this Observable
  64164. */
  64165. remove(observer: Nullable<Observer<T>>): boolean;
  64166. /**
  64167. * Remove a callback from the Observable object
  64168. * @param callback the callback to remove
  64169. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64170. * @returns false if it doesn't belong to this Observable
  64171. */
  64172. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64173. private _deferUnregister;
  64174. private _remove;
  64175. /**
  64176. * Moves the observable to the top of the observer list making it get called first when notified
  64177. * @param observer the observer to move
  64178. */
  64179. makeObserverTopPriority(observer: Observer<T>): void;
  64180. /**
  64181. * Moves the observable to the bottom of the observer list making it get called last when notified
  64182. * @param observer the observer to move
  64183. */
  64184. makeObserverBottomPriority(observer: Observer<T>): void;
  64185. /**
  64186. * Notify all Observers by calling their respective callback with the given data
  64187. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64188. * @param eventData defines the data to send to all observers
  64189. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64190. * @param target defines the original target of the state
  64191. * @param currentTarget defines the current target of the state
  64192. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64193. */
  64194. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64195. /**
  64196. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64197. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64198. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64199. * and it is crucial that all callbacks will be executed.
  64200. * The order of the callbacks is kept, callbacks are not executed parallel.
  64201. *
  64202. * @param eventData The data to be sent to each callback
  64203. * @param mask is used to filter observers defaults to -1
  64204. * @param target defines the callback target (see EventState)
  64205. * @param currentTarget defines he current object in the bubbling phase
  64206. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64207. */
  64208. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64209. /**
  64210. * Notify a specific observer
  64211. * @param observer defines the observer to notify
  64212. * @param eventData defines the data to be sent to each callback
  64213. * @param mask is used to filter observers defaults to -1
  64214. */
  64215. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64216. /**
  64217. * Gets a boolean indicating if the observable has at least one observer
  64218. * @returns true is the Observable has at least one Observer registered
  64219. */
  64220. hasObservers(): boolean;
  64221. /**
  64222. * Clear the list of observers
  64223. */
  64224. clear(): void;
  64225. /**
  64226. * Clone the current observable
  64227. * @returns a new observable
  64228. */
  64229. clone(): Observable<T>;
  64230. /**
  64231. * Does this observable handles observer registered with a given mask
  64232. * @param mask defines the mask to be tested
  64233. * @return whether or not one observer registered with the given mask is handeled
  64234. **/
  64235. hasSpecificMask(mask?: number): boolean;
  64236. }
  64237. }
  64238. declare module BABYLON {
  64239. /**
  64240. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64241. * Babylon.js
  64242. */
  64243. export class DomManagement {
  64244. /**
  64245. * Checks if the window object exists
  64246. * @returns true if the window object exists
  64247. */
  64248. static IsWindowObjectExist(): boolean;
  64249. /**
  64250. * Extracts text content from a DOM element hierarchy
  64251. * @param element defines the root element
  64252. * @returns a string
  64253. */
  64254. static GetDOMTextContent(element: HTMLElement): string;
  64255. }
  64256. }
  64257. declare module BABYLON {
  64258. /**
  64259. * Logger used througouht the application to allow configuration of
  64260. * the log level required for the messages.
  64261. */
  64262. export class Logger {
  64263. /**
  64264. * No log
  64265. */
  64266. static readonly NoneLogLevel: number;
  64267. /**
  64268. * Only message logs
  64269. */
  64270. static readonly MessageLogLevel: number;
  64271. /**
  64272. * Only warning logs
  64273. */
  64274. static readonly WarningLogLevel: number;
  64275. /**
  64276. * Only error logs
  64277. */
  64278. static readonly ErrorLogLevel: number;
  64279. /**
  64280. * All logs
  64281. */
  64282. static readonly AllLogLevel: number;
  64283. private static _LogCache;
  64284. /**
  64285. * Gets a value indicating the number of loading errors
  64286. * @ignorenaming
  64287. */
  64288. static errorsCount: number;
  64289. /**
  64290. * Callback called when a new log is added
  64291. */
  64292. static OnNewCacheEntry: (entry: string) => void;
  64293. private static _AddLogEntry;
  64294. private static _FormatMessage;
  64295. private static _LogDisabled;
  64296. private static _LogEnabled;
  64297. private static _WarnDisabled;
  64298. private static _WarnEnabled;
  64299. private static _ErrorDisabled;
  64300. private static _ErrorEnabled;
  64301. /**
  64302. * Log a message to the console
  64303. */
  64304. static Log: (message: string) => void;
  64305. /**
  64306. * Write a warning message to the console
  64307. */
  64308. static Warn: (message: string) => void;
  64309. /**
  64310. * Write an error message to the console
  64311. */
  64312. static Error: (message: string) => void;
  64313. /**
  64314. * Gets current log cache (list of logs)
  64315. */
  64316. static readonly LogCache: string;
  64317. /**
  64318. * Clears the log cache
  64319. */
  64320. static ClearLogCache(): void;
  64321. /**
  64322. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64323. */
  64324. static LogLevels: number;
  64325. }
  64326. }
  64327. declare module BABYLON {
  64328. /** @hidden */
  64329. export class _TypeStore {
  64330. /** @hidden */
  64331. static RegisteredTypes: {
  64332. [key: string]: Object;
  64333. };
  64334. /** @hidden */
  64335. static GetClass(fqdn: string): any;
  64336. }
  64337. }
  64338. declare module BABYLON {
  64339. /**
  64340. * Class containing a set of static utilities functions for deep copy.
  64341. */
  64342. export class DeepCopier {
  64343. /**
  64344. * Tries to copy an object by duplicating every property
  64345. * @param source defines the source object
  64346. * @param destination defines the target object
  64347. * @param doNotCopyList defines a list of properties to avoid
  64348. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64349. */
  64350. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64351. }
  64352. }
  64353. declare module BABYLON {
  64354. /**
  64355. * Class containing a set of static utilities functions for precision date
  64356. */
  64357. export class PrecisionDate {
  64358. /**
  64359. * Gets either window.performance.now() if supported or Date.now() else
  64360. */
  64361. static readonly Now: number;
  64362. }
  64363. }
  64364. declare module BABYLON {
  64365. /** @hidden */
  64366. export class _DevTools {
  64367. static WarnImport(name: string): string;
  64368. }
  64369. }
  64370. declare module BABYLON {
  64371. /**
  64372. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64373. */
  64374. export class WebRequest {
  64375. private _xhr;
  64376. /**
  64377. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64378. * i.e. when loading files, where the server/service expects an Authorization header
  64379. */
  64380. static CustomRequestHeaders: {
  64381. [key: string]: string;
  64382. };
  64383. /**
  64384. * Add callback functions in this array to update all the requests before they get sent to the network
  64385. */
  64386. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64387. private _injectCustomRequestHeaders;
  64388. /**
  64389. * Gets or sets a function to be called when loading progress changes
  64390. */
  64391. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64392. /**
  64393. * Returns client's state
  64394. */
  64395. readonly readyState: number;
  64396. /**
  64397. * Returns client's status
  64398. */
  64399. readonly status: number;
  64400. /**
  64401. * Returns client's status as a text
  64402. */
  64403. readonly statusText: string;
  64404. /**
  64405. * Returns client's response
  64406. */
  64407. readonly response: any;
  64408. /**
  64409. * Returns client's response url
  64410. */
  64411. readonly responseURL: string;
  64412. /**
  64413. * Returns client's response as text
  64414. */
  64415. readonly responseText: string;
  64416. /**
  64417. * Gets or sets the expected response type
  64418. */
  64419. responseType: XMLHttpRequestResponseType;
  64420. /** @hidden */
  64421. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64422. /** @hidden */
  64423. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64424. /**
  64425. * Cancels any network activity
  64426. */
  64427. abort(): void;
  64428. /**
  64429. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64430. * @param body defines an optional request body
  64431. */
  64432. send(body?: Document | BodyInit | null): void;
  64433. /**
  64434. * Sets the request method, request URL
  64435. * @param method defines the method to use (GET, POST, etc..)
  64436. * @param url defines the url to connect with
  64437. */
  64438. open(method: string, url: string): void;
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /**
  64443. * File request interface
  64444. */
  64445. export interface IFileRequest {
  64446. /**
  64447. * Raised when the request is complete (success or error).
  64448. */
  64449. onCompleteObservable: Observable<IFileRequest>;
  64450. /**
  64451. * Aborts the request for a file.
  64452. */
  64453. abort: () => void;
  64454. }
  64455. }
  64456. declare module BABYLON {
  64457. /**
  64458. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64459. */
  64460. export class PerformanceMonitor {
  64461. private _enabled;
  64462. private _rollingFrameTime;
  64463. private _lastFrameTimeMs;
  64464. /**
  64465. * constructor
  64466. * @param frameSampleSize The number of samples required to saturate the sliding window
  64467. */
  64468. constructor(frameSampleSize?: number);
  64469. /**
  64470. * Samples current frame
  64471. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64472. */
  64473. sampleFrame(timeMs?: number): void;
  64474. /**
  64475. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64476. */
  64477. readonly averageFrameTime: number;
  64478. /**
  64479. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64480. */
  64481. readonly averageFrameTimeVariance: number;
  64482. /**
  64483. * Returns the frame time of the most recent frame
  64484. */
  64485. readonly instantaneousFrameTime: number;
  64486. /**
  64487. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64488. */
  64489. readonly averageFPS: number;
  64490. /**
  64491. * Returns the average framerate in frames per second using the most recent frame time
  64492. */
  64493. readonly instantaneousFPS: number;
  64494. /**
  64495. * Returns true if enough samples have been taken to completely fill the sliding window
  64496. */
  64497. readonly isSaturated: boolean;
  64498. /**
  64499. * Enables contributions to the sliding window sample set
  64500. */
  64501. enable(): void;
  64502. /**
  64503. * Disables contributions to the sliding window sample set
  64504. * Samples will not be interpolated over the disabled period
  64505. */
  64506. disable(): void;
  64507. /**
  64508. * Returns true if sampling is enabled
  64509. */
  64510. readonly isEnabled: boolean;
  64511. /**
  64512. * Resets performance monitor
  64513. */
  64514. reset(): void;
  64515. }
  64516. /**
  64517. * RollingAverage
  64518. *
  64519. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64520. */
  64521. export class RollingAverage {
  64522. /**
  64523. * Current average
  64524. */
  64525. average: number;
  64526. /**
  64527. * Current variance
  64528. */
  64529. variance: number;
  64530. protected _samples: Array<number>;
  64531. protected _sampleCount: number;
  64532. protected _pos: number;
  64533. protected _m2: number;
  64534. /**
  64535. * constructor
  64536. * @param length The number of samples required to saturate the sliding window
  64537. */
  64538. constructor(length: number);
  64539. /**
  64540. * Adds a sample to the sample set
  64541. * @param v The sample value
  64542. */
  64543. add(v: number): void;
  64544. /**
  64545. * Returns previously added values or null if outside of history or outside the sliding window domain
  64546. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64547. * @return Value previously recorded with add() or null if outside of range
  64548. */
  64549. history(i: number): number;
  64550. /**
  64551. * Returns true if enough samples have been taken to completely fill the sliding window
  64552. * @return true if sample-set saturated
  64553. */
  64554. isSaturated(): boolean;
  64555. /**
  64556. * Resets the rolling average (equivalent to 0 samples taken so far)
  64557. */
  64558. reset(): void;
  64559. /**
  64560. * Wraps a value around the sample range boundaries
  64561. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64562. * @return Wrapped position in sample range
  64563. */
  64564. protected _wrapPosition(i: number): number;
  64565. }
  64566. }
  64567. declare module BABYLON {
  64568. /**
  64569. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64570. * The underlying implementation relies on an associative array to ensure the best performances.
  64571. * The value can be anything including 'null' but except 'undefined'
  64572. */
  64573. export class StringDictionary<T> {
  64574. /**
  64575. * This will clear this dictionary and copy the content from the 'source' one.
  64576. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64577. * @param source the dictionary to take the content from and copy to this dictionary
  64578. */
  64579. copyFrom(source: StringDictionary<T>): void;
  64580. /**
  64581. * Get a value based from its key
  64582. * @param key the given key to get the matching value from
  64583. * @return the value if found, otherwise undefined is returned
  64584. */
  64585. get(key: string): T | undefined;
  64586. /**
  64587. * Get a value from its key or add it if it doesn't exist.
  64588. * This method will ensure you that a given key/data will be present in the dictionary.
  64589. * @param key the given key to get the matching value from
  64590. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64591. * The factory will only be invoked if there's no data for the given key.
  64592. * @return the value corresponding to the key.
  64593. */
  64594. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64595. /**
  64596. * Get a value from its key if present in the dictionary otherwise add it
  64597. * @param key the key to get the value from
  64598. * @param val if there's no such key/value pair in the dictionary add it with this value
  64599. * @return the value corresponding to the key
  64600. */
  64601. getOrAdd(key: string, val: T): T;
  64602. /**
  64603. * Check if there's a given key in the dictionary
  64604. * @param key the key to check for
  64605. * @return true if the key is present, false otherwise
  64606. */
  64607. contains(key: string): boolean;
  64608. /**
  64609. * Add a new key and its corresponding value
  64610. * @param key the key to add
  64611. * @param value the value corresponding to the key
  64612. * @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
  64613. */
  64614. add(key: string, value: T): boolean;
  64615. /**
  64616. * Update a specific value associated to a key
  64617. * @param key defines the key to use
  64618. * @param value defines the value to store
  64619. * @returns true if the value was updated (or false if the key was not found)
  64620. */
  64621. set(key: string, value: T): boolean;
  64622. /**
  64623. * Get the element of the given key and remove it from the dictionary
  64624. * @param key defines the key to search
  64625. * @returns the value associated with the key or null if not found
  64626. */
  64627. getAndRemove(key: string): Nullable<T>;
  64628. /**
  64629. * Remove a key/value from the dictionary.
  64630. * @param key the key to remove
  64631. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64632. */
  64633. remove(key: string): boolean;
  64634. /**
  64635. * Clear the whole content of the dictionary
  64636. */
  64637. clear(): void;
  64638. /**
  64639. * Gets the current count
  64640. */
  64641. readonly count: number;
  64642. /**
  64643. * Execute a callback on each key/val of the dictionary.
  64644. * Note that you can remove any element in this dictionary in the callback implementation
  64645. * @param callback the callback to execute on a given key/value pair
  64646. */
  64647. forEach(callback: (key: string, val: T) => void): void;
  64648. /**
  64649. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64650. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64651. * Note that you can remove any element in this dictionary in the callback implementation
  64652. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64653. * @returns the first item
  64654. */
  64655. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64656. private _count;
  64657. private _data;
  64658. }
  64659. }
  64660. declare module BABYLON {
  64661. /**
  64662. * Class used to store gfx data (like WebGLBuffer)
  64663. */
  64664. export class DataBuffer {
  64665. /**
  64666. * Gets or sets the number of objects referencing this buffer
  64667. */
  64668. references: number;
  64669. /** Gets or sets the size of the underlying buffer */
  64670. capacity: number;
  64671. /**
  64672. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64673. */
  64674. is32Bits: boolean;
  64675. /**
  64676. * Gets the underlying buffer
  64677. */
  64678. readonly underlyingResource: any;
  64679. }
  64680. }
  64681. declare module BABYLON {
  64682. /**
  64683. * Class used to store data that will be store in GPU memory
  64684. */
  64685. export class Buffer {
  64686. private _engine;
  64687. private _buffer;
  64688. /** @hidden */
  64689. _data: Nullable<DataArray>;
  64690. private _updatable;
  64691. private _instanced;
  64692. /**
  64693. * Gets the byte stride.
  64694. */
  64695. readonly byteStride: number;
  64696. /**
  64697. * Constructor
  64698. * @param engine the engine
  64699. * @param data the data to use for this buffer
  64700. * @param updatable whether the data is updatable
  64701. * @param stride the stride (optional)
  64702. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64703. * @param instanced whether the buffer is instanced (optional)
  64704. * @param useBytes set to true if the stride in in bytes (optional)
  64705. */
  64706. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64707. /**
  64708. * Create a new VertexBuffer based on the current buffer
  64709. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64710. * @param offset defines offset in the buffer (0 by default)
  64711. * @param size defines the size in floats of attributes (position is 3 for instance)
  64712. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64713. * @param instanced defines if the vertex buffer contains indexed data
  64714. * @param useBytes defines if the offset and stride are in bytes
  64715. * @returns the new vertex buffer
  64716. */
  64717. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64718. /**
  64719. * Gets a boolean indicating if the Buffer is updatable?
  64720. * @returns true if the buffer is updatable
  64721. */
  64722. isUpdatable(): boolean;
  64723. /**
  64724. * Gets current buffer's data
  64725. * @returns a DataArray or null
  64726. */
  64727. getData(): Nullable<DataArray>;
  64728. /**
  64729. * Gets underlying native buffer
  64730. * @returns underlying native buffer
  64731. */
  64732. getBuffer(): Nullable<DataBuffer>;
  64733. /**
  64734. * Gets the stride in float32 units (i.e. byte stride / 4).
  64735. * May not be an integer if the byte stride is not divisible by 4.
  64736. * DEPRECATED. Use byteStride instead.
  64737. * @returns the stride in float32 units
  64738. */
  64739. getStrideSize(): number;
  64740. /**
  64741. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64742. * @param data defines the data to store
  64743. */
  64744. create(data?: Nullable<DataArray>): void;
  64745. /** @hidden */
  64746. _rebuild(): void;
  64747. /**
  64748. * Update current buffer data
  64749. * @param data defines the data to store
  64750. */
  64751. update(data: DataArray): void;
  64752. /**
  64753. * Updates the data directly.
  64754. * @param data the new data
  64755. * @param offset the new offset
  64756. * @param vertexCount the vertex count (optional)
  64757. * @param useBytes set to true if the offset is in bytes
  64758. */
  64759. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64760. /**
  64761. * Release all resources
  64762. */
  64763. dispose(): void;
  64764. }
  64765. /**
  64766. * Specialized buffer used to store vertex data
  64767. */
  64768. export class VertexBuffer {
  64769. /** @hidden */
  64770. _buffer: Buffer;
  64771. private _kind;
  64772. private _size;
  64773. private _ownsBuffer;
  64774. private _instanced;
  64775. private _instanceDivisor;
  64776. /**
  64777. * The byte type.
  64778. */
  64779. static readonly BYTE: number;
  64780. /**
  64781. * The unsigned byte type.
  64782. */
  64783. static readonly UNSIGNED_BYTE: number;
  64784. /**
  64785. * The short type.
  64786. */
  64787. static readonly SHORT: number;
  64788. /**
  64789. * The unsigned short type.
  64790. */
  64791. static readonly UNSIGNED_SHORT: number;
  64792. /**
  64793. * The integer type.
  64794. */
  64795. static readonly INT: number;
  64796. /**
  64797. * The unsigned integer type.
  64798. */
  64799. static readonly UNSIGNED_INT: number;
  64800. /**
  64801. * The float type.
  64802. */
  64803. static readonly FLOAT: number;
  64804. /**
  64805. * Gets or sets the instance divisor when in instanced mode
  64806. */
  64807. instanceDivisor: number;
  64808. /**
  64809. * Gets the byte stride.
  64810. */
  64811. readonly byteStride: number;
  64812. /**
  64813. * Gets the byte offset.
  64814. */
  64815. readonly byteOffset: number;
  64816. /**
  64817. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64818. */
  64819. readonly normalized: boolean;
  64820. /**
  64821. * Gets the data type of each component in the array.
  64822. */
  64823. readonly type: number;
  64824. /**
  64825. * Constructor
  64826. * @param engine the engine
  64827. * @param data the data to use for this vertex buffer
  64828. * @param kind the vertex buffer kind
  64829. * @param updatable whether the data is updatable
  64830. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64831. * @param stride the stride (optional)
  64832. * @param instanced whether the buffer is instanced (optional)
  64833. * @param offset the offset of the data (optional)
  64834. * @param size the number of components (optional)
  64835. * @param type the type of the component (optional)
  64836. * @param normalized whether the data contains normalized data (optional)
  64837. * @param useBytes set to true if stride and offset are in bytes (optional)
  64838. */
  64839. 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);
  64840. /** @hidden */
  64841. _rebuild(): void;
  64842. /**
  64843. * Returns the kind of the VertexBuffer (string)
  64844. * @returns a string
  64845. */
  64846. getKind(): string;
  64847. /**
  64848. * Gets a boolean indicating if the VertexBuffer is updatable?
  64849. * @returns true if the buffer is updatable
  64850. */
  64851. isUpdatable(): boolean;
  64852. /**
  64853. * Gets current buffer's data
  64854. * @returns a DataArray or null
  64855. */
  64856. getData(): Nullable<DataArray>;
  64857. /**
  64858. * Gets underlying native buffer
  64859. * @returns underlying native buffer
  64860. */
  64861. getBuffer(): Nullable<DataBuffer>;
  64862. /**
  64863. * Gets the stride in float32 units (i.e. byte stride / 4).
  64864. * May not be an integer if the byte stride is not divisible by 4.
  64865. * DEPRECATED. Use byteStride instead.
  64866. * @returns the stride in float32 units
  64867. */
  64868. getStrideSize(): number;
  64869. /**
  64870. * Returns the offset as a multiple of the type byte length.
  64871. * DEPRECATED. Use byteOffset instead.
  64872. * @returns the offset in bytes
  64873. */
  64874. getOffset(): number;
  64875. /**
  64876. * Returns the number of components per vertex attribute (integer)
  64877. * @returns the size in float
  64878. */
  64879. getSize(): number;
  64880. /**
  64881. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64882. * @returns true if this buffer is instanced
  64883. */
  64884. getIsInstanced(): boolean;
  64885. /**
  64886. * Returns the instancing divisor, zero for non-instanced (integer).
  64887. * @returns a number
  64888. */
  64889. getInstanceDivisor(): number;
  64890. /**
  64891. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64892. * @param data defines the data to store
  64893. */
  64894. create(data?: DataArray): void;
  64895. /**
  64896. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64897. * This function will create a new buffer if the current one is not updatable
  64898. * @param data defines the data to store
  64899. */
  64900. update(data: DataArray): void;
  64901. /**
  64902. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64903. * Returns the directly updated WebGLBuffer.
  64904. * @param data the new data
  64905. * @param offset the new offset
  64906. * @param useBytes set to true if the offset is in bytes
  64907. */
  64908. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64909. /**
  64910. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64911. */
  64912. dispose(): void;
  64913. /**
  64914. * Enumerates each value of this vertex buffer as numbers.
  64915. * @param count the number of values to enumerate
  64916. * @param callback the callback function called for each value
  64917. */
  64918. forEach(count: number, callback: (value: number, index: number) => void): void;
  64919. /**
  64920. * Positions
  64921. */
  64922. static readonly PositionKind: string;
  64923. /**
  64924. * Normals
  64925. */
  64926. static readonly NormalKind: string;
  64927. /**
  64928. * Tangents
  64929. */
  64930. static readonly TangentKind: string;
  64931. /**
  64932. * Texture coordinates
  64933. */
  64934. static readonly UVKind: string;
  64935. /**
  64936. * Texture coordinates 2
  64937. */
  64938. static readonly UV2Kind: string;
  64939. /**
  64940. * Texture coordinates 3
  64941. */
  64942. static readonly UV3Kind: string;
  64943. /**
  64944. * Texture coordinates 4
  64945. */
  64946. static readonly UV4Kind: string;
  64947. /**
  64948. * Texture coordinates 5
  64949. */
  64950. static readonly UV5Kind: string;
  64951. /**
  64952. * Texture coordinates 6
  64953. */
  64954. static readonly UV6Kind: string;
  64955. /**
  64956. * Colors
  64957. */
  64958. static readonly ColorKind: string;
  64959. /**
  64960. * Matrix indices (for bones)
  64961. */
  64962. static readonly MatricesIndicesKind: string;
  64963. /**
  64964. * Matrix weights (for bones)
  64965. */
  64966. static readonly MatricesWeightsKind: string;
  64967. /**
  64968. * Additional matrix indices (for bones)
  64969. */
  64970. static readonly MatricesIndicesExtraKind: string;
  64971. /**
  64972. * Additional matrix weights (for bones)
  64973. */
  64974. static readonly MatricesWeightsExtraKind: string;
  64975. /**
  64976. * Deduces the stride given a kind.
  64977. * @param kind The kind string to deduce
  64978. * @returns The deduced stride
  64979. */
  64980. static DeduceStride(kind: string): number;
  64981. /**
  64982. * Gets the byte length of the given type.
  64983. * @param type the type
  64984. * @returns the number of bytes
  64985. */
  64986. static GetTypeByteLength(type: number): number;
  64987. /**
  64988. * Enumerates each value of the given parameters as numbers.
  64989. * @param data the data to enumerate
  64990. * @param byteOffset the byte offset of the data
  64991. * @param byteStride the byte stride of the data
  64992. * @param componentCount the number of components per element
  64993. * @param componentType the type of the component
  64994. * @param count the number of values to enumerate
  64995. * @param normalized whether the data is normalized
  64996. * @param callback the callback function called for each value
  64997. */
  64998. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64999. private static _GetFloatValue;
  65000. }
  65001. }
  65002. declare module BABYLON {
  65003. /**
  65004. * Scalar computation library
  65005. */
  65006. export class Scalar {
  65007. /**
  65008. * Two pi constants convenient for computation.
  65009. */
  65010. static TwoPi: number;
  65011. /**
  65012. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65013. * @param a number
  65014. * @param b number
  65015. * @param epsilon (default = 1.401298E-45)
  65016. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65017. */
  65018. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65019. /**
  65020. * Returns a string : the upper case translation of the number i to hexadecimal.
  65021. * @param i number
  65022. * @returns the upper case translation of the number i to hexadecimal.
  65023. */
  65024. static ToHex(i: number): string;
  65025. /**
  65026. * Returns -1 if value is negative and +1 is value is positive.
  65027. * @param value the value
  65028. * @returns the value itself if it's equal to zero.
  65029. */
  65030. static Sign(value: number): number;
  65031. /**
  65032. * Returns the value itself if it's between min and max.
  65033. * Returns min if the value is lower than min.
  65034. * Returns max if the value is greater than max.
  65035. * @param value the value to clmap
  65036. * @param min the min value to clamp to (default: 0)
  65037. * @param max the max value to clamp to (default: 1)
  65038. * @returns the clamped value
  65039. */
  65040. static Clamp(value: number, min?: number, max?: number): number;
  65041. /**
  65042. * the log2 of value.
  65043. * @param value the value to compute log2 of
  65044. * @returns the log2 of value.
  65045. */
  65046. static Log2(value: number): number;
  65047. /**
  65048. * Loops the value, so that it is never larger than length and never smaller than 0.
  65049. *
  65050. * This is similar to the modulo operator but it works with floating point numbers.
  65051. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65052. * With t = 5 and length = 2.5, the result would be 0.0.
  65053. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65054. * @param value the value
  65055. * @param length the length
  65056. * @returns the looped value
  65057. */
  65058. static Repeat(value: number, length: number): number;
  65059. /**
  65060. * Normalize the value between 0.0 and 1.0 using min and max values
  65061. * @param value value to normalize
  65062. * @param min max to normalize between
  65063. * @param max min to normalize between
  65064. * @returns the normalized value
  65065. */
  65066. static Normalize(value: number, min: number, max: number): number;
  65067. /**
  65068. * Denormalize the value from 0.0 and 1.0 using min and max values
  65069. * @param normalized value to denormalize
  65070. * @param min max to denormalize between
  65071. * @param max min to denormalize between
  65072. * @returns the denormalized value
  65073. */
  65074. static Denormalize(normalized: number, min: number, max: number): number;
  65075. /**
  65076. * Calculates the shortest difference between two given angles given in degrees.
  65077. * @param current current angle in degrees
  65078. * @param target target angle in degrees
  65079. * @returns the delta
  65080. */
  65081. static DeltaAngle(current: number, target: number): number;
  65082. /**
  65083. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65084. * @param tx value
  65085. * @param length length
  65086. * @returns The returned value will move back and forth between 0 and length
  65087. */
  65088. static PingPong(tx: number, length: number): number;
  65089. /**
  65090. * Interpolates between min and max with smoothing at the limits.
  65091. *
  65092. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65093. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65094. * @param from from
  65095. * @param to to
  65096. * @param tx value
  65097. * @returns the smooth stepped value
  65098. */
  65099. static SmoothStep(from: number, to: number, tx: number): number;
  65100. /**
  65101. * Moves a value current towards target.
  65102. *
  65103. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65104. * Negative values of maxDelta pushes the value away from target.
  65105. * @param current current value
  65106. * @param target target value
  65107. * @param maxDelta max distance to move
  65108. * @returns resulting value
  65109. */
  65110. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65111. /**
  65112. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65113. *
  65114. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65115. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65116. * @param current current value
  65117. * @param target target value
  65118. * @param maxDelta max distance to move
  65119. * @returns resulting angle
  65120. */
  65121. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65122. /**
  65123. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65124. * @param start start value
  65125. * @param end target value
  65126. * @param amount amount to lerp between
  65127. * @returns the lerped value
  65128. */
  65129. static Lerp(start: number, end: number, amount: number): number;
  65130. /**
  65131. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65132. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65133. * @param start start value
  65134. * @param end target value
  65135. * @param amount amount to lerp between
  65136. * @returns the lerped value
  65137. */
  65138. static LerpAngle(start: number, end: number, amount: number): number;
  65139. /**
  65140. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65141. * @param a start value
  65142. * @param b target value
  65143. * @param value value between a and b
  65144. * @returns the inverseLerp value
  65145. */
  65146. static InverseLerp(a: number, b: number, value: number): number;
  65147. /**
  65148. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65149. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65150. * @param value1 spline value
  65151. * @param tangent1 spline value
  65152. * @param value2 spline value
  65153. * @param tangent2 spline value
  65154. * @param amount input value
  65155. * @returns hermite result
  65156. */
  65157. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65158. /**
  65159. * Returns a random float number between and min and max values
  65160. * @param min min value of random
  65161. * @param max max value of random
  65162. * @returns random value
  65163. */
  65164. static RandomRange(min: number, max: number): number;
  65165. /**
  65166. * This function returns percentage of a number in a given range.
  65167. *
  65168. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65169. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65170. * @param number to convert to percentage
  65171. * @param min min range
  65172. * @param max max range
  65173. * @returns the percentage
  65174. */
  65175. static RangeToPercent(number: number, min: number, max: number): number;
  65176. /**
  65177. * This function returns number that corresponds to the percentage in a given range.
  65178. *
  65179. * PercentToRange(0.34,0,100) will return 34.
  65180. * @param percent to convert to number
  65181. * @param min min range
  65182. * @param max max range
  65183. * @returns the number
  65184. */
  65185. static PercentToRange(percent: number, min: number, max: number): number;
  65186. /**
  65187. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65188. * @param angle The angle to normalize in radian.
  65189. * @return The converted angle.
  65190. */
  65191. static NormalizeRadians(angle: number): number;
  65192. }
  65193. }
  65194. declare module BABYLON {
  65195. /**
  65196. * Constant used to convert a value to gamma space
  65197. * @ignorenaming
  65198. */
  65199. export const ToGammaSpace: number;
  65200. /**
  65201. * Constant used to convert a value to linear space
  65202. * @ignorenaming
  65203. */
  65204. export const ToLinearSpace = 2.2;
  65205. /**
  65206. * Constant used to define the minimal number value in Babylon.js
  65207. * @ignorenaming
  65208. */
  65209. let Epsilon: number;
  65210. }
  65211. declare module BABYLON {
  65212. /**
  65213. * Class used to represent a viewport on screen
  65214. */
  65215. export class Viewport {
  65216. /** viewport left coordinate */
  65217. x: number;
  65218. /** viewport top coordinate */
  65219. y: number;
  65220. /**viewport width */
  65221. width: number;
  65222. /** viewport height */
  65223. height: number;
  65224. /**
  65225. * Creates a Viewport object located at (x, y) and sized (width, height)
  65226. * @param x defines viewport left coordinate
  65227. * @param y defines viewport top coordinate
  65228. * @param width defines the viewport width
  65229. * @param height defines the viewport height
  65230. */
  65231. constructor(
  65232. /** viewport left coordinate */
  65233. x: number,
  65234. /** viewport top coordinate */
  65235. y: number,
  65236. /**viewport width */
  65237. width: number,
  65238. /** viewport height */
  65239. height: number);
  65240. /**
  65241. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65242. * @param renderWidth defines the rendering width
  65243. * @param renderHeight defines the rendering height
  65244. * @returns a new Viewport
  65245. */
  65246. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65247. /**
  65248. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65249. * @param renderWidth defines the rendering width
  65250. * @param renderHeight defines the rendering height
  65251. * @param ref defines the target viewport
  65252. * @returns the current viewport
  65253. */
  65254. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65255. /**
  65256. * Returns a new Viewport copied from the current one
  65257. * @returns a new Viewport
  65258. */
  65259. clone(): Viewport;
  65260. }
  65261. }
  65262. declare module BABYLON {
  65263. /**
  65264. * Class containing a set of static utilities functions for arrays.
  65265. */
  65266. export class ArrayTools {
  65267. /**
  65268. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65269. * @param size the number of element to construct and put in the array
  65270. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65271. * @returns a new array filled with new objects
  65272. */
  65273. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65274. }
  65275. }
  65276. declare module BABYLON {
  65277. /**
  65278. * @hidden
  65279. */
  65280. export interface IColor4Like {
  65281. r: float;
  65282. g: float;
  65283. b: float;
  65284. a: float;
  65285. }
  65286. /**
  65287. * @hidden
  65288. */
  65289. export interface IColor3Like {
  65290. r: float;
  65291. g: float;
  65292. b: float;
  65293. }
  65294. /**
  65295. * @hidden
  65296. */
  65297. export interface IVector4Like {
  65298. x: float;
  65299. y: float;
  65300. z: float;
  65301. w: float;
  65302. }
  65303. /**
  65304. * @hidden
  65305. */
  65306. export interface IVector3Like {
  65307. x: float;
  65308. y: float;
  65309. z: float;
  65310. }
  65311. /**
  65312. * @hidden
  65313. */
  65314. export interface IVector2Like {
  65315. x: float;
  65316. y: float;
  65317. }
  65318. /**
  65319. * @hidden
  65320. */
  65321. export interface IMatrixLike {
  65322. toArray(): DeepImmutable<Float32Array>;
  65323. updateFlag: int;
  65324. }
  65325. /**
  65326. * @hidden
  65327. */
  65328. export interface IViewportLike {
  65329. x: float;
  65330. y: float;
  65331. width: float;
  65332. height: float;
  65333. }
  65334. /**
  65335. * @hidden
  65336. */
  65337. export interface IPlaneLike {
  65338. normal: IVector3Like;
  65339. d: float;
  65340. normalize(): void;
  65341. }
  65342. }
  65343. declare module BABYLON {
  65344. /**
  65345. * Class representing a vector containing 2 coordinates
  65346. */
  65347. export class Vector2 {
  65348. /** defines the first coordinate */
  65349. x: number;
  65350. /** defines the second coordinate */
  65351. y: number;
  65352. /**
  65353. * Creates a new Vector2 from the given x and y coordinates
  65354. * @param x defines the first coordinate
  65355. * @param y defines the second coordinate
  65356. */
  65357. constructor(
  65358. /** defines the first coordinate */
  65359. x?: number,
  65360. /** defines the second coordinate */
  65361. y?: number);
  65362. /**
  65363. * Gets a string with the Vector2 coordinates
  65364. * @returns a string with the Vector2 coordinates
  65365. */
  65366. toString(): string;
  65367. /**
  65368. * Gets class name
  65369. * @returns the string "Vector2"
  65370. */
  65371. getClassName(): string;
  65372. /**
  65373. * Gets current vector hash code
  65374. * @returns the Vector2 hash code as a number
  65375. */
  65376. getHashCode(): number;
  65377. /**
  65378. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65379. * @param array defines the source array
  65380. * @param index defines the offset in source array
  65381. * @returns the current Vector2
  65382. */
  65383. toArray(array: FloatArray, index?: number): Vector2;
  65384. /**
  65385. * Copy the current vector to an array
  65386. * @returns a new array with 2 elements: the Vector2 coordinates.
  65387. */
  65388. asArray(): number[];
  65389. /**
  65390. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65391. * @param source defines the source Vector2
  65392. * @returns the current updated Vector2
  65393. */
  65394. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65395. /**
  65396. * Sets the Vector2 coordinates with the given floats
  65397. * @param x defines the first coordinate
  65398. * @param y defines the second coordinate
  65399. * @returns the current updated Vector2
  65400. */
  65401. copyFromFloats(x: number, y: number): Vector2;
  65402. /**
  65403. * Sets the Vector2 coordinates with the given floats
  65404. * @param x defines the first coordinate
  65405. * @param y defines the second coordinate
  65406. * @returns the current updated Vector2
  65407. */
  65408. set(x: number, y: number): Vector2;
  65409. /**
  65410. * Add another vector with the current one
  65411. * @param otherVector defines the other vector
  65412. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65413. */
  65414. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65415. /**
  65416. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65417. * @param otherVector defines the other vector
  65418. * @param result defines the target vector
  65419. * @returns the unmodified current Vector2
  65420. */
  65421. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65422. /**
  65423. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65424. * @param otherVector defines the other vector
  65425. * @returns the current updated Vector2
  65426. */
  65427. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65428. /**
  65429. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65430. * @param otherVector defines the other vector
  65431. * @returns a new Vector2
  65432. */
  65433. addVector3(otherVector: Vector3): Vector2;
  65434. /**
  65435. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65436. * @param otherVector defines the other vector
  65437. * @returns a new Vector2
  65438. */
  65439. subtract(otherVector: Vector2): Vector2;
  65440. /**
  65441. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65442. * @param otherVector defines the other vector
  65443. * @param result defines the target vector
  65444. * @returns the unmodified current Vector2
  65445. */
  65446. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65447. /**
  65448. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65449. * @param otherVector defines the other vector
  65450. * @returns the current updated Vector2
  65451. */
  65452. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65453. /**
  65454. * Multiplies in place the current Vector2 coordinates by the given ones
  65455. * @param otherVector defines the other vector
  65456. * @returns the current updated Vector2
  65457. */
  65458. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65459. /**
  65460. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65461. * @param otherVector defines the other vector
  65462. * @returns a new Vector2
  65463. */
  65464. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65465. /**
  65466. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65467. * @param otherVector defines the other vector
  65468. * @param result defines the target vector
  65469. * @returns the unmodified current Vector2
  65470. */
  65471. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65472. /**
  65473. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65474. * @param x defines the first coordinate
  65475. * @param y defines the second coordinate
  65476. * @returns a new Vector2
  65477. */
  65478. multiplyByFloats(x: number, y: number): Vector2;
  65479. /**
  65480. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65481. * @param otherVector defines the other vector
  65482. * @returns a new Vector2
  65483. */
  65484. divide(otherVector: Vector2): Vector2;
  65485. /**
  65486. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65487. * @param otherVector defines the other vector
  65488. * @param result defines the target vector
  65489. * @returns the unmodified current Vector2
  65490. */
  65491. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65492. /**
  65493. * Divides the current Vector2 coordinates by the given ones
  65494. * @param otherVector defines the other vector
  65495. * @returns the current updated Vector2
  65496. */
  65497. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65498. /**
  65499. * Gets a new Vector2 with current Vector2 negated coordinates
  65500. * @returns a new Vector2
  65501. */
  65502. negate(): Vector2;
  65503. /**
  65504. * Multiply the Vector2 coordinates by scale
  65505. * @param scale defines the scaling factor
  65506. * @returns the current updated Vector2
  65507. */
  65508. scaleInPlace(scale: number): Vector2;
  65509. /**
  65510. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65511. * @param scale defines the scaling factor
  65512. * @returns a new Vector2
  65513. */
  65514. scale(scale: number): Vector2;
  65515. /**
  65516. * Scale the current Vector2 values by a factor to a given Vector2
  65517. * @param scale defines the scale factor
  65518. * @param result defines the Vector2 object where to store the result
  65519. * @returns the unmodified current Vector2
  65520. */
  65521. scaleToRef(scale: number, result: Vector2): Vector2;
  65522. /**
  65523. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65524. * @param scale defines the scale factor
  65525. * @param result defines the Vector2 object where to store the result
  65526. * @returns the unmodified current Vector2
  65527. */
  65528. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65529. /**
  65530. * Gets a boolean if two vectors are equals
  65531. * @param otherVector defines the other vector
  65532. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65533. */
  65534. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65535. /**
  65536. * Gets a boolean if two vectors are equals (using an epsilon value)
  65537. * @param otherVector defines the other vector
  65538. * @param epsilon defines the minimal distance to consider equality
  65539. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65540. */
  65541. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65542. /**
  65543. * Gets a new Vector2 from current Vector2 floored values
  65544. * @returns a new Vector2
  65545. */
  65546. floor(): Vector2;
  65547. /**
  65548. * Gets a new Vector2 from current Vector2 floored values
  65549. * @returns a new Vector2
  65550. */
  65551. fract(): Vector2;
  65552. /**
  65553. * Gets the length of the vector
  65554. * @returns the vector length (float)
  65555. */
  65556. length(): number;
  65557. /**
  65558. * Gets the vector squared length
  65559. * @returns the vector squared length (float)
  65560. */
  65561. lengthSquared(): number;
  65562. /**
  65563. * Normalize the vector
  65564. * @returns the current updated Vector2
  65565. */
  65566. normalize(): Vector2;
  65567. /**
  65568. * Gets a new Vector2 copied from the Vector2
  65569. * @returns a new Vector2
  65570. */
  65571. clone(): Vector2;
  65572. /**
  65573. * Gets a new Vector2(0, 0)
  65574. * @returns a new Vector2
  65575. */
  65576. static Zero(): Vector2;
  65577. /**
  65578. * Gets a new Vector2(1, 1)
  65579. * @returns a new Vector2
  65580. */
  65581. static One(): Vector2;
  65582. /**
  65583. * Gets a new Vector2 set from the given index element of the given array
  65584. * @param array defines the data source
  65585. * @param offset defines the offset in the data source
  65586. * @returns a new Vector2
  65587. */
  65588. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65589. /**
  65590. * Sets "result" from the given index element of the given array
  65591. * @param array defines the data source
  65592. * @param offset defines the offset in the data source
  65593. * @param result defines the target vector
  65594. */
  65595. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65596. /**
  65597. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65598. * @param value1 defines 1st point of control
  65599. * @param value2 defines 2nd point of control
  65600. * @param value3 defines 3rd point of control
  65601. * @param value4 defines 4th point of control
  65602. * @param amount defines the interpolation factor
  65603. * @returns a new Vector2
  65604. */
  65605. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65606. /**
  65607. * 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".
  65608. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65609. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65610. * @param value defines the value to clamp
  65611. * @param min defines the lower limit
  65612. * @param max defines the upper limit
  65613. * @returns a new Vector2
  65614. */
  65615. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65616. /**
  65617. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65618. * @param value1 defines the 1st control point
  65619. * @param tangent1 defines the outgoing tangent
  65620. * @param value2 defines the 2nd control point
  65621. * @param tangent2 defines the incoming tangent
  65622. * @param amount defines the interpolation factor
  65623. * @returns a new Vector2
  65624. */
  65625. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65626. /**
  65627. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65628. * @param start defines the start vector
  65629. * @param end defines the end vector
  65630. * @param amount defines the interpolation factor
  65631. * @returns a new Vector2
  65632. */
  65633. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65634. /**
  65635. * Gets the dot product of the vector "left" and the vector "right"
  65636. * @param left defines first vector
  65637. * @param right defines second vector
  65638. * @returns the dot product (float)
  65639. */
  65640. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65641. /**
  65642. * Returns a new Vector2 equal to the normalized given vector
  65643. * @param vector defines the vector to normalize
  65644. * @returns a new Vector2
  65645. */
  65646. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65647. /**
  65648. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65649. * @param left defines 1st vector
  65650. * @param right defines 2nd vector
  65651. * @returns a new Vector2
  65652. */
  65653. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65654. /**
  65655. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65656. * @param left defines 1st vector
  65657. * @param right defines 2nd vector
  65658. * @returns a new Vector2
  65659. */
  65660. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65661. /**
  65662. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65663. * @param vector defines the vector to transform
  65664. * @param transformation defines the matrix to apply
  65665. * @returns a new Vector2
  65666. */
  65667. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65668. /**
  65669. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65670. * @param vector defines the vector to transform
  65671. * @param transformation defines the matrix to apply
  65672. * @param result defines the target vector
  65673. */
  65674. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65675. /**
  65676. * Determines if a given vector is included in a triangle
  65677. * @param p defines the vector to test
  65678. * @param p0 defines 1st triangle point
  65679. * @param p1 defines 2nd triangle point
  65680. * @param p2 defines 3rd triangle point
  65681. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65682. */
  65683. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65684. /**
  65685. * Gets the distance between the vectors "value1" and "value2"
  65686. * @param value1 defines first vector
  65687. * @param value2 defines second vector
  65688. * @returns the distance between vectors
  65689. */
  65690. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65691. /**
  65692. * Returns the squared distance between the vectors "value1" and "value2"
  65693. * @param value1 defines first vector
  65694. * @param value2 defines second vector
  65695. * @returns the squared distance between vectors
  65696. */
  65697. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65698. /**
  65699. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65700. * @param value1 defines first vector
  65701. * @param value2 defines second vector
  65702. * @returns a new Vector2
  65703. */
  65704. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65705. /**
  65706. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65707. * @param p defines the middle point
  65708. * @param segA defines one point of the segment
  65709. * @param segB defines the other point of the segment
  65710. * @returns the shortest distance
  65711. */
  65712. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65713. }
  65714. /**
  65715. * Classed used to store (x,y,z) vector representation
  65716. * A Vector3 is the main object used in 3D geometry
  65717. * It can represent etiher the coordinates of a point the space, either a direction
  65718. * Reminder: js uses a left handed forward facing system
  65719. */
  65720. export class Vector3 {
  65721. /**
  65722. * Defines the first coordinates (on X axis)
  65723. */
  65724. x: number;
  65725. /**
  65726. * Defines the second coordinates (on Y axis)
  65727. */
  65728. y: number;
  65729. /**
  65730. * Defines the third coordinates (on Z axis)
  65731. */
  65732. z: number;
  65733. private static _UpReadOnly;
  65734. private static _ZeroReadOnly;
  65735. /**
  65736. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65737. * @param x defines the first coordinates (on X axis)
  65738. * @param y defines the second coordinates (on Y axis)
  65739. * @param z defines the third coordinates (on Z axis)
  65740. */
  65741. constructor(
  65742. /**
  65743. * Defines the first coordinates (on X axis)
  65744. */
  65745. x?: number,
  65746. /**
  65747. * Defines the second coordinates (on Y axis)
  65748. */
  65749. y?: number,
  65750. /**
  65751. * Defines the third coordinates (on Z axis)
  65752. */
  65753. z?: number);
  65754. /**
  65755. * Creates a string representation of the Vector3
  65756. * @returns a string with the Vector3 coordinates.
  65757. */
  65758. toString(): string;
  65759. /**
  65760. * Gets the class name
  65761. * @returns the string "Vector3"
  65762. */
  65763. getClassName(): string;
  65764. /**
  65765. * Creates the Vector3 hash code
  65766. * @returns a number which tends to be unique between Vector3 instances
  65767. */
  65768. getHashCode(): number;
  65769. /**
  65770. * Creates an array containing three elements : the coordinates of the Vector3
  65771. * @returns a new array of numbers
  65772. */
  65773. asArray(): number[];
  65774. /**
  65775. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  65776. * @param array defines the destination array
  65777. * @param index defines the offset in the destination array
  65778. * @returns the current Vector3
  65779. */
  65780. toArray(array: FloatArray, index?: number): Vector3;
  65781. /**
  65782. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  65783. * @returns a new Quaternion object, computed from the Vector3 coordinates
  65784. */
  65785. toQuaternion(): Quaternion;
  65786. /**
  65787. * Adds the given vector to the current Vector3
  65788. * @param otherVector defines the second operand
  65789. * @returns the current updated Vector3
  65790. */
  65791. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65792. /**
  65793. * Adds the given coordinates to the current Vector3
  65794. * @param x defines the x coordinate of the operand
  65795. * @param y defines the y coordinate of the operand
  65796. * @param z defines the z coordinate of the operand
  65797. * @returns the current updated Vector3
  65798. */
  65799. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65800. /**
  65801. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65802. * @param otherVector defines the second operand
  65803. * @returns the resulting Vector3
  65804. */
  65805. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65806. /**
  65807. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65808. * @param otherVector defines the second operand
  65809. * @param result defines the Vector3 object where to store the result
  65810. * @returns the current Vector3
  65811. */
  65812. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65813. /**
  65814. * Subtract the given vector from the current Vector3
  65815. * @param otherVector defines the second operand
  65816. * @returns the current updated Vector3
  65817. */
  65818. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65819. /**
  65820. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65821. * @param otherVector defines the second operand
  65822. * @returns the resulting Vector3
  65823. */
  65824. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65825. /**
  65826. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65827. * @param otherVector defines the second operand
  65828. * @param result defines the Vector3 object where to store the result
  65829. * @returns the current Vector3
  65830. */
  65831. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65832. /**
  65833. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65834. * @param x defines the x coordinate of the operand
  65835. * @param y defines the y coordinate of the operand
  65836. * @param z defines the z coordinate of the operand
  65837. * @returns the resulting Vector3
  65838. */
  65839. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65840. /**
  65841. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65842. * @param x defines the x coordinate of the operand
  65843. * @param y defines the y coordinate of the operand
  65844. * @param z defines the z coordinate of the operand
  65845. * @param result defines the Vector3 object where to store the result
  65846. * @returns the current Vector3
  65847. */
  65848. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65849. /**
  65850. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65851. * @returns a new Vector3
  65852. */
  65853. negate(): Vector3;
  65854. /**
  65855. * Multiplies the Vector3 coordinates by the float "scale"
  65856. * @param scale defines the multiplier factor
  65857. * @returns the current updated Vector3
  65858. */
  65859. scaleInPlace(scale: number): Vector3;
  65860. /**
  65861. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65862. * @param scale defines the multiplier factor
  65863. * @returns a new Vector3
  65864. */
  65865. scale(scale: number): Vector3;
  65866. /**
  65867. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65868. * @param scale defines the multiplier factor
  65869. * @param result defines the Vector3 object where to store the result
  65870. * @returns the current Vector3
  65871. */
  65872. scaleToRef(scale: number, result: Vector3): Vector3;
  65873. /**
  65874. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65875. * @param scale defines the scale factor
  65876. * @param result defines the Vector3 object where to store the result
  65877. * @returns the unmodified current Vector3
  65878. */
  65879. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65880. /**
  65881. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65882. * @param otherVector defines the second operand
  65883. * @returns true if both vectors are equals
  65884. */
  65885. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65886. /**
  65887. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65888. * @param otherVector defines the second operand
  65889. * @param epsilon defines the minimal distance to define values as equals
  65890. * @returns true if both vectors are distant less than epsilon
  65891. */
  65892. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65893. /**
  65894. * Returns true if the current Vector3 coordinates equals the given floats
  65895. * @param x defines the x coordinate of the operand
  65896. * @param y defines the y coordinate of the operand
  65897. * @param z defines the z coordinate of the operand
  65898. * @returns true if both vectors are equals
  65899. */
  65900. equalsToFloats(x: number, y: number, z: number): boolean;
  65901. /**
  65902. * Multiplies the current Vector3 coordinates by the given ones
  65903. * @param otherVector defines the second operand
  65904. * @returns the current updated Vector3
  65905. */
  65906. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65907. /**
  65908. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65909. * @param otherVector defines the second operand
  65910. * @returns the new Vector3
  65911. */
  65912. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65913. /**
  65914. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65915. * @param otherVector defines the second operand
  65916. * @param result defines the Vector3 object where to store the result
  65917. * @returns the current Vector3
  65918. */
  65919. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65920. /**
  65921. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65922. * @param x defines the x coordinate of the operand
  65923. * @param y defines the y coordinate of the operand
  65924. * @param z defines the z coordinate of the operand
  65925. * @returns the new Vector3
  65926. */
  65927. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65928. /**
  65929. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65930. * @param otherVector defines the second operand
  65931. * @returns the new Vector3
  65932. */
  65933. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65934. /**
  65935. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65936. * @param otherVector defines the second operand
  65937. * @param result defines the Vector3 object where to store the result
  65938. * @returns the current Vector3
  65939. */
  65940. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65941. /**
  65942. * Divides the current Vector3 coordinates by the given ones.
  65943. * @param otherVector defines the second operand
  65944. * @returns the current updated Vector3
  65945. */
  65946. divideInPlace(otherVector: Vector3): Vector3;
  65947. /**
  65948. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65949. * @param other defines the second operand
  65950. * @returns the current updated Vector3
  65951. */
  65952. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65953. /**
  65954. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65955. * @param other defines the second operand
  65956. * @returns the current updated Vector3
  65957. */
  65958. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65959. /**
  65960. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65961. * @param x defines the x coordinate of the operand
  65962. * @param y defines the y coordinate of the operand
  65963. * @param z defines the z coordinate of the operand
  65964. * @returns the current updated Vector3
  65965. */
  65966. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65967. /**
  65968. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  65969. * @param x defines the x coordinate of the operand
  65970. * @param y defines the y coordinate of the operand
  65971. * @param z defines the z coordinate of the operand
  65972. * @returns the current updated Vector3
  65973. */
  65974. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65975. /**
  65976. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65977. * Check if is non uniform within a certain amount of decimal places to account for this
  65978. * @param epsilon the amount the values can differ
  65979. * @returns if the the vector is non uniform to a certain number of decimal places
  65980. */
  65981. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65982. /**
  65983. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65984. */
  65985. readonly isNonUniform: boolean;
  65986. /**
  65987. * Gets a new Vector3 from current Vector3 floored values
  65988. * @returns a new Vector3
  65989. */
  65990. floor(): Vector3;
  65991. /**
  65992. * Gets a new Vector3 from current Vector3 floored values
  65993. * @returns a new Vector3
  65994. */
  65995. fract(): Vector3;
  65996. /**
  65997. * Gets the length of the Vector3
  65998. * @returns the length of the Vector3
  65999. */
  66000. length(): number;
  66001. /**
  66002. * Gets the squared length of the Vector3
  66003. * @returns squared length of the Vector3
  66004. */
  66005. lengthSquared(): number;
  66006. /**
  66007. * Normalize the current Vector3.
  66008. * Please note that this is an in place operation.
  66009. * @returns the current updated Vector3
  66010. */
  66011. normalize(): Vector3;
  66012. /**
  66013. * Reorders the x y z properties of the vector in place
  66014. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66015. * @returns the current updated vector
  66016. */
  66017. reorderInPlace(order: string): this;
  66018. /**
  66019. * Rotates the vector around 0,0,0 by a quaternion
  66020. * @param quaternion the rotation quaternion
  66021. * @param result vector to store the result
  66022. * @returns the resulting vector
  66023. */
  66024. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66025. /**
  66026. * Rotates a vector around a given point
  66027. * @param quaternion the rotation quaternion
  66028. * @param point the point to rotate around
  66029. * @param result vector to store the result
  66030. * @returns the resulting vector
  66031. */
  66032. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66033. /**
  66034. * Normalize the current Vector3 with the given input length.
  66035. * Please note that this is an in place operation.
  66036. * @param len the length of the vector
  66037. * @returns the current updated Vector3
  66038. */
  66039. normalizeFromLength(len: number): Vector3;
  66040. /**
  66041. * Normalize the current Vector3 to a new vector
  66042. * @returns the new Vector3
  66043. */
  66044. normalizeToNew(): Vector3;
  66045. /**
  66046. * Normalize the current Vector3 to the reference
  66047. * @param reference define the Vector3 to update
  66048. * @returns the updated Vector3
  66049. */
  66050. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66051. /**
  66052. * Creates a new Vector3 copied from the current Vector3
  66053. * @returns the new Vector3
  66054. */
  66055. clone(): Vector3;
  66056. /**
  66057. * Copies the given vector coordinates to the current Vector3 ones
  66058. * @param source defines the source Vector3
  66059. * @returns the current updated Vector3
  66060. */
  66061. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66062. /**
  66063. * Copies the given floats to the current Vector3 coordinates
  66064. * @param x defines the x coordinate of the operand
  66065. * @param y defines the y coordinate of the operand
  66066. * @param z defines the z coordinate of the operand
  66067. * @returns the current updated Vector3
  66068. */
  66069. copyFromFloats(x: number, y: number, z: number): Vector3;
  66070. /**
  66071. * Copies the given floats to the current Vector3 coordinates
  66072. * @param x defines the x coordinate of the operand
  66073. * @param y defines the y coordinate of the operand
  66074. * @param z defines the z coordinate of the operand
  66075. * @returns the current updated Vector3
  66076. */
  66077. set(x: number, y: number, z: number): Vector3;
  66078. /**
  66079. * Copies the given float to the current Vector3 coordinates
  66080. * @param v defines the x, y and z coordinates of the operand
  66081. * @returns the current updated Vector3
  66082. */
  66083. setAll(v: number): Vector3;
  66084. /**
  66085. * Get the clip factor between two vectors
  66086. * @param vector0 defines the first operand
  66087. * @param vector1 defines the second operand
  66088. * @param axis defines the axis to use
  66089. * @param size defines the size along the axis
  66090. * @returns the clip factor
  66091. */
  66092. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66093. /**
  66094. * Get angle between two vectors
  66095. * @param vector0 angle between vector0 and vector1
  66096. * @param vector1 angle between vector0 and vector1
  66097. * @param normal direction of the normal
  66098. * @return the angle between vector0 and vector1
  66099. */
  66100. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66101. /**
  66102. * Returns a new Vector3 set from the index "offset" of the given array
  66103. * @param array defines the source array
  66104. * @param offset defines the offset in the source array
  66105. * @returns the new Vector3
  66106. */
  66107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66108. /**
  66109. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66110. * This function is deprecated. Use FromArray instead
  66111. * @param array defines the source array
  66112. * @param offset defines the offset in the source array
  66113. * @returns the new Vector3
  66114. */
  66115. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66116. /**
  66117. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66118. * @param array defines the source array
  66119. * @param offset defines the offset in the source array
  66120. * @param result defines the Vector3 where to store the result
  66121. */
  66122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66123. /**
  66124. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66125. * This function is deprecated. Use FromArrayToRef instead.
  66126. * @param array defines the source array
  66127. * @param offset defines the offset in the source array
  66128. * @param result defines the Vector3 where to store the result
  66129. */
  66130. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66131. /**
  66132. * Sets the given vector "result" with the given floats.
  66133. * @param x defines the x coordinate of the source
  66134. * @param y defines the y coordinate of the source
  66135. * @param z defines the z coordinate of the source
  66136. * @param result defines the Vector3 where to store the result
  66137. */
  66138. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66139. /**
  66140. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66141. * @returns a new empty Vector3
  66142. */
  66143. static Zero(): Vector3;
  66144. /**
  66145. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66146. * @returns a new unit Vector3
  66147. */
  66148. static One(): Vector3;
  66149. /**
  66150. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66151. * @returns a new up Vector3
  66152. */
  66153. static Up(): Vector3;
  66154. /**
  66155. * Gets a up Vector3 that must not be updated
  66156. */
  66157. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66158. /**
  66159. * Gets a zero Vector3 that must not be updated
  66160. */
  66161. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66162. /**
  66163. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66164. * @returns a new down Vector3
  66165. */
  66166. static Down(): Vector3;
  66167. /**
  66168. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66169. * @returns a new forward Vector3
  66170. */
  66171. static Forward(): Vector3;
  66172. /**
  66173. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66174. * @returns a new forward Vector3
  66175. */
  66176. static Backward(): Vector3;
  66177. /**
  66178. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66179. * @returns a new right Vector3
  66180. */
  66181. static Right(): Vector3;
  66182. /**
  66183. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66184. * @returns a new left Vector3
  66185. */
  66186. static Left(): Vector3;
  66187. /**
  66188. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66189. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66190. * @param vector defines the Vector3 to transform
  66191. * @param transformation defines the transformation matrix
  66192. * @returns the transformed Vector3
  66193. */
  66194. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66195. /**
  66196. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66197. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66198. * @param vector defines the Vector3 to transform
  66199. * @param transformation defines the transformation matrix
  66200. * @param result defines the Vector3 where to store the result
  66201. */
  66202. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66203. /**
  66204. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66205. * This method computes tranformed coordinates only, not transformed direction vectors
  66206. * @param x define the x coordinate of the source vector
  66207. * @param y define the y coordinate of the source vector
  66208. * @param z define the z coordinate of the source vector
  66209. * @param transformation defines the transformation matrix
  66210. * @param result defines the Vector3 where to store the result
  66211. */
  66212. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66213. /**
  66214. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66215. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66216. * @param vector defines the Vector3 to transform
  66217. * @param transformation defines the transformation matrix
  66218. * @returns the new Vector3
  66219. */
  66220. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66221. /**
  66222. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66223. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66224. * @param vector defines the Vector3 to transform
  66225. * @param transformation defines the transformation matrix
  66226. * @param result defines the Vector3 where to store the result
  66227. */
  66228. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66229. /**
  66230. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66231. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66232. * @param x define the x coordinate of the source vector
  66233. * @param y define the y coordinate of the source vector
  66234. * @param z define the z coordinate of the source vector
  66235. * @param transformation defines the transformation matrix
  66236. * @param result defines the Vector3 where to store the result
  66237. */
  66238. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66239. /**
  66240. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66241. * @param value1 defines the first control point
  66242. * @param value2 defines the second control point
  66243. * @param value3 defines the third control point
  66244. * @param value4 defines the fourth control point
  66245. * @param amount defines the amount on the spline to use
  66246. * @returns the new Vector3
  66247. */
  66248. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66249. /**
  66250. * 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"
  66251. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66252. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66253. * @param value defines the current value
  66254. * @param min defines the lower range value
  66255. * @param max defines the upper range value
  66256. * @returns the new Vector3
  66257. */
  66258. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66259. /**
  66260. * 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"
  66261. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66262. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66263. * @param value defines the current value
  66264. * @param min defines the lower range value
  66265. * @param max defines the upper range value
  66266. * @param result defines the Vector3 where to store the result
  66267. */
  66268. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66269. /**
  66270. * Checks if a given vector is inside a specific range
  66271. * @param v defines the vector to test
  66272. * @param min defines the minimum range
  66273. * @param max defines the maximum range
  66274. */
  66275. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66276. /**
  66277. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66278. * @param value1 defines the first control point
  66279. * @param tangent1 defines the first tangent vector
  66280. * @param value2 defines the second control point
  66281. * @param tangent2 defines the second tangent vector
  66282. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66283. * @returns the new Vector3
  66284. */
  66285. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66286. /**
  66287. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66288. * @param start defines the start value
  66289. * @param end defines the end value
  66290. * @param amount max defines amount between both (between 0 and 1)
  66291. * @returns the new Vector3
  66292. */
  66293. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66294. /**
  66295. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66296. * @param start defines the start value
  66297. * @param end defines the end value
  66298. * @param amount max defines amount between both (between 0 and 1)
  66299. * @param result defines the Vector3 where to store the result
  66300. */
  66301. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66302. /**
  66303. * Returns the dot product (float) between the vectors "left" and "right"
  66304. * @param left defines the left operand
  66305. * @param right defines the right operand
  66306. * @returns the dot product
  66307. */
  66308. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66309. /**
  66310. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66311. * The cross product is then orthogonal to both "left" and "right"
  66312. * @param left defines the left operand
  66313. * @param right defines the right operand
  66314. * @returns the cross product
  66315. */
  66316. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66317. /**
  66318. * Sets the given vector "result" with the cross product of "left" and "right"
  66319. * The cross product is then orthogonal to both "left" and "right"
  66320. * @param left defines the left operand
  66321. * @param right defines the right operand
  66322. * @param result defines the Vector3 where to store the result
  66323. */
  66324. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66325. /**
  66326. * Returns a new Vector3 as the normalization of the given vector
  66327. * @param vector defines the Vector3 to normalize
  66328. * @returns the new Vector3
  66329. */
  66330. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66331. /**
  66332. * Sets the given vector "result" with the normalization of the given first vector
  66333. * @param vector defines the Vector3 to normalize
  66334. * @param result defines the Vector3 where to store the result
  66335. */
  66336. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66337. /**
  66338. * Project a Vector3 onto screen space
  66339. * @param vector defines the Vector3 to project
  66340. * @param world defines the world matrix to use
  66341. * @param transform defines the transform (view x projection) matrix to use
  66342. * @param viewport defines the screen viewport to use
  66343. * @returns the new Vector3
  66344. */
  66345. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66346. /** @hidden */
  66347. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66348. /**
  66349. * Unproject from screen space to object space
  66350. * @param source defines the screen space Vector3 to use
  66351. * @param viewportWidth defines the current width of the viewport
  66352. * @param viewportHeight defines the current height of the viewport
  66353. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66354. * @param transform defines the transform (view x projection) matrix to use
  66355. * @returns the new Vector3
  66356. */
  66357. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66358. /**
  66359. * Unproject from screen space to object space
  66360. * @param source defines the screen space Vector3 to use
  66361. * @param viewportWidth defines the current width of the viewport
  66362. * @param viewportHeight defines the current height of the viewport
  66363. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66364. * @param view defines the view matrix to use
  66365. * @param projection defines the projection matrix to use
  66366. * @returns the new Vector3
  66367. */
  66368. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66369. /**
  66370. * Unproject from screen space to object space
  66371. * @param source defines the screen space Vector3 to use
  66372. * @param viewportWidth defines the current width of the viewport
  66373. * @param viewportHeight defines the current height of the viewport
  66374. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66375. * @param view defines the view matrix to use
  66376. * @param projection defines the projection matrix to use
  66377. * @param result defines the Vector3 where to store the result
  66378. */
  66379. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66380. /**
  66381. * Unproject from screen space to object space
  66382. * @param sourceX defines the screen space x coordinate to use
  66383. * @param sourceY defines the screen space y coordinate to use
  66384. * @param sourceZ defines the screen space z coordinate to use
  66385. * @param viewportWidth defines the current width of the viewport
  66386. * @param viewportHeight defines the current height of the viewport
  66387. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66388. * @param view defines the view matrix to use
  66389. * @param projection defines the projection matrix to use
  66390. * @param result defines the Vector3 where to store the result
  66391. */
  66392. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66393. /**
  66394. * Gets the minimal coordinate values between two Vector3
  66395. * @param left defines the first operand
  66396. * @param right defines the second operand
  66397. * @returns the new Vector3
  66398. */
  66399. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66400. /**
  66401. * Gets the maximal coordinate values between two Vector3
  66402. * @param left defines the first operand
  66403. * @param right defines the second operand
  66404. * @returns the new Vector3
  66405. */
  66406. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66407. /**
  66408. * Returns the distance between the vectors "value1" and "value2"
  66409. * @param value1 defines the first operand
  66410. * @param value2 defines the second operand
  66411. * @returns the distance
  66412. */
  66413. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66414. /**
  66415. * Returns the squared distance between the vectors "value1" and "value2"
  66416. * @param value1 defines the first operand
  66417. * @param value2 defines the second operand
  66418. * @returns the squared distance
  66419. */
  66420. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66421. /**
  66422. * Returns a new Vector3 located at the center between "value1" and "value2"
  66423. * @param value1 defines the first operand
  66424. * @param value2 defines the second operand
  66425. * @returns the new Vector3
  66426. */
  66427. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66428. /**
  66429. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66430. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66431. * to something in order to rotate it from its local system to the given target system
  66432. * Note: axis1, axis2 and axis3 are normalized during this operation
  66433. * @param axis1 defines the first axis
  66434. * @param axis2 defines the second axis
  66435. * @param axis3 defines the third axis
  66436. * @returns a new Vector3
  66437. */
  66438. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66439. /**
  66440. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66441. * @param axis1 defines the first axis
  66442. * @param axis2 defines the second axis
  66443. * @param axis3 defines the third axis
  66444. * @param ref defines the Vector3 where to store the result
  66445. */
  66446. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66447. }
  66448. /**
  66449. * Vector4 class created for EulerAngle class conversion to Quaternion
  66450. */
  66451. export class Vector4 {
  66452. /** x value of the vector */
  66453. x: number;
  66454. /** y value of the vector */
  66455. y: number;
  66456. /** z value of the vector */
  66457. z: number;
  66458. /** w value of the vector */
  66459. w: number;
  66460. /**
  66461. * Creates a Vector4 object from the given floats.
  66462. * @param x x value of the vector
  66463. * @param y y value of the vector
  66464. * @param z z value of the vector
  66465. * @param w w value of the vector
  66466. */
  66467. constructor(
  66468. /** x value of the vector */
  66469. x: number,
  66470. /** y value of the vector */
  66471. y: number,
  66472. /** z value of the vector */
  66473. z: number,
  66474. /** w value of the vector */
  66475. w: number);
  66476. /**
  66477. * Returns the string with the Vector4 coordinates.
  66478. * @returns a string containing all the vector values
  66479. */
  66480. toString(): string;
  66481. /**
  66482. * Returns the string "Vector4".
  66483. * @returns "Vector4"
  66484. */
  66485. getClassName(): string;
  66486. /**
  66487. * Returns the Vector4 hash code.
  66488. * @returns a unique hash code
  66489. */
  66490. getHashCode(): number;
  66491. /**
  66492. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66493. * @returns the resulting array
  66494. */
  66495. asArray(): number[];
  66496. /**
  66497. * Populates the given array from the given index with the Vector4 coordinates.
  66498. * @param array array to populate
  66499. * @param index index of the array to start at (default: 0)
  66500. * @returns the Vector4.
  66501. */
  66502. toArray(array: FloatArray, index?: number): Vector4;
  66503. /**
  66504. * Adds the given vector to the current Vector4.
  66505. * @param otherVector the vector to add
  66506. * @returns the updated Vector4.
  66507. */
  66508. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66509. /**
  66510. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66511. * @param otherVector the vector to add
  66512. * @returns the resulting vector
  66513. */
  66514. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66515. /**
  66516. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66517. * @param otherVector the vector to add
  66518. * @param result the vector to store the result
  66519. * @returns the current Vector4.
  66520. */
  66521. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66522. /**
  66523. * Subtract in place the given vector from the current Vector4.
  66524. * @param otherVector the vector to subtract
  66525. * @returns the updated Vector4.
  66526. */
  66527. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66528. /**
  66529. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66530. * @param otherVector the vector to add
  66531. * @returns the new vector with the result
  66532. */
  66533. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66534. /**
  66535. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66536. * @param otherVector the vector to subtract
  66537. * @param result the vector to store the result
  66538. * @returns the current Vector4.
  66539. */
  66540. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66541. /**
  66542. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66543. */
  66544. /**
  66545. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66546. * @param x value to subtract
  66547. * @param y value to subtract
  66548. * @param z value to subtract
  66549. * @param w value to subtract
  66550. * @returns new vector containing the result
  66551. */
  66552. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66553. /**
  66554. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66555. * @param x value to subtract
  66556. * @param y value to subtract
  66557. * @param z value to subtract
  66558. * @param w value to subtract
  66559. * @param result the vector to store the result in
  66560. * @returns the current Vector4.
  66561. */
  66562. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66563. /**
  66564. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66565. * @returns a new vector with the negated values
  66566. */
  66567. negate(): Vector4;
  66568. /**
  66569. * Multiplies the current Vector4 coordinates by scale (float).
  66570. * @param scale the number to scale with
  66571. * @returns the updated Vector4.
  66572. */
  66573. scaleInPlace(scale: number): Vector4;
  66574. /**
  66575. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66576. * @param scale the number to scale with
  66577. * @returns a new vector with the result
  66578. */
  66579. scale(scale: number): Vector4;
  66580. /**
  66581. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66582. * @param scale the number to scale with
  66583. * @param result a vector to store the result in
  66584. * @returns the current Vector4.
  66585. */
  66586. scaleToRef(scale: number, result: Vector4): Vector4;
  66587. /**
  66588. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66589. * @param scale defines the scale factor
  66590. * @param result defines the Vector4 object where to store the result
  66591. * @returns the unmodified current Vector4
  66592. */
  66593. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66594. /**
  66595. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66596. * @param otherVector the vector to compare against
  66597. * @returns true if they are equal
  66598. */
  66599. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66600. /**
  66601. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66602. * @param otherVector vector to compare against
  66603. * @param epsilon (Default: very small number)
  66604. * @returns true if they are equal
  66605. */
  66606. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66607. /**
  66608. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66609. * @param x x value to compare against
  66610. * @param y y value to compare against
  66611. * @param z z value to compare against
  66612. * @param w w value to compare against
  66613. * @returns true if equal
  66614. */
  66615. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66616. /**
  66617. * Multiplies in place the current Vector4 by the given one.
  66618. * @param otherVector vector to multiple with
  66619. * @returns the updated Vector4.
  66620. */
  66621. multiplyInPlace(otherVector: Vector4): Vector4;
  66622. /**
  66623. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66624. * @param otherVector vector to multiple with
  66625. * @returns resulting new vector
  66626. */
  66627. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66628. /**
  66629. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66630. * @param otherVector vector to multiple with
  66631. * @param result vector to store the result
  66632. * @returns the current Vector4.
  66633. */
  66634. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66635. /**
  66636. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66637. * @param x x value multiply with
  66638. * @param y y value multiply with
  66639. * @param z z value multiply with
  66640. * @param w w value multiply with
  66641. * @returns resulting new vector
  66642. */
  66643. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66644. /**
  66645. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66646. * @param otherVector vector to devide with
  66647. * @returns resulting new vector
  66648. */
  66649. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66650. /**
  66651. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66652. * @param otherVector vector to devide with
  66653. * @param result vector to store the result
  66654. * @returns the current Vector4.
  66655. */
  66656. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66657. /**
  66658. * Divides the current Vector3 coordinates by the given ones.
  66659. * @param otherVector vector to devide with
  66660. * @returns the updated Vector3.
  66661. */
  66662. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66663. /**
  66664. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66665. * @param other defines the second operand
  66666. * @returns the current updated Vector4
  66667. */
  66668. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66669. /**
  66670. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66671. * @param other defines the second operand
  66672. * @returns the current updated Vector4
  66673. */
  66674. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66675. /**
  66676. * Gets a new Vector4 from current Vector4 floored values
  66677. * @returns a new Vector4
  66678. */
  66679. floor(): Vector4;
  66680. /**
  66681. * Gets a new Vector4 from current Vector3 floored values
  66682. * @returns a new Vector4
  66683. */
  66684. fract(): Vector4;
  66685. /**
  66686. * Returns the Vector4 length (float).
  66687. * @returns the length
  66688. */
  66689. length(): number;
  66690. /**
  66691. * Returns the Vector4 squared length (float).
  66692. * @returns the length squared
  66693. */
  66694. lengthSquared(): number;
  66695. /**
  66696. * Normalizes in place the Vector4.
  66697. * @returns the updated Vector4.
  66698. */
  66699. normalize(): Vector4;
  66700. /**
  66701. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66702. * @returns this converted to a new vector3
  66703. */
  66704. toVector3(): Vector3;
  66705. /**
  66706. * Returns a new Vector4 copied from the current one.
  66707. * @returns the new cloned vector
  66708. */
  66709. clone(): Vector4;
  66710. /**
  66711. * Updates the current Vector4 with the given one coordinates.
  66712. * @param source the source vector to copy from
  66713. * @returns the updated Vector4.
  66714. */
  66715. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66716. /**
  66717. * Updates the current Vector4 coordinates with the given floats.
  66718. * @param x float to copy from
  66719. * @param y float to copy from
  66720. * @param z float to copy from
  66721. * @param w float to copy from
  66722. * @returns the updated Vector4.
  66723. */
  66724. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66725. /**
  66726. * Updates the current Vector4 coordinates with the given floats.
  66727. * @param x float to set from
  66728. * @param y float to set from
  66729. * @param z float to set from
  66730. * @param w float to set from
  66731. * @returns the updated Vector4.
  66732. */
  66733. set(x: number, y: number, z: number, w: number): Vector4;
  66734. /**
  66735. * Copies the given float to the current Vector3 coordinates
  66736. * @param v defines the x, y, z and w coordinates of the operand
  66737. * @returns the current updated Vector3
  66738. */
  66739. setAll(v: number): Vector4;
  66740. /**
  66741. * Returns a new Vector4 set from the starting index of the given array.
  66742. * @param array the array to pull values from
  66743. * @param offset the offset into the array to start at
  66744. * @returns the new vector
  66745. */
  66746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66747. /**
  66748. * Updates the given vector "result" from the starting index of the given array.
  66749. * @param array the array to pull values from
  66750. * @param offset the offset into the array to start at
  66751. * @param result the vector to store the result in
  66752. */
  66753. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66754. /**
  66755. * Updates the given vector "result" from the starting index of the given Float32Array.
  66756. * @param array the array to pull values from
  66757. * @param offset the offset into the array to start at
  66758. * @param result the vector to store the result in
  66759. */
  66760. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  66761. /**
  66762. * Updates the given vector "result" coordinates from the given floats.
  66763. * @param x float to set from
  66764. * @param y float to set from
  66765. * @param z float to set from
  66766. * @param w float to set from
  66767. * @param result the vector to the floats in
  66768. */
  66769. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  66770. /**
  66771. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  66772. * @returns the new vector
  66773. */
  66774. static Zero(): Vector4;
  66775. /**
  66776. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  66777. * @returns the new vector
  66778. */
  66779. static One(): Vector4;
  66780. /**
  66781. * Returns a new normalized Vector4 from the given one.
  66782. * @param vector the vector to normalize
  66783. * @returns the vector
  66784. */
  66785. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  66786. /**
  66787. * Updates the given vector "result" from the normalization of the given one.
  66788. * @param vector the vector to normalize
  66789. * @param result the vector to store the result in
  66790. */
  66791. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66792. /**
  66793. * Returns a vector with the minimum values from the left and right vectors
  66794. * @param left left vector to minimize
  66795. * @param right right vector to minimize
  66796. * @returns a new vector with the minimum of the left and right vector values
  66797. */
  66798. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66799. /**
  66800. * Returns a vector with the maximum values from the left and right vectors
  66801. * @param left left vector to maximize
  66802. * @param right right vector to maximize
  66803. * @returns a new vector with the maximum of the left and right vector values
  66804. */
  66805. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66806. /**
  66807. * Returns the distance (float) between the vectors "value1" and "value2".
  66808. * @param value1 value to calulate the distance between
  66809. * @param value2 value to calulate the distance between
  66810. * @return the distance between the two vectors
  66811. */
  66812. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66813. /**
  66814. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66815. * @param value1 value to calulate the distance between
  66816. * @param value2 value to calulate the distance between
  66817. * @return the distance between the two vectors squared
  66818. */
  66819. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66820. /**
  66821. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66822. * @param value1 value to calulate the center between
  66823. * @param value2 value to calulate the center between
  66824. * @return the center between the two vectors
  66825. */
  66826. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66827. /**
  66828. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66829. * This methods computes transformed normalized direction vectors only.
  66830. * @param vector the vector to transform
  66831. * @param transformation the transformation matrix to apply
  66832. * @returns the new vector
  66833. */
  66834. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66835. /**
  66836. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66837. * This methods computes transformed normalized direction vectors only.
  66838. * @param vector the vector to transform
  66839. * @param transformation the transformation matrix to apply
  66840. * @param result the vector to store the result in
  66841. */
  66842. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66843. /**
  66844. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66845. * This methods computes transformed normalized direction vectors only.
  66846. * @param x value to transform
  66847. * @param y value to transform
  66848. * @param z value to transform
  66849. * @param w value to transform
  66850. * @param transformation the transformation matrix to apply
  66851. * @param result the vector to store the results in
  66852. */
  66853. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66854. /**
  66855. * Creates a new Vector4 from a Vector3
  66856. * @param source defines the source data
  66857. * @param w defines the 4th component (default is 0)
  66858. * @returns a new Vector4
  66859. */
  66860. static FromVector3(source: Vector3, w?: number): Vector4;
  66861. }
  66862. /**
  66863. * Class used to store quaternion data
  66864. * @see https://en.wikipedia.org/wiki/Quaternion
  66865. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66866. */
  66867. export class Quaternion {
  66868. /** defines the first component (0 by default) */
  66869. x: number;
  66870. /** defines the second component (0 by default) */
  66871. y: number;
  66872. /** defines the third component (0 by default) */
  66873. z: number;
  66874. /** defines the fourth component (1.0 by default) */
  66875. w: number;
  66876. /**
  66877. * Creates a new Quaternion from the given floats
  66878. * @param x defines the first component (0 by default)
  66879. * @param y defines the second component (0 by default)
  66880. * @param z defines the third component (0 by default)
  66881. * @param w defines the fourth component (1.0 by default)
  66882. */
  66883. constructor(
  66884. /** defines the first component (0 by default) */
  66885. x?: number,
  66886. /** defines the second component (0 by default) */
  66887. y?: number,
  66888. /** defines the third component (0 by default) */
  66889. z?: number,
  66890. /** defines the fourth component (1.0 by default) */
  66891. w?: number);
  66892. /**
  66893. * Gets a string representation for the current quaternion
  66894. * @returns a string with the Quaternion coordinates
  66895. */
  66896. toString(): string;
  66897. /**
  66898. * Gets the class name of the quaternion
  66899. * @returns the string "Quaternion"
  66900. */
  66901. getClassName(): string;
  66902. /**
  66903. * Gets a hash code for this quaternion
  66904. * @returns the quaternion hash code
  66905. */
  66906. getHashCode(): number;
  66907. /**
  66908. * Copy the quaternion to an array
  66909. * @returns a new array populated with 4 elements from the quaternion coordinates
  66910. */
  66911. asArray(): number[];
  66912. /**
  66913. * Check if two quaternions are equals
  66914. * @param otherQuaternion defines the second operand
  66915. * @return true if the current quaternion and the given one coordinates are strictly equals
  66916. */
  66917. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66918. /**
  66919. * Clone the current quaternion
  66920. * @returns a new quaternion copied from the current one
  66921. */
  66922. clone(): Quaternion;
  66923. /**
  66924. * Copy a quaternion to the current one
  66925. * @param other defines the other quaternion
  66926. * @returns the updated current quaternion
  66927. */
  66928. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66929. /**
  66930. * Updates the current quaternion with the given float coordinates
  66931. * @param x defines the x coordinate
  66932. * @param y defines the y coordinate
  66933. * @param z defines the z coordinate
  66934. * @param w defines the w coordinate
  66935. * @returns the updated current quaternion
  66936. */
  66937. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66938. /**
  66939. * Updates the current quaternion from the given float coordinates
  66940. * @param x defines the x coordinate
  66941. * @param y defines the y coordinate
  66942. * @param z defines the z coordinate
  66943. * @param w defines the w coordinate
  66944. * @returns the updated current quaternion
  66945. */
  66946. set(x: number, y: number, z: number, w: number): Quaternion;
  66947. /**
  66948. * Adds two quaternions
  66949. * @param other defines the second operand
  66950. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66951. */
  66952. add(other: DeepImmutable<Quaternion>): Quaternion;
  66953. /**
  66954. * Add a quaternion to the current one
  66955. * @param other defines the quaternion to add
  66956. * @returns the current quaternion
  66957. */
  66958. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66959. /**
  66960. * Subtract two quaternions
  66961. * @param other defines the second operand
  66962. * @returns a new quaternion as the subtraction result of the given one from the current one
  66963. */
  66964. subtract(other: Quaternion): Quaternion;
  66965. /**
  66966. * Multiplies the current quaternion by a scale factor
  66967. * @param value defines the scale factor
  66968. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66969. */
  66970. scale(value: number): Quaternion;
  66971. /**
  66972. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66973. * @param scale defines the scale factor
  66974. * @param result defines the Quaternion object where to store the result
  66975. * @returns the unmodified current quaternion
  66976. */
  66977. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66978. /**
  66979. * Multiplies in place the current quaternion by a scale factor
  66980. * @param value defines the scale factor
  66981. * @returns the current modified quaternion
  66982. */
  66983. scaleInPlace(value: number): Quaternion;
  66984. /**
  66985. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66986. * @param scale defines the scale factor
  66987. * @param result defines the Quaternion object where to store the result
  66988. * @returns the unmodified current quaternion
  66989. */
  66990. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66991. /**
  66992. * Multiplies two quaternions
  66993. * @param q1 defines the second operand
  66994. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66995. */
  66996. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66997. /**
  66998. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66999. * @param q1 defines the second operand
  67000. * @param result defines the target quaternion
  67001. * @returns the current quaternion
  67002. */
  67003. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67004. /**
  67005. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67006. * @param q1 defines the second operand
  67007. * @returns the currentupdated quaternion
  67008. */
  67009. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67010. /**
  67011. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67012. * @param ref defines the target quaternion
  67013. * @returns the current quaternion
  67014. */
  67015. conjugateToRef(ref: Quaternion): Quaternion;
  67016. /**
  67017. * Conjugates in place (1-q) the current quaternion
  67018. * @returns the current updated quaternion
  67019. */
  67020. conjugateInPlace(): Quaternion;
  67021. /**
  67022. * Conjugates in place (1-q) the current quaternion
  67023. * @returns a new quaternion
  67024. */
  67025. conjugate(): Quaternion;
  67026. /**
  67027. * Gets length of current quaternion
  67028. * @returns the quaternion length (float)
  67029. */
  67030. length(): number;
  67031. /**
  67032. * Normalize in place the current quaternion
  67033. * @returns the current updated quaternion
  67034. */
  67035. normalize(): Quaternion;
  67036. /**
  67037. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67038. * @param order is a reserved parameter and is ignore for now
  67039. * @returns a new Vector3 containing the Euler angles
  67040. */
  67041. toEulerAngles(order?: string): Vector3;
  67042. /**
  67043. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67044. * @param result defines the vector which will be filled with the Euler angles
  67045. * @param order is a reserved parameter and is ignore for now
  67046. * @returns the current unchanged quaternion
  67047. */
  67048. toEulerAnglesToRef(result: Vector3): Quaternion;
  67049. /**
  67050. * Updates the given rotation matrix with the current quaternion values
  67051. * @param result defines the target matrix
  67052. * @returns the current unchanged quaternion
  67053. */
  67054. toRotationMatrix(result: Matrix): Quaternion;
  67055. /**
  67056. * Updates the current quaternion from the given rotation matrix values
  67057. * @param matrix defines the source matrix
  67058. * @returns the current updated quaternion
  67059. */
  67060. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67061. /**
  67062. * Creates a new quaternion from a rotation matrix
  67063. * @param matrix defines the source matrix
  67064. * @returns a new quaternion created from the given rotation matrix values
  67065. */
  67066. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67067. /**
  67068. * Updates the given quaternion with the given rotation matrix values
  67069. * @param matrix defines the source matrix
  67070. * @param result defines the target quaternion
  67071. */
  67072. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67073. /**
  67074. * Returns the dot product (float) between the quaternions "left" and "right"
  67075. * @param left defines the left operand
  67076. * @param right defines the right operand
  67077. * @returns the dot product
  67078. */
  67079. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67080. /**
  67081. * Checks if the two quaternions are close to each other
  67082. * @param quat0 defines the first quaternion to check
  67083. * @param quat1 defines the second quaternion to check
  67084. * @returns true if the two quaternions are close to each other
  67085. */
  67086. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67087. /**
  67088. * Creates an empty quaternion
  67089. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67090. */
  67091. static Zero(): Quaternion;
  67092. /**
  67093. * Inverse a given quaternion
  67094. * @param q defines the source quaternion
  67095. * @returns a new quaternion as the inverted current quaternion
  67096. */
  67097. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67098. /**
  67099. * Inverse a given quaternion
  67100. * @param q defines the source quaternion
  67101. * @param result the quaternion the result will be stored in
  67102. * @returns the result quaternion
  67103. */
  67104. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67105. /**
  67106. * Creates an identity quaternion
  67107. * @returns the identity quaternion
  67108. */
  67109. static Identity(): Quaternion;
  67110. /**
  67111. * Gets a boolean indicating if the given quaternion is identity
  67112. * @param quaternion defines the quaternion to check
  67113. * @returns true if the quaternion is identity
  67114. */
  67115. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67116. /**
  67117. * Creates a quaternion from a rotation around an axis
  67118. * @param axis defines the axis to use
  67119. * @param angle defines the angle to use
  67120. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67121. */
  67122. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67123. /**
  67124. * Creates a rotation around an axis and stores it into the given quaternion
  67125. * @param axis defines the axis to use
  67126. * @param angle defines the angle to use
  67127. * @param result defines the target quaternion
  67128. * @returns the target quaternion
  67129. */
  67130. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67131. /**
  67132. * Creates a new quaternion from data stored into an array
  67133. * @param array defines the data source
  67134. * @param offset defines the offset in the source array where the data starts
  67135. * @returns a new quaternion
  67136. */
  67137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67138. /**
  67139. * Create a quaternion from Euler rotation angles
  67140. * @param x Pitch
  67141. * @param y Yaw
  67142. * @param z Roll
  67143. * @returns the new Quaternion
  67144. */
  67145. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67146. /**
  67147. * Updates a quaternion from Euler rotation angles
  67148. * @param x Pitch
  67149. * @param y Yaw
  67150. * @param z Roll
  67151. * @param result the quaternion to store the result
  67152. * @returns the updated quaternion
  67153. */
  67154. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67155. /**
  67156. * Create a quaternion from Euler rotation vector
  67157. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67158. * @returns the new Quaternion
  67159. */
  67160. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67161. /**
  67162. * Updates a quaternion from Euler rotation vector
  67163. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67164. * @param result the quaternion to store the result
  67165. * @returns the updated quaternion
  67166. */
  67167. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67168. /**
  67169. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67170. * @param yaw defines the rotation around Y axis
  67171. * @param pitch defines the rotation around X axis
  67172. * @param roll defines the rotation around Z axis
  67173. * @returns the new quaternion
  67174. */
  67175. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67176. /**
  67177. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67178. * @param yaw defines the rotation around Y axis
  67179. * @param pitch defines the rotation around X axis
  67180. * @param roll defines the rotation around Z axis
  67181. * @param result defines the target quaternion
  67182. */
  67183. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67184. /**
  67185. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67186. * @param alpha defines the rotation around first axis
  67187. * @param beta defines the rotation around second axis
  67188. * @param gamma defines the rotation around third axis
  67189. * @returns the new quaternion
  67190. */
  67191. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67192. /**
  67193. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67194. * @param alpha defines the rotation around first axis
  67195. * @param beta defines the rotation around second axis
  67196. * @param gamma defines the rotation around third axis
  67197. * @param result defines the target quaternion
  67198. */
  67199. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67200. /**
  67201. * 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)
  67202. * @param axis1 defines the first axis
  67203. * @param axis2 defines the second axis
  67204. * @param axis3 defines the third axis
  67205. * @returns the new quaternion
  67206. */
  67207. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67208. /**
  67209. * 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
  67210. * @param axis1 defines the first axis
  67211. * @param axis2 defines the second axis
  67212. * @param axis3 defines the third axis
  67213. * @param ref defines the target quaternion
  67214. */
  67215. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67216. /**
  67217. * Interpolates between two quaternions
  67218. * @param left defines first quaternion
  67219. * @param right defines second quaternion
  67220. * @param amount defines the gradient to use
  67221. * @returns the new interpolated quaternion
  67222. */
  67223. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67224. /**
  67225. * Interpolates between two quaternions and stores it into a target quaternion
  67226. * @param left defines first quaternion
  67227. * @param right defines second quaternion
  67228. * @param amount defines the gradient to use
  67229. * @param result defines the target quaternion
  67230. */
  67231. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67232. /**
  67233. * Interpolate between two quaternions using Hermite interpolation
  67234. * @param value1 defines first quaternion
  67235. * @param tangent1 defines the incoming tangent
  67236. * @param value2 defines second quaternion
  67237. * @param tangent2 defines the outgoing tangent
  67238. * @param amount defines the target quaternion
  67239. * @returns the new interpolated quaternion
  67240. */
  67241. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67242. }
  67243. /**
  67244. * Class used to store matrix data (4x4)
  67245. */
  67246. export class Matrix {
  67247. private static _updateFlagSeed;
  67248. private static _identityReadOnly;
  67249. private _isIdentity;
  67250. private _isIdentityDirty;
  67251. private _isIdentity3x2;
  67252. private _isIdentity3x2Dirty;
  67253. /**
  67254. * Gets the update flag of the matrix which is an unique number for the matrix.
  67255. * It will be incremented every time the matrix data change.
  67256. * You can use it to speed the comparison between two versions of the same matrix.
  67257. */
  67258. updateFlag: number;
  67259. private readonly _m;
  67260. /**
  67261. * Gets the internal data of the matrix
  67262. */
  67263. readonly m: DeepImmutable<Float32Array>;
  67264. /** @hidden */
  67265. _markAsUpdated(): void;
  67266. /** @hidden */
  67267. private _updateIdentityStatus;
  67268. /**
  67269. * Creates an empty matrix (filled with zeros)
  67270. */
  67271. constructor();
  67272. /**
  67273. * Check if the current matrix is identity
  67274. * @returns true is the matrix is the identity matrix
  67275. */
  67276. isIdentity(): boolean;
  67277. /**
  67278. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67279. * @returns true is the matrix is the identity matrix
  67280. */
  67281. isIdentityAs3x2(): boolean;
  67282. /**
  67283. * Gets the determinant of the matrix
  67284. * @returns the matrix determinant
  67285. */
  67286. determinant(): number;
  67287. /**
  67288. * Returns the matrix as a Float32Array
  67289. * @returns the matrix underlying array
  67290. */
  67291. toArray(): DeepImmutable<Float32Array>;
  67292. /**
  67293. * Returns the matrix as a Float32Array
  67294. * @returns the matrix underlying array.
  67295. */
  67296. asArray(): DeepImmutable<Float32Array>;
  67297. /**
  67298. * Inverts the current matrix in place
  67299. * @returns the current inverted matrix
  67300. */
  67301. invert(): Matrix;
  67302. /**
  67303. * Sets all the matrix elements to zero
  67304. * @returns the current matrix
  67305. */
  67306. reset(): Matrix;
  67307. /**
  67308. * Adds the current matrix with a second one
  67309. * @param other defines the matrix to add
  67310. * @returns a new matrix as the addition of the current matrix and the given one
  67311. */
  67312. add(other: DeepImmutable<Matrix>): Matrix;
  67313. /**
  67314. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67315. * @param other defines the matrix to add
  67316. * @param result defines the target matrix
  67317. * @returns the current matrix
  67318. */
  67319. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67320. /**
  67321. * Adds in place the given matrix to the current matrix
  67322. * @param other defines the second operand
  67323. * @returns the current updated matrix
  67324. */
  67325. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67326. /**
  67327. * Sets the given matrix to the current inverted Matrix
  67328. * @param other defines the target matrix
  67329. * @returns the unmodified current matrix
  67330. */
  67331. invertToRef(other: Matrix): Matrix;
  67332. /**
  67333. * add a value at the specified position in the current Matrix
  67334. * @param index the index of the value within the matrix. between 0 and 15.
  67335. * @param value the value to be added
  67336. * @returns the current updated matrix
  67337. */
  67338. addAtIndex(index: number, value: number): Matrix;
  67339. /**
  67340. * mutiply the specified position in the current Matrix by a value
  67341. * @param index the index of the value within the matrix. between 0 and 15.
  67342. * @param value the value to be added
  67343. * @returns the current updated matrix
  67344. */
  67345. multiplyAtIndex(index: number, value: number): Matrix;
  67346. /**
  67347. * Inserts the translation vector (using 3 floats) in the current matrix
  67348. * @param x defines the 1st component of the translation
  67349. * @param y defines the 2nd component of the translation
  67350. * @param z defines the 3rd component of the translation
  67351. * @returns the current updated matrix
  67352. */
  67353. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67354. /**
  67355. * Adds the translation vector (using 3 floats) in the current matrix
  67356. * @param x defines the 1st component of the translation
  67357. * @param y defines the 2nd component of the translation
  67358. * @param z defines the 3rd component of the translation
  67359. * @returns the current updated matrix
  67360. */
  67361. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67362. /**
  67363. * Inserts the translation vector in the current matrix
  67364. * @param vector3 defines the translation to insert
  67365. * @returns the current updated matrix
  67366. */
  67367. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67368. /**
  67369. * Gets the translation value of the current matrix
  67370. * @returns a new Vector3 as the extracted translation from the matrix
  67371. */
  67372. getTranslation(): Vector3;
  67373. /**
  67374. * Fill a Vector3 with the extracted translation from the matrix
  67375. * @param result defines the Vector3 where to store the translation
  67376. * @returns the current matrix
  67377. */
  67378. getTranslationToRef(result: Vector3): Matrix;
  67379. /**
  67380. * Remove rotation and scaling part from the matrix
  67381. * @returns the updated matrix
  67382. */
  67383. removeRotationAndScaling(): Matrix;
  67384. /**
  67385. * Multiply two matrices
  67386. * @param other defines the second operand
  67387. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67388. */
  67389. multiply(other: DeepImmutable<Matrix>): Matrix;
  67390. /**
  67391. * Copy the current matrix from the given one
  67392. * @param other defines the source matrix
  67393. * @returns the current updated matrix
  67394. */
  67395. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67396. /**
  67397. * Populates the given array from the starting index with the current matrix values
  67398. * @param array defines the target array
  67399. * @param offset defines the offset in the target array where to start storing values
  67400. * @returns the current matrix
  67401. */
  67402. copyToArray(array: Float32Array, offset?: number): Matrix;
  67403. /**
  67404. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67405. * @param other defines the second operand
  67406. * @param result defines the matrix where to store the multiplication
  67407. * @returns the current matrix
  67408. */
  67409. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67410. /**
  67411. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67412. * @param other defines the second operand
  67413. * @param result defines the array where to store the multiplication
  67414. * @param offset defines the offset in the target array where to start storing values
  67415. * @returns the current matrix
  67416. */
  67417. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67418. /**
  67419. * Check equality between this matrix and a second one
  67420. * @param value defines the second matrix to compare
  67421. * @returns true is the current matrix and the given one values are strictly equal
  67422. */
  67423. equals(value: DeepImmutable<Matrix>): boolean;
  67424. /**
  67425. * Clone the current matrix
  67426. * @returns a new matrix from the current matrix
  67427. */
  67428. clone(): Matrix;
  67429. /**
  67430. * Returns the name of the current matrix class
  67431. * @returns the string "Matrix"
  67432. */
  67433. getClassName(): string;
  67434. /**
  67435. * Gets the hash code of the current matrix
  67436. * @returns the hash code
  67437. */
  67438. getHashCode(): number;
  67439. /**
  67440. * Decomposes the current Matrix into a translation, rotation and scaling components
  67441. * @param scale defines the scale vector3 given as a reference to update
  67442. * @param rotation defines the rotation quaternion given as a reference to update
  67443. * @param translation defines the translation vector3 given as a reference to update
  67444. * @returns true if operation was successful
  67445. */
  67446. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67447. /**
  67448. * Gets specific row of the matrix
  67449. * @param index defines the number of the row to get
  67450. * @returns the index-th row of the current matrix as a new Vector4
  67451. */
  67452. getRow(index: number): Nullable<Vector4>;
  67453. /**
  67454. * Sets the index-th row of the current matrix to the vector4 values
  67455. * @param index defines the number of the row to set
  67456. * @param row defines the target vector4
  67457. * @returns the updated current matrix
  67458. */
  67459. setRow(index: number, row: Vector4): Matrix;
  67460. /**
  67461. * Compute the transpose of the matrix
  67462. * @returns the new transposed matrix
  67463. */
  67464. transpose(): Matrix;
  67465. /**
  67466. * Compute the transpose of the matrix and store it in a given matrix
  67467. * @param result defines the target matrix
  67468. * @returns the current matrix
  67469. */
  67470. transposeToRef(result: Matrix): Matrix;
  67471. /**
  67472. * Sets the index-th row of the current matrix with the given 4 x float values
  67473. * @param index defines the row index
  67474. * @param x defines the x component to set
  67475. * @param y defines the y component to set
  67476. * @param z defines the z component to set
  67477. * @param w defines the w component to set
  67478. * @returns the updated current matrix
  67479. */
  67480. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67481. /**
  67482. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67483. * @param scale defines the scale factor
  67484. * @returns a new matrix
  67485. */
  67486. scale(scale: number): Matrix;
  67487. /**
  67488. * Scale the current matrix values by a factor to a given result matrix
  67489. * @param scale defines the scale factor
  67490. * @param result defines the matrix to store the result
  67491. * @returns the current matrix
  67492. */
  67493. scaleToRef(scale: number, result: Matrix): Matrix;
  67494. /**
  67495. * Scale the current matrix values by a factor and add the result to a given matrix
  67496. * @param scale defines the scale factor
  67497. * @param result defines the Matrix to store the result
  67498. * @returns the current matrix
  67499. */
  67500. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67501. /**
  67502. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67503. * @param ref matrix to store the result
  67504. */
  67505. toNormalMatrix(ref: Matrix): void;
  67506. /**
  67507. * Gets only rotation part of the current matrix
  67508. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67509. */
  67510. getRotationMatrix(): Matrix;
  67511. /**
  67512. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67513. * @param result defines the target matrix to store data to
  67514. * @returns the current matrix
  67515. */
  67516. getRotationMatrixToRef(result: Matrix): Matrix;
  67517. /**
  67518. * Toggles model matrix from being right handed to left handed in place and vice versa
  67519. */
  67520. toggleModelMatrixHandInPlace(): void;
  67521. /**
  67522. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67523. */
  67524. toggleProjectionMatrixHandInPlace(): void;
  67525. /**
  67526. * Creates a matrix from an array
  67527. * @param array defines the source array
  67528. * @param offset defines an offset in the source array
  67529. * @returns a new Matrix set from the starting index of the given array
  67530. */
  67531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67532. /**
  67533. * Copy the content of an array into a given matrix
  67534. * @param array defines the source array
  67535. * @param offset defines an offset in the source array
  67536. * @param result defines the target matrix
  67537. */
  67538. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67539. /**
  67540. * Stores an array into a matrix after having multiplied each component by a given factor
  67541. * @param array defines the source array
  67542. * @param offset defines the offset in the source array
  67543. * @param scale defines the scaling factor
  67544. * @param result defines the target matrix
  67545. */
  67546. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67547. /**
  67548. * Gets an identity matrix that must not be updated
  67549. */
  67550. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67551. /**
  67552. * Stores a list of values (16) inside a given matrix
  67553. * @param initialM11 defines 1st value of 1st row
  67554. * @param initialM12 defines 2nd value of 1st row
  67555. * @param initialM13 defines 3rd value of 1st row
  67556. * @param initialM14 defines 4th value of 1st row
  67557. * @param initialM21 defines 1st value of 2nd row
  67558. * @param initialM22 defines 2nd value of 2nd row
  67559. * @param initialM23 defines 3rd value of 2nd row
  67560. * @param initialM24 defines 4th value of 2nd row
  67561. * @param initialM31 defines 1st value of 3rd row
  67562. * @param initialM32 defines 2nd value of 3rd row
  67563. * @param initialM33 defines 3rd value of 3rd row
  67564. * @param initialM34 defines 4th value of 3rd row
  67565. * @param initialM41 defines 1st value of 4th row
  67566. * @param initialM42 defines 2nd value of 4th row
  67567. * @param initialM43 defines 3rd value of 4th row
  67568. * @param initialM44 defines 4th value of 4th row
  67569. * @param result defines the target matrix
  67570. */
  67571. 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;
  67572. /**
  67573. * Creates new matrix from a list of values (16)
  67574. * @param initialM11 defines 1st value of 1st row
  67575. * @param initialM12 defines 2nd value of 1st row
  67576. * @param initialM13 defines 3rd value of 1st row
  67577. * @param initialM14 defines 4th value of 1st row
  67578. * @param initialM21 defines 1st value of 2nd row
  67579. * @param initialM22 defines 2nd value of 2nd row
  67580. * @param initialM23 defines 3rd value of 2nd row
  67581. * @param initialM24 defines 4th value of 2nd row
  67582. * @param initialM31 defines 1st value of 3rd row
  67583. * @param initialM32 defines 2nd value of 3rd row
  67584. * @param initialM33 defines 3rd value of 3rd row
  67585. * @param initialM34 defines 4th value of 3rd row
  67586. * @param initialM41 defines 1st value of 4th row
  67587. * @param initialM42 defines 2nd value of 4th row
  67588. * @param initialM43 defines 3rd value of 4th row
  67589. * @param initialM44 defines 4th value of 4th row
  67590. * @returns the new matrix
  67591. */
  67592. 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;
  67593. /**
  67594. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67595. * @param scale defines the scale vector3
  67596. * @param rotation defines the rotation quaternion
  67597. * @param translation defines the translation vector3
  67598. * @returns a new matrix
  67599. */
  67600. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67601. /**
  67602. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67603. * @param scale defines the scale vector3
  67604. * @param rotation defines the rotation quaternion
  67605. * @param translation defines the translation vector3
  67606. * @param result defines the target matrix
  67607. */
  67608. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67609. /**
  67610. * Creates a new identity matrix
  67611. * @returns a new identity matrix
  67612. */
  67613. static Identity(): Matrix;
  67614. /**
  67615. * Creates a new identity matrix and stores the result in a given matrix
  67616. * @param result defines the target matrix
  67617. */
  67618. static IdentityToRef(result: Matrix): void;
  67619. /**
  67620. * Creates a new zero matrix
  67621. * @returns a new zero matrix
  67622. */
  67623. static Zero(): Matrix;
  67624. /**
  67625. * Creates a new rotation matrix for "angle" radians around the X axis
  67626. * @param angle defines the angle (in radians) to use
  67627. * @return the new matrix
  67628. */
  67629. static RotationX(angle: number): Matrix;
  67630. /**
  67631. * Creates a new matrix as the invert of a given matrix
  67632. * @param source defines the source matrix
  67633. * @returns the new matrix
  67634. */
  67635. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67636. /**
  67637. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67638. * @param angle defines the angle (in radians) to use
  67639. * @param result defines the target matrix
  67640. */
  67641. static RotationXToRef(angle: number, result: Matrix): void;
  67642. /**
  67643. * Creates a new rotation matrix for "angle" radians around the Y axis
  67644. * @param angle defines the angle (in radians) to use
  67645. * @return the new matrix
  67646. */
  67647. static RotationY(angle: number): Matrix;
  67648. /**
  67649. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67650. * @param angle defines the angle (in radians) to use
  67651. * @param result defines the target matrix
  67652. */
  67653. static RotationYToRef(angle: number, result: Matrix): void;
  67654. /**
  67655. * Creates a new rotation matrix for "angle" radians around the Z axis
  67656. * @param angle defines the angle (in radians) to use
  67657. * @return the new matrix
  67658. */
  67659. static RotationZ(angle: number): Matrix;
  67660. /**
  67661. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67662. * @param angle defines the angle (in radians) to use
  67663. * @param result defines the target matrix
  67664. */
  67665. static RotationZToRef(angle: number, result: Matrix): void;
  67666. /**
  67667. * Creates a new rotation matrix for "angle" radians around the given axis
  67668. * @param axis defines the axis to use
  67669. * @param angle defines the angle (in radians) to use
  67670. * @return the new matrix
  67671. */
  67672. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67673. /**
  67674. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67675. * @param axis defines the axis to use
  67676. * @param angle defines the angle (in radians) to use
  67677. * @param result defines the target matrix
  67678. */
  67679. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67680. /**
  67681. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67682. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67683. * @param from defines the vector to align
  67684. * @param to defines the vector to align to
  67685. * @param result defines the target matrix
  67686. */
  67687. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67688. /**
  67689. * Creates a rotation matrix
  67690. * @param yaw defines the yaw angle in radians (Y axis)
  67691. * @param pitch defines the pitch angle in radians (X axis)
  67692. * @param roll defines the roll angle in radians (X axis)
  67693. * @returns the new rotation matrix
  67694. */
  67695. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67696. /**
  67697. * Creates a rotation matrix and stores it in a given matrix
  67698. * @param yaw defines the yaw angle in radians (Y axis)
  67699. * @param pitch defines the pitch angle in radians (X axis)
  67700. * @param roll defines the roll angle in radians (X axis)
  67701. * @param result defines the target matrix
  67702. */
  67703. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67704. /**
  67705. * Creates a scaling matrix
  67706. * @param x defines the scale factor on X axis
  67707. * @param y defines the scale factor on Y axis
  67708. * @param z defines the scale factor on Z axis
  67709. * @returns the new matrix
  67710. */
  67711. static Scaling(x: number, y: number, z: number): Matrix;
  67712. /**
  67713. * Creates a scaling matrix and stores it in a given matrix
  67714. * @param x defines the scale factor on X axis
  67715. * @param y defines the scale factor on Y axis
  67716. * @param z defines the scale factor on Z axis
  67717. * @param result defines the target matrix
  67718. */
  67719. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67720. /**
  67721. * Creates a translation matrix
  67722. * @param x defines the translation on X axis
  67723. * @param y defines the translation on Y axis
  67724. * @param z defines the translationon Z axis
  67725. * @returns the new matrix
  67726. */
  67727. static Translation(x: number, y: number, z: number): Matrix;
  67728. /**
  67729. * Creates a translation matrix and stores it in a given matrix
  67730. * @param x defines the translation on X axis
  67731. * @param y defines the translation on Y axis
  67732. * @param z defines the translationon Z axis
  67733. * @param result defines the target matrix
  67734. */
  67735. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67736. /**
  67737. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67738. * @param startValue defines the start value
  67739. * @param endValue defines the end value
  67740. * @param gradient defines the gradient factor
  67741. * @returns the new matrix
  67742. */
  67743. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67744. /**
  67745. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67746. * @param startValue defines the start value
  67747. * @param endValue defines the end value
  67748. * @param gradient defines the gradient factor
  67749. * @param result defines the Matrix object where to store data
  67750. */
  67751. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67752. /**
  67753. * Builds a new matrix whose values are computed by:
  67754. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67755. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67756. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67757. * @param startValue defines the first matrix
  67758. * @param endValue defines the second matrix
  67759. * @param gradient defines the gradient between the two matrices
  67760. * @returns the new matrix
  67761. */
  67762. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67763. /**
  67764. * Update a matrix to values which are computed by:
  67765. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67766. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67767. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67768. * @param startValue defines the first matrix
  67769. * @param endValue defines the second matrix
  67770. * @param gradient defines the gradient between the two matrices
  67771. * @param result defines the target matrix
  67772. */
  67773. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67774. /**
  67775. * 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"
  67776. * This function works in left handed mode
  67777. * @param eye defines the final position of the entity
  67778. * @param target defines where the entity should look at
  67779. * @param up defines the up vector for the entity
  67780. * @returns the new matrix
  67781. */
  67782. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67783. /**
  67784. * 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".
  67785. * This function works in left handed mode
  67786. * @param eye defines the final position of the entity
  67787. * @param target defines where the entity should look at
  67788. * @param up defines the up vector for the entity
  67789. * @param result defines the target matrix
  67790. */
  67791. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67792. /**
  67793. * 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"
  67794. * This function works in right handed mode
  67795. * @param eye defines the final position of the entity
  67796. * @param target defines where the entity should look at
  67797. * @param up defines the up vector for the entity
  67798. * @returns the new matrix
  67799. */
  67800. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67801. /**
  67802. * 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".
  67803. * This function works in right handed mode
  67804. * @param eye defines the final position of the entity
  67805. * @param target defines where the entity should look at
  67806. * @param up defines the up vector for the entity
  67807. * @param result defines the target matrix
  67808. */
  67809. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67810. /**
  67811. * Create a left-handed orthographic projection matrix
  67812. * @param width defines the viewport width
  67813. * @param height defines the viewport height
  67814. * @param znear defines the near clip plane
  67815. * @param zfar defines the far clip plane
  67816. * @returns a new matrix as a left-handed orthographic projection matrix
  67817. */
  67818. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67819. /**
  67820. * Store a left-handed orthographic projection to a given matrix
  67821. * @param width defines the viewport width
  67822. * @param height defines the viewport height
  67823. * @param znear defines the near clip plane
  67824. * @param zfar defines the far clip plane
  67825. * @param result defines the target matrix
  67826. */
  67827. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67828. /**
  67829. * Create a left-handed orthographic projection matrix
  67830. * @param left defines the viewport left coordinate
  67831. * @param right defines the viewport right coordinate
  67832. * @param bottom defines the viewport bottom coordinate
  67833. * @param top defines the viewport top coordinate
  67834. * @param znear defines the near clip plane
  67835. * @param zfar defines the far clip plane
  67836. * @returns a new matrix as a left-handed orthographic projection matrix
  67837. */
  67838. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67839. /**
  67840. * Stores a left-handed orthographic projection into a given matrix
  67841. * @param left defines the viewport left coordinate
  67842. * @param right defines the viewport right coordinate
  67843. * @param bottom defines the viewport bottom coordinate
  67844. * @param top defines the viewport top coordinate
  67845. * @param znear defines the near clip plane
  67846. * @param zfar defines the far clip plane
  67847. * @param result defines the target matrix
  67848. */
  67849. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67850. /**
  67851. * Creates a right-handed orthographic projection matrix
  67852. * @param left defines the viewport left coordinate
  67853. * @param right defines the viewport right coordinate
  67854. * @param bottom defines the viewport bottom coordinate
  67855. * @param top defines the viewport top coordinate
  67856. * @param znear defines the near clip plane
  67857. * @param zfar defines the far clip plane
  67858. * @returns a new matrix as a right-handed orthographic projection matrix
  67859. */
  67860. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67861. /**
  67862. * Stores a right-handed orthographic projection into a given matrix
  67863. * @param left defines the viewport left coordinate
  67864. * @param right defines the viewport right coordinate
  67865. * @param bottom defines the viewport bottom coordinate
  67866. * @param top defines the viewport top coordinate
  67867. * @param znear defines the near clip plane
  67868. * @param zfar defines the far clip plane
  67869. * @param result defines the target matrix
  67870. */
  67871. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67872. /**
  67873. * Creates a left-handed perspective projection matrix
  67874. * @param width defines the viewport width
  67875. * @param height defines the viewport height
  67876. * @param znear defines the near clip plane
  67877. * @param zfar defines the far clip plane
  67878. * @returns a new matrix as a left-handed perspective projection matrix
  67879. */
  67880. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67881. /**
  67882. * Creates a left-handed perspective projection matrix
  67883. * @param fov defines the horizontal field of view
  67884. * @param aspect defines the aspect ratio
  67885. * @param znear defines the near clip plane
  67886. * @param zfar defines the far clip plane
  67887. * @returns a new matrix as a left-handed perspective projection matrix
  67888. */
  67889. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67890. /**
  67891. * Stores a left-handed perspective projection into a given matrix
  67892. * @param fov defines the horizontal field of view
  67893. * @param aspect defines the aspect ratio
  67894. * @param znear defines the near clip plane
  67895. * @param zfar defines the far clip plane
  67896. * @param result defines the target matrix
  67897. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67898. */
  67899. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67900. /**
  67901. * Creates a right-handed perspective projection matrix
  67902. * @param fov defines the horizontal field of view
  67903. * @param aspect defines the aspect ratio
  67904. * @param znear defines the near clip plane
  67905. * @param zfar defines the far clip plane
  67906. * @returns a new matrix as a right-handed perspective projection matrix
  67907. */
  67908. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67909. /**
  67910. * Stores a right-handed perspective projection into a given matrix
  67911. * @param fov defines the horizontal field of view
  67912. * @param aspect defines the aspect ratio
  67913. * @param znear defines the near clip plane
  67914. * @param zfar defines the far clip plane
  67915. * @param result defines the target matrix
  67916. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67917. */
  67918. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67919. /**
  67920. * Stores a perspective projection for WebVR info a given matrix
  67921. * @param fov defines the field of view
  67922. * @param znear defines the near clip plane
  67923. * @param zfar defines the far clip plane
  67924. * @param result defines the target matrix
  67925. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67926. */
  67927. static PerspectiveFovWebVRToRef(fov: {
  67928. upDegrees: number;
  67929. downDegrees: number;
  67930. leftDegrees: number;
  67931. rightDegrees: number;
  67932. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67933. /**
  67934. * Computes a complete transformation matrix
  67935. * @param viewport defines the viewport to use
  67936. * @param world defines the world matrix
  67937. * @param view defines the view matrix
  67938. * @param projection defines the projection matrix
  67939. * @param zmin defines the near clip plane
  67940. * @param zmax defines the far clip plane
  67941. * @returns the transformation matrix
  67942. */
  67943. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67944. /**
  67945. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67946. * @param matrix defines the matrix to use
  67947. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67948. */
  67949. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67950. /**
  67951. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67952. * @param matrix defines the matrix to use
  67953. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67954. */
  67955. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67956. /**
  67957. * Compute the transpose of a given matrix
  67958. * @param matrix defines the matrix to transpose
  67959. * @returns the new matrix
  67960. */
  67961. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67962. /**
  67963. * Compute the transpose of a matrix and store it in a target matrix
  67964. * @param matrix defines the matrix to transpose
  67965. * @param result defines the target matrix
  67966. */
  67967. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67968. /**
  67969. * Computes a reflection matrix from a plane
  67970. * @param plane defines the reflection plane
  67971. * @returns a new matrix
  67972. */
  67973. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67974. /**
  67975. * Computes a reflection matrix from a plane
  67976. * @param plane defines the reflection plane
  67977. * @param result defines the target matrix
  67978. */
  67979. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67980. /**
  67981. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67982. * @param xaxis defines the value of the 1st axis
  67983. * @param yaxis defines the value of the 2nd axis
  67984. * @param zaxis defines the value of the 3rd axis
  67985. * @param result defines the target matrix
  67986. */
  67987. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67988. /**
  67989. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67990. * @param quat defines the quaternion to use
  67991. * @param result defines the target matrix
  67992. */
  67993. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67994. }
  67995. /**
  67996. * @hidden
  67997. */
  67998. export class TmpVectors {
  67999. static Vector2: Vector2[];
  68000. static Vector3: Vector3[];
  68001. static Vector4: Vector4[];
  68002. static Quaternion: Quaternion[];
  68003. static Matrix: Matrix[];
  68004. }
  68005. }
  68006. declare module BABYLON {
  68007. /** Defines the cross module used constants to avoid circular dependncies */
  68008. export class Constants {
  68009. /** Defines that alpha blending is disabled */
  68010. static readonly ALPHA_DISABLE: number;
  68011. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68012. static readonly ALPHA_ADD: number;
  68013. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68014. static readonly ALPHA_COMBINE: number;
  68015. /** Defines that alpha blending to DEST - SRC * DEST */
  68016. static readonly ALPHA_SUBTRACT: number;
  68017. /** Defines that alpha blending to SRC * DEST */
  68018. static readonly ALPHA_MULTIPLY: number;
  68019. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68020. static readonly ALPHA_MAXIMIZED: number;
  68021. /** Defines that alpha blending to SRC + DEST */
  68022. static readonly ALPHA_ONEONE: number;
  68023. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68024. static readonly ALPHA_PREMULTIPLIED: number;
  68025. /**
  68026. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68027. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68028. */
  68029. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68030. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68031. static readonly ALPHA_INTERPOLATE: number;
  68032. /**
  68033. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68034. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68035. */
  68036. static readonly ALPHA_SCREENMODE: number;
  68037. /** Defines that the ressource is not delayed*/
  68038. static readonly DELAYLOADSTATE_NONE: number;
  68039. /** Defines that the ressource was successfully delay loaded */
  68040. static readonly DELAYLOADSTATE_LOADED: number;
  68041. /** Defines that the ressource is currently delay loading */
  68042. static readonly DELAYLOADSTATE_LOADING: number;
  68043. /** Defines that the ressource is delayed and has not started loading */
  68044. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68045. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68046. static readonly NEVER: number;
  68047. /** 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 */
  68048. static readonly ALWAYS: number;
  68049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68050. static readonly LESS: number;
  68051. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68052. static readonly EQUAL: number;
  68053. /** 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 */
  68054. static readonly LEQUAL: number;
  68055. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68056. static readonly GREATER: number;
  68057. /** 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 */
  68058. static readonly GEQUAL: number;
  68059. /** 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 */
  68060. static readonly NOTEQUAL: number;
  68061. /** Passed to stencilOperation to specify that stencil value must be kept */
  68062. static readonly KEEP: number;
  68063. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68064. static readonly REPLACE: number;
  68065. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68066. static readonly INCR: number;
  68067. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68068. static readonly DECR: number;
  68069. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68070. static readonly INVERT: number;
  68071. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68072. static readonly INCR_WRAP: number;
  68073. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68074. static readonly DECR_WRAP: number;
  68075. /** Texture is not repeating outside of 0..1 UVs */
  68076. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68077. /** Texture is repeating outside of 0..1 UVs */
  68078. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68079. /** Texture is repeating and mirrored */
  68080. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68081. /** ALPHA */
  68082. static readonly TEXTUREFORMAT_ALPHA: number;
  68083. /** LUMINANCE */
  68084. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68085. /** LUMINANCE_ALPHA */
  68086. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68087. /** RGB */
  68088. static readonly TEXTUREFORMAT_RGB: number;
  68089. /** RGBA */
  68090. static readonly TEXTUREFORMAT_RGBA: number;
  68091. /** RED */
  68092. static readonly TEXTUREFORMAT_RED: number;
  68093. /** RED (2nd reference) */
  68094. static readonly TEXTUREFORMAT_R: number;
  68095. /** RG */
  68096. static readonly TEXTUREFORMAT_RG: number;
  68097. /** RED_INTEGER */
  68098. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68099. /** RED_INTEGER (2nd reference) */
  68100. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68101. /** RG_INTEGER */
  68102. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68103. /** RGB_INTEGER */
  68104. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68105. /** RGBA_INTEGER */
  68106. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68107. /** UNSIGNED_BYTE */
  68108. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68109. /** UNSIGNED_BYTE (2nd reference) */
  68110. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68111. /** FLOAT */
  68112. static readonly TEXTURETYPE_FLOAT: number;
  68113. /** HALF_FLOAT */
  68114. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68115. /** BYTE */
  68116. static readonly TEXTURETYPE_BYTE: number;
  68117. /** SHORT */
  68118. static readonly TEXTURETYPE_SHORT: number;
  68119. /** UNSIGNED_SHORT */
  68120. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68121. /** INT */
  68122. static readonly TEXTURETYPE_INT: number;
  68123. /** UNSIGNED_INT */
  68124. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68125. /** UNSIGNED_SHORT_4_4_4_4 */
  68126. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68127. /** UNSIGNED_SHORT_5_5_5_1 */
  68128. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68129. /** UNSIGNED_SHORT_5_6_5 */
  68130. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68131. /** UNSIGNED_INT_2_10_10_10_REV */
  68132. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68133. /** UNSIGNED_INT_24_8 */
  68134. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68135. /** UNSIGNED_INT_10F_11F_11F_REV */
  68136. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68137. /** UNSIGNED_INT_5_9_9_9_REV */
  68138. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68139. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68140. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68141. /** nearest is mag = nearest and min = nearest and mip = linear */
  68142. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68143. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68144. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68145. /** Trilinear is mag = linear and min = linear and mip = linear */
  68146. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68147. /** nearest is mag = nearest and min = nearest and mip = linear */
  68148. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68149. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68150. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68151. /** Trilinear is mag = linear and min = linear and mip = linear */
  68152. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68153. /** mag = nearest and min = nearest and mip = nearest */
  68154. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68155. /** mag = nearest and min = linear and mip = nearest */
  68156. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68157. /** mag = nearest and min = linear and mip = linear */
  68158. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68159. /** mag = nearest and min = linear and mip = none */
  68160. static readonly TEXTURE_NEAREST_LINEAR: number;
  68161. /** mag = nearest and min = nearest and mip = none */
  68162. static readonly TEXTURE_NEAREST_NEAREST: number;
  68163. /** mag = linear and min = nearest and mip = nearest */
  68164. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68165. /** mag = linear and min = nearest and mip = linear */
  68166. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68167. /** mag = linear and min = linear and mip = none */
  68168. static readonly TEXTURE_LINEAR_LINEAR: number;
  68169. /** mag = linear and min = nearest and mip = none */
  68170. static readonly TEXTURE_LINEAR_NEAREST: number;
  68171. /** Explicit coordinates mode */
  68172. static readonly TEXTURE_EXPLICIT_MODE: number;
  68173. /** Spherical coordinates mode */
  68174. static readonly TEXTURE_SPHERICAL_MODE: number;
  68175. /** Planar coordinates mode */
  68176. static readonly TEXTURE_PLANAR_MODE: number;
  68177. /** Cubic coordinates mode */
  68178. static readonly TEXTURE_CUBIC_MODE: number;
  68179. /** Projection coordinates mode */
  68180. static readonly TEXTURE_PROJECTION_MODE: number;
  68181. /** Skybox coordinates mode */
  68182. static readonly TEXTURE_SKYBOX_MODE: number;
  68183. /** Inverse Cubic coordinates mode */
  68184. static readonly TEXTURE_INVCUBIC_MODE: number;
  68185. /** Equirectangular coordinates mode */
  68186. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68187. /** Equirectangular Fixed coordinates mode */
  68188. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68189. /** Equirectangular Fixed Mirrored coordinates mode */
  68190. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68191. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68192. static readonly SCALEMODE_FLOOR: number;
  68193. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68194. static readonly SCALEMODE_NEAREST: number;
  68195. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68196. static readonly SCALEMODE_CEILING: number;
  68197. /**
  68198. * The dirty texture flag value
  68199. */
  68200. static readonly MATERIAL_TextureDirtyFlag: number;
  68201. /**
  68202. * The dirty light flag value
  68203. */
  68204. static readonly MATERIAL_LightDirtyFlag: number;
  68205. /**
  68206. * The dirty fresnel flag value
  68207. */
  68208. static readonly MATERIAL_FresnelDirtyFlag: number;
  68209. /**
  68210. * The dirty attribute flag value
  68211. */
  68212. static readonly MATERIAL_AttributesDirtyFlag: number;
  68213. /**
  68214. * The dirty misc flag value
  68215. */
  68216. static readonly MATERIAL_MiscDirtyFlag: number;
  68217. /**
  68218. * The all dirty flag value
  68219. */
  68220. static readonly MATERIAL_AllDirtyFlag: number;
  68221. /**
  68222. * Returns the triangle fill mode
  68223. */
  68224. static readonly MATERIAL_TriangleFillMode: number;
  68225. /**
  68226. * Returns the wireframe mode
  68227. */
  68228. static readonly MATERIAL_WireFrameFillMode: number;
  68229. /**
  68230. * Returns the point fill mode
  68231. */
  68232. static readonly MATERIAL_PointFillMode: number;
  68233. /**
  68234. * Returns the point list draw mode
  68235. */
  68236. static readonly MATERIAL_PointListDrawMode: number;
  68237. /**
  68238. * Returns the line list draw mode
  68239. */
  68240. static readonly MATERIAL_LineListDrawMode: number;
  68241. /**
  68242. * Returns the line loop draw mode
  68243. */
  68244. static readonly MATERIAL_LineLoopDrawMode: number;
  68245. /**
  68246. * Returns the line strip draw mode
  68247. */
  68248. static readonly MATERIAL_LineStripDrawMode: number;
  68249. /**
  68250. * Returns the triangle strip draw mode
  68251. */
  68252. static readonly MATERIAL_TriangleStripDrawMode: number;
  68253. /**
  68254. * Returns the triangle fan draw mode
  68255. */
  68256. static readonly MATERIAL_TriangleFanDrawMode: number;
  68257. /**
  68258. * Stores the clock-wise side orientation
  68259. */
  68260. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68261. /**
  68262. * Stores the counter clock-wise side orientation
  68263. */
  68264. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68265. /**
  68266. * Nothing
  68267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68268. */
  68269. static readonly ACTION_NothingTrigger: number;
  68270. /**
  68271. * On pick
  68272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68273. */
  68274. static readonly ACTION_OnPickTrigger: number;
  68275. /**
  68276. * On left pick
  68277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68278. */
  68279. static readonly ACTION_OnLeftPickTrigger: number;
  68280. /**
  68281. * On right pick
  68282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68283. */
  68284. static readonly ACTION_OnRightPickTrigger: number;
  68285. /**
  68286. * On center pick
  68287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68288. */
  68289. static readonly ACTION_OnCenterPickTrigger: number;
  68290. /**
  68291. * On pick down
  68292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68293. */
  68294. static readonly ACTION_OnPickDownTrigger: number;
  68295. /**
  68296. * On double pick
  68297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68298. */
  68299. static readonly ACTION_OnDoublePickTrigger: number;
  68300. /**
  68301. * On pick up
  68302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68303. */
  68304. static readonly ACTION_OnPickUpTrigger: number;
  68305. /**
  68306. * On pick out.
  68307. * This trigger will only be raised if you also declared a OnPickDown
  68308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68309. */
  68310. static readonly ACTION_OnPickOutTrigger: number;
  68311. /**
  68312. * On long press
  68313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68314. */
  68315. static readonly ACTION_OnLongPressTrigger: number;
  68316. /**
  68317. * On pointer over
  68318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68319. */
  68320. static readonly ACTION_OnPointerOverTrigger: number;
  68321. /**
  68322. * On pointer out
  68323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68324. */
  68325. static readonly ACTION_OnPointerOutTrigger: number;
  68326. /**
  68327. * On every frame
  68328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68329. */
  68330. static readonly ACTION_OnEveryFrameTrigger: number;
  68331. /**
  68332. * On intersection enter
  68333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68334. */
  68335. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68336. /**
  68337. * On intersection exit
  68338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68339. */
  68340. static readonly ACTION_OnIntersectionExitTrigger: number;
  68341. /**
  68342. * On key down
  68343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68344. */
  68345. static readonly ACTION_OnKeyDownTrigger: number;
  68346. /**
  68347. * On key up
  68348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68349. */
  68350. static readonly ACTION_OnKeyUpTrigger: number;
  68351. /**
  68352. * Billboard mode will only apply to Y axis
  68353. */
  68354. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68355. /**
  68356. * Billboard mode will apply to all axes
  68357. */
  68358. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68359. /**
  68360. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68361. */
  68362. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68363. /**
  68364. * Gets or sets base Assets URL
  68365. */
  68366. static PARTICLES_BaseAssetsUrl: string;
  68367. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68368. * Test order :
  68369. * Is the bounding sphere outside the frustum ?
  68370. * If not, are the bounding box vertices outside the frustum ?
  68371. * It not, then the cullable object is in the frustum.
  68372. */
  68373. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68374. /** Culling strategy : Bounding Sphere Only.
  68375. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68376. * It's also less accurate than the standard because some not visible objects can still be selected.
  68377. * Test : is the bounding sphere outside the frustum ?
  68378. * If not, then the cullable object is in the frustum.
  68379. */
  68380. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68381. /** Culling strategy : Optimistic Inclusion.
  68382. * This in an inclusion test first, then the standard exclusion test.
  68383. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68384. * 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.
  68385. * Anyway, it's as accurate as the standard strategy.
  68386. * Test :
  68387. * Is the cullable object bounding sphere center in the frustum ?
  68388. * If not, apply the default culling strategy.
  68389. */
  68390. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68391. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68392. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68393. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68394. * 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.
  68395. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68396. * Test :
  68397. * Is the cullable object bounding sphere center in the frustum ?
  68398. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68399. */
  68400. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68401. /**
  68402. * No logging while loading
  68403. */
  68404. static readonly SCENELOADER_NO_LOGGING: number;
  68405. /**
  68406. * Minimal logging while loading
  68407. */
  68408. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68409. /**
  68410. * Summary logging while loading
  68411. */
  68412. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68413. /**
  68414. * Detailled logging while loading
  68415. */
  68416. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68417. }
  68418. }
  68419. declare module BABYLON {
  68420. /**
  68421. * Class used to store and describe the pipeline context associated with an effect
  68422. */
  68423. export interface IPipelineContext {
  68424. /**
  68425. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68426. */
  68427. isAsync: boolean;
  68428. /**
  68429. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68430. */
  68431. isReady: boolean;
  68432. /** @hidden */
  68433. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68434. }
  68435. }
  68436. declare module BABYLON {
  68437. /** @hidden */
  68438. export interface IShaderProcessor {
  68439. attributeProcessor?: (attribute: string) => string;
  68440. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68441. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68442. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68443. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68444. lineProcessor?: (line: string, isFragment: boolean) => string;
  68445. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68446. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /** @hidden */
  68451. export interface ProcessingOptions {
  68452. defines: string[];
  68453. indexParameters: any;
  68454. isFragment: boolean;
  68455. shouldUseHighPrecisionShader: boolean;
  68456. supportsUniformBuffers: boolean;
  68457. shadersRepository: string;
  68458. includesShadersStore: {
  68459. [key: string]: string;
  68460. };
  68461. processor?: IShaderProcessor;
  68462. version: string;
  68463. platformName: string;
  68464. lookForClosingBracketForUniformBuffer?: boolean;
  68465. }
  68466. }
  68467. declare module BABYLON {
  68468. /**
  68469. * Helper to manipulate strings
  68470. */
  68471. export class StringTools {
  68472. /**
  68473. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68474. * @param str Source string
  68475. * @param suffix Suffix to search for in the source string
  68476. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68477. */
  68478. static EndsWith(str: string, suffix: string): boolean;
  68479. /**
  68480. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68481. * @param str Source string
  68482. * @param suffix Suffix to search for in the source string
  68483. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68484. */
  68485. static StartsWith(str: string, suffix: string): boolean;
  68486. }
  68487. }
  68488. declare module BABYLON {
  68489. /** @hidden */
  68490. export class ShaderCodeNode {
  68491. line: string;
  68492. children: ShaderCodeNode[];
  68493. additionalDefineKey?: string;
  68494. additionalDefineValue?: string;
  68495. isValid(preprocessors: {
  68496. [key: string]: string;
  68497. }): boolean;
  68498. process(preprocessors: {
  68499. [key: string]: string;
  68500. }, options: ProcessingOptions): string;
  68501. }
  68502. }
  68503. declare module BABYLON {
  68504. /** @hidden */
  68505. export class ShaderCodeCursor {
  68506. private _lines;
  68507. lineIndex: number;
  68508. readonly currentLine: string;
  68509. readonly canRead: boolean;
  68510. lines: string[];
  68511. }
  68512. }
  68513. declare module BABYLON {
  68514. /** @hidden */
  68515. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68516. process(preprocessors: {
  68517. [key: string]: string;
  68518. }, options: ProcessingOptions): string;
  68519. }
  68520. }
  68521. declare module BABYLON {
  68522. /** @hidden */
  68523. export class ShaderDefineExpression {
  68524. isTrue(preprocessors: {
  68525. [key: string]: string;
  68526. }): boolean;
  68527. }
  68528. }
  68529. declare module BABYLON {
  68530. /** @hidden */
  68531. export class ShaderCodeTestNode extends ShaderCodeNode {
  68532. testExpression: ShaderDefineExpression;
  68533. isValid(preprocessors: {
  68534. [key: string]: string;
  68535. }): boolean;
  68536. }
  68537. }
  68538. declare module BABYLON {
  68539. /** @hidden */
  68540. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68541. define: string;
  68542. not: boolean;
  68543. constructor(define: string, not?: boolean);
  68544. isTrue(preprocessors: {
  68545. [key: string]: string;
  68546. }): boolean;
  68547. }
  68548. }
  68549. declare module BABYLON {
  68550. /** @hidden */
  68551. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68552. leftOperand: ShaderDefineExpression;
  68553. rightOperand: ShaderDefineExpression;
  68554. isTrue(preprocessors: {
  68555. [key: string]: string;
  68556. }): boolean;
  68557. }
  68558. }
  68559. declare module BABYLON {
  68560. /** @hidden */
  68561. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68562. leftOperand: ShaderDefineExpression;
  68563. rightOperand: ShaderDefineExpression;
  68564. isTrue(preprocessors: {
  68565. [key: string]: string;
  68566. }): boolean;
  68567. }
  68568. }
  68569. declare module BABYLON {
  68570. /** @hidden */
  68571. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68572. define: string;
  68573. operand: string;
  68574. testValue: string;
  68575. constructor(define: string, operand: string, testValue: string);
  68576. isTrue(preprocessors: {
  68577. [key: string]: string;
  68578. }): boolean;
  68579. }
  68580. }
  68581. declare module BABYLON {
  68582. /**
  68583. * @ignore
  68584. * Application error to support additional information when loading a file
  68585. */
  68586. export class LoadFileError extends Error {
  68587. /** defines the optional web request */
  68588. request?: WebRequest | undefined;
  68589. private static _setPrototypeOf;
  68590. /**
  68591. * Creates a new LoadFileError
  68592. * @param message defines the message of the error
  68593. * @param request defines the optional web request
  68594. */
  68595. constructor(message: string,
  68596. /** defines the optional web request */
  68597. request?: WebRequest | undefined);
  68598. }
  68599. }
  68600. declare module BABYLON {
  68601. /**
  68602. * Class used to enable access to offline support
  68603. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68604. */
  68605. export interface IOfflineProvider {
  68606. /**
  68607. * Gets a boolean indicating if scene must be saved in the database
  68608. */
  68609. enableSceneOffline: boolean;
  68610. /**
  68611. * Gets a boolean indicating if textures must be saved in the database
  68612. */
  68613. enableTexturesOffline: boolean;
  68614. /**
  68615. * Open the offline support and make it available
  68616. * @param successCallback defines the callback to call on success
  68617. * @param errorCallback defines the callback to call on error
  68618. */
  68619. open(successCallback: () => void, errorCallback: () => void): void;
  68620. /**
  68621. * Loads an image from the offline support
  68622. * @param url defines the url to load from
  68623. * @param image defines the target DOM image
  68624. */
  68625. loadImage(url: string, image: HTMLImageElement): void;
  68626. /**
  68627. * Loads a file from offline support
  68628. * @param url defines the URL to load from
  68629. * @param sceneLoaded defines a callback to call on success
  68630. * @param progressCallBack defines a callback to call when progress changed
  68631. * @param errorCallback defines a callback to call on error
  68632. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68633. */
  68634. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68635. }
  68636. }
  68637. declare module BABYLON {
  68638. /**
  68639. * Class used to help managing file picking and drag'n'drop
  68640. * File Storage
  68641. */
  68642. export class FilesInputStore {
  68643. /**
  68644. * List of files ready to be loaded
  68645. */
  68646. static FilesToLoad: {
  68647. [key: string]: File;
  68648. };
  68649. }
  68650. }
  68651. declare module BABYLON {
  68652. /**
  68653. * Class used to define a retry strategy when error happens while loading assets
  68654. */
  68655. export class RetryStrategy {
  68656. /**
  68657. * Function used to defines an exponential back off strategy
  68658. * @param maxRetries defines the maximum number of retries (3 by default)
  68659. * @param baseInterval defines the interval between retries
  68660. * @returns the strategy function to use
  68661. */
  68662. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68663. }
  68664. }
  68665. declare module BABYLON {
  68666. /**
  68667. * @hidden
  68668. */
  68669. export class FileTools {
  68670. /**
  68671. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68672. */
  68673. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68674. /**
  68675. * Gets or sets the base URL to use to load assets
  68676. */
  68677. static BaseUrl: string;
  68678. /**
  68679. * Default behaviour for cors in the application.
  68680. * It can be a string if the expected behavior is identical in the entire app.
  68681. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68682. */
  68683. static CorsBehavior: string | ((url: string | string[]) => string);
  68684. /**
  68685. * Gets or sets a function used to pre-process url before using them to load assets
  68686. */
  68687. static PreprocessUrl: (url: string) => string;
  68688. /**
  68689. * Removes unwanted characters from an url
  68690. * @param url defines the url to clean
  68691. * @returns the cleaned url
  68692. */
  68693. private static _CleanUrl;
  68694. /**
  68695. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68696. * @param url define the url we are trying
  68697. * @param element define the dom element where to configure the cors policy
  68698. */
  68699. static SetCorsBehavior(url: string | string[], element: {
  68700. crossOrigin: string | null;
  68701. }): void;
  68702. /**
  68703. * Loads an image as an HTMLImageElement.
  68704. * @param input url string, ArrayBuffer, or Blob to load
  68705. * @param onLoad callback called when the image successfully loads
  68706. * @param onError callback called when the image fails to load
  68707. * @param offlineProvider offline provider for caching
  68708. * @returns the HTMLImageElement of the loaded image
  68709. */
  68710. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68711. /**
  68712. * Loads a file
  68713. * @param fileToLoad defines the file to load
  68714. * @param callback defines the callback to call when data is loaded
  68715. * @param progressCallBack defines the callback to call during loading process
  68716. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68717. * @returns a file request object
  68718. */
  68719. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68720. /**
  68721. * Loads a file
  68722. * @param url url string, ArrayBuffer, or Blob to load
  68723. * @param onSuccess callback called when the file successfully loads
  68724. * @param onProgress callback called while file is loading (if the server supports this mode)
  68725. * @param offlineProvider defines the offline provider for caching
  68726. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68727. * @param onError callback called when the file fails to load
  68728. * @returns a file request object
  68729. */
  68730. 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;
  68731. /**
  68732. * Checks if the loaded document was accessed via `file:`-Protocol.
  68733. * @returns boolean
  68734. */
  68735. static IsFileURL(): boolean;
  68736. }
  68737. }
  68738. declare module BABYLON {
  68739. /** @hidden */
  68740. export class ShaderProcessor {
  68741. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68742. private static _ProcessPrecision;
  68743. private static _ExtractOperation;
  68744. private static _BuildSubExpression;
  68745. private static _BuildExpression;
  68746. private static _MoveCursorWithinIf;
  68747. private static _MoveCursor;
  68748. private static _EvaluatePreProcessors;
  68749. private static _PreparePreProcessors;
  68750. private static _ProcessShaderConversion;
  68751. private static _ProcessIncludes;
  68752. }
  68753. }
  68754. declare module BABYLON {
  68755. /**
  68756. * Class used to hold a RBG color
  68757. */
  68758. export class Color3 {
  68759. /**
  68760. * Defines the red component (between 0 and 1, default is 0)
  68761. */
  68762. r: number;
  68763. /**
  68764. * Defines the green component (between 0 and 1, default is 0)
  68765. */
  68766. g: number;
  68767. /**
  68768. * Defines the blue component (between 0 and 1, default is 0)
  68769. */
  68770. b: number;
  68771. /**
  68772. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68773. * @param r defines the red component (between 0 and 1, default is 0)
  68774. * @param g defines the green component (between 0 and 1, default is 0)
  68775. * @param b defines the blue component (between 0 and 1, default is 0)
  68776. */
  68777. constructor(
  68778. /**
  68779. * Defines the red component (between 0 and 1, default is 0)
  68780. */
  68781. r?: number,
  68782. /**
  68783. * Defines the green component (between 0 and 1, default is 0)
  68784. */
  68785. g?: number,
  68786. /**
  68787. * Defines the blue component (between 0 and 1, default is 0)
  68788. */
  68789. b?: number);
  68790. /**
  68791. * Creates a string with the Color3 current values
  68792. * @returns the string representation of the Color3 object
  68793. */
  68794. toString(): string;
  68795. /**
  68796. * Returns the string "Color3"
  68797. * @returns "Color3"
  68798. */
  68799. getClassName(): string;
  68800. /**
  68801. * Compute the Color3 hash code
  68802. * @returns an unique number that can be used to hash Color3 objects
  68803. */
  68804. getHashCode(): number;
  68805. /**
  68806. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68807. * @param array defines the array where to store the r,g,b components
  68808. * @param index defines an optional index in the target array to define where to start storing values
  68809. * @returns the current Color3 object
  68810. */
  68811. toArray(array: FloatArray, index?: number): Color3;
  68812. /**
  68813. * Returns a new Color4 object from the current Color3 and the given alpha
  68814. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68815. * @returns a new Color4 object
  68816. */
  68817. toColor4(alpha?: number): Color4;
  68818. /**
  68819. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68820. * @returns the new array
  68821. */
  68822. asArray(): number[];
  68823. /**
  68824. * Returns the luminance value
  68825. * @returns a float value
  68826. */
  68827. toLuminance(): number;
  68828. /**
  68829. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68830. * @param otherColor defines the second operand
  68831. * @returns the new Color3 object
  68832. */
  68833. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68834. /**
  68835. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68836. * @param otherColor defines the second operand
  68837. * @param result defines the Color3 object where to store the result
  68838. * @returns the current Color3
  68839. */
  68840. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68841. /**
  68842. * Determines equality between Color3 objects
  68843. * @param otherColor defines the second operand
  68844. * @returns true if the rgb values are equal to the given ones
  68845. */
  68846. equals(otherColor: DeepImmutable<Color3>): boolean;
  68847. /**
  68848. * Determines equality between the current Color3 object and a set of r,b,g values
  68849. * @param r defines the red component to check
  68850. * @param g defines the green component to check
  68851. * @param b defines the blue component to check
  68852. * @returns true if the rgb values are equal to the given ones
  68853. */
  68854. equalsFloats(r: number, g: number, b: number): boolean;
  68855. /**
  68856. * Multiplies in place each rgb value by scale
  68857. * @param scale defines the scaling factor
  68858. * @returns the updated Color3
  68859. */
  68860. scale(scale: number): Color3;
  68861. /**
  68862. * Multiplies the rgb values by scale and stores the result into "result"
  68863. * @param scale defines the scaling factor
  68864. * @param result defines the Color3 object where to store the result
  68865. * @returns the unmodified current Color3
  68866. */
  68867. scaleToRef(scale: number, result: Color3): Color3;
  68868. /**
  68869. * Scale the current Color3 values by a factor and add the result to a given Color3
  68870. * @param scale defines the scale factor
  68871. * @param result defines color to store the result into
  68872. * @returns the unmodified current Color3
  68873. */
  68874. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68875. /**
  68876. * Clamps the rgb values by the min and max values and stores the result into "result"
  68877. * @param min defines minimum clamping value (default is 0)
  68878. * @param max defines maximum clamping value (default is 1)
  68879. * @param result defines color to store the result into
  68880. * @returns the original Color3
  68881. */
  68882. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68883. /**
  68884. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68885. * @param otherColor defines the second operand
  68886. * @returns the new Color3
  68887. */
  68888. add(otherColor: DeepImmutable<Color3>): Color3;
  68889. /**
  68890. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68891. * @param otherColor defines the second operand
  68892. * @param result defines Color3 object to store the result into
  68893. * @returns the unmodified current Color3
  68894. */
  68895. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68896. /**
  68897. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68898. * @param otherColor defines the second operand
  68899. * @returns the new Color3
  68900. */
  68901. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68902. /**
  68903. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68904. * @param otherColor defines the second operand
  68905. * @param result defines Color3 object to store the result into
  68906. * @returns the unmodified current Color3
  68907. */
  68908. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68909. /**
  68910. * Copy the current object
  68911. * @returns a new Color3 copied the current one
  68912. */
  68913. clone(): Color3;
  68914. /**
  68915. * Copies the rgb values from the source in the current Color3
  68916. * @param source defines the source Color3 object
  68917. * @returns the updated Color3 object
  68918. */
  68919. copyFrom(source: DeepImmutable<Color3>): Color3;
  68920. /**
  68921. * Updates the Color3 rgb values from the given floats
  68922. * @param r defines the red component to read from
  68923. * @param g defines the green component to read from
  68924. * @param b defines the blue component to read from
  68925. * @returns the current Color3 object
  68926. */
  68927. copyFromFloats(r: number, g: number, b: number): Color3;
  68928. /**
  68929. * Updates the Color3 rgb values from the given floats
  68930. * @param r defines the red component to read from
  68931. * @param g defines the green component to read from
  68932. * @param b defines the blue component to read from
  68933. * @returns the current Color3 object
  68934. */
  68935. set(r: number, g: number, b: number): Color3;
  68936. /**
  68937. * Compute the Color3 hexadecimal code as a string
  68938. * @returns a string containing the hexadecimal representation of the Color3 object
  68939. */
  68940. toHexString(): string;
  68941. /**
  68942. * Computes a new Color3 converted from the current one to linear space
  68943. * @returns a new Color3 object
  68944. */
  68945. toLinearSpace(): Color3;
  68946. /**
  68947. * Converts current color in rgb space to HSV values
  68948. * @returns a new color3 representing the HSV values
  68949. */
  68950. toHSV(): Color3;
  68951. /**
  68952. * Converts current color in rgb space to HSV values
  68953. * @param result defines the Color3 where to store the HSV values
  68954. */
  68955. toHSVToRef(result: Color3): void;
  68956. /**
  68957. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68958. * @param convertedColor defines the Color3 object where to store the linear space version
  68959. * @returns the unmodified Color3
  68960. */
  68961. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68962. /**
  68963. * Computes a new Color3 converted from the current one to gamma space
  68964. * @returns a new Color3 object
  68965. */
  68966. toGammaSpace(): Color3;
  68967. /**
  68968. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68969. * @param convertedColor defines the Color3 object where to store the gamma space version
  68970. * @returns the unmodified Color3
  68971. */
  68972. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68973. private static _BlackReadOnly;
  68974. /**
  68975. * Convert Hue, saturation and value to a Color3 (RGB)
  68976. * @param hue defines the hue
  68977. * @param saturation defines the saturation
  68978. * @param value defines the value
  68979. * @param result defines the Color3 where to store the RGB values
  68980. */
  68981. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68982. /**
  68983. * Creates a new Color3 from the string containing valid hexadecimal values
  68984. * @param hex defines a string containing valid hexadecimal values
  68985. * @returns a new Color3 object
  68986. */
  68987. static FromHexString(hex: string): Color3;
  68988. /**
  68989. * Creates a new Color3 from the starting index of the given array
  68990. * @param array defines the source array
  68991. * @param offset defines an offset in the source array
  68992. * @returns a new Color3 object
  68993. */
  68994. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68995. /**
  68996. * Creates a new Color3 from integer values (< 256)
  68997. * @param r defines the red component to read from (value between 0 and 255)
  68998. * @param g defines the green component to read from (value between 0 and 255)
  68999. * @param b defines the blue component to read from (value between 0 and 255)
  69000. * @returns a new Color3 object
  69001. */
  69002. static FromInts(r: number, g: number, b: number): Color3;
  69003. /**
  69004. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69005. * @param start defines the start Color3 value
  69006. * @param end defines the end Color3 value
  69007. * @param amount defines the gradient value between start and end
  69008. * @returns a new Color3 object
  69009. */
  69010. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69011. /**
  69012. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69013. * @param left defines the start value
  69014. * @param right defines the end value
  69015. * @param amount defines the gradient factor
  69016. * @param result defines the Color3 object where to store the result
  69017. */
  69018. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69019. /**
  69020. * Returns a Color3 value containing a red color
  69021. * @returns a new Color3 object
  69022. */
  69023. static Red(): Color3;
  69024. /**
  69025. * Returns a Color3 value containing a green color
  69026. * @returns a new Color3 object
  69027. */
  69028. static Green(): Color3;
  69029. /**
  69030. * Returns a Color3 value containing a blue color
  69031. * @returns a new Color3 object
  69032. */
  69033. static Blue(): Color3;
  69034. /**
  69035. * Returns a Color3 value containing a black color
  69036. * @returns a new Color3 object
  69037. */
  69038. static Black(): Color3;
  69039. /**
  69040. * Gets a Color3 value containing a black color that must not be updated
  69041. */
  69042. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69043. /**
  69044. * Returns a Color3 value containing a white color
  69045. * @returns a new Color3 object
  69046. */
  69047. static White(): Color3;
  69048. /**
  69049. * Returns a Color3 value containing a purple color
  69050. * @returns a new Color3 object
  69051. */
  69052. static Purple(): Color3;
  69053. /**
  69054. * Returns a Color3 value containing a magenta color
  69055. * @returns a new Color3 object
  69056. */
  69057. static Magenta(): Color3;
  69058. /**
  69059. * Returns a Color3 value containing a yellow color
  69060. * @returns a new Color3 object
  69061. */
  69062. static Yellow(): Color3;
  69063. /**
  69064. * Returns a Color3 value containing a gray color
  69065. * @returns a new Color3 object
  69066. */
  69067. static Gray(): Color3;
  69068. /**
  69069. * Returns a Color3 value containing a teal color
  69070. * @returns a new Color3 object
  69071. */
  69072. static Teal(): Color3;
  69073. /**
  69074. * Returns a Color3 value containing a random color
  69075. * @returns a new Color3 object
  69076. */
  69077. static Random(): Color3;
  69078. }
  69079. /**
  69080. * Class used to hold a RBGA color
  69081. */
  69082. export class Color4 {
  69083. /**
  69084. * Defines the red component (between 0 and 1, default is 0)
  69085. */
  69086. r: number;
  69087. /**
  69088. * Defines the green component (between 0 and 1, default is 0)
  69089. */
  69090. g: number;
  69091. /**
  69092. * Defines the blue component (between 0 and 1, default is 0)
  69093. */
  69094. b: number;
  69095. /**
  69096. * Defines the alpha component (between 0 and 1, default is 1)
  69097. */
  69098. a: number;
  69099. /**
  69100. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69101. * @param r defines the red component (between 0 and 1, default is 0)
  69102. * @param g defines the green component (between 0 and 1, default is 0)
  69103. * @param b defines the blue component (between 0 and 1, default is 0)
  69104. * @param a defines the alpha component (between 0 and 1, default is 1)
  69105. */
  69106. constructor(
  69107. /**
  69108. * Defines the red component (between 0 and 1, default is 0)
  69109. */
  69110. r?: number,
  69111. /**
  69112. * Defines the green component (between 0 and 1, default is 0)
  69113. */
  69114. g?: number,
  69115. /**
  69116. * Defines the blue component (between 0 and 1, default is 0)
  69117. */
  69118. b?: number,
  69119. /**
  69120. * Defines the alpha component (between 0 and 1, default is 1)
  69121. */
  69122. a?: number);
  69123. /**
  69124. * Adds in place the given Color4 values to the current Color4 object
  69125. * @param right defines the second operand
  69126. * @returns the current updated Color4 object
  69127. */
  69128. addInPlace(right: DeepImmutable<Color4>): Color4;
  69129. /**
  69130. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69131. * @returns the new array
  69132. */
  69133. asArray(): number[];
  69134. /**
  69135. * Stores from the starting index in the given array the Color4 successive values
  69136. * @param array defines the array where to store the r,g,b components
  69137. * @param index defines an optional index in the target array to define where to start storing values
  69138. * @returns the current Color4 object
  69139. */
  69140. toArray(array: number[], index?: number): Color4;
  69141. /**
  69142. * Determines equality between Color4 objects
  69143. * @param otherColor defines the second operand
  69144. * @returns true if the rgba values are equal to the given ones
  69145. */
  69146. equals(otherColor: DeepImmutable<Color4>): boolean;
  69147. /**
  69148. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69149. * @param right defines the second operand
  69150. * @returns a new Color4 object
  69151. */
  69152. add(right: DeepImmutable<Color4>): Color4;
  69153. /**
  69154. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69155. * @param right defines the second operand
  69156. * @returns a new Color4 object
  69157. */
  69158. subtract(right: DeepImmutable<Color4>): Color4;
  69159. /**
  69160. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69161. * @param right defines the second operand
  69162. * @param result defines the Color4 object where to store the result
  69163. * @returns the current Color4 object
  69164. */
  69165. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69166. /**
  69167. * Creates a new Color4 with the current Color4 values multiplied by scale
  69168. * @param scale defines the scaling factor to apply
  69169. * @returns a new Color4 object
  69170. */
  69171. scale(scale: number): Color4;
  69172. /**
  69173. * Multiplies the current Color4 values by scale and stores the result in "result"
  69174. * @param scale defines the scaling factor to apply
  69175. * @param result defines the Color4 object where to store the result
  69176. * @returns the current unmodified Color4
  69177. */
  69178. scaleToRef(scale: number, result: Color4): Color4;
  69179. /**
  69180. * Scale the current Color4 values by a factor and add the result to a given Color4
  69181. * @param scale defines the scale factor
  69182. * @param result defines the Color4 object where to store the result
  69183. * @returns the unmodified current Color4
  69184. */
  69185. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69186. /**
  69187. * Clamps the rgb values by the min and max values and stores the result into "result"
  69188. * @param min defines minimum clamping value (default is 0)
  69189. * @param max defines maximum clamping value (default is 1)
  69190. * @param result defines color to store the result into.
  69191. * @returns the cuurent Color4
  69192. */
  69193. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69194. /**
  69195. * Multipy an Color4 value by another and return a new Color4 object
  69196. * @param color defines the Color4 value to multiply by
  69197. * @returns a new Color4 object
  69198. */
  69199. multiply(color: Color4): Color4;
  69200. /**
  69201. * Multipy a Color4 value by another and push the result in a reference value
  69202. * @param color defines the Color4 value to multiply by
  69203. * @param result defines the Color4 to fill the result in
  69204. * @returns the result Color4
  69205. */
  69206. multiplyToRef(color: Color4, result: Color4): Color4;
  69207. /**
  69208. * Creates a string with the Color4 current values
  69209. * @returns the string representation of the Color4 object
  69210. */
  69211. toString(): string;
  69212. /**
  69213. * Returns the string "Color4"
  69214. * @returns "Color4"
  69215. */
  69216. getClassName(): string;
  69217. /**
  69218. * Compute the Color4 hash code
  69219. * @returns an unique number that can be used to hash Color4 objects
  69220. */
  69221. getHashCode(): number;
  69222. /**
  69223. * Creates a new Color4 copied from the current one
  69224. * @returns a new Color4 object
  69225. */
  69226. clone(): Color4;
  69227. /**
  69228. * Copies the given Color4 values into the current one
  69229. * @param source defines the source Color4 object
  69230. * @returns the current updated Color4 object
  69231. */
  69232. copyFrom(source: Color4): Color4;
  69233. /**
  69234. * Copies the given float values into the current one
  69235. * @param r defines the red component to read from
  69236. * @param g defines the green component to read from
  69237. * @param b defines the blue component to read from
  69238. * @param a defines the alpha component to read from
  69239. * @returns the current updated Color4 object
  69240. */
  69241. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69242. /**
  69243. * Copies the given float values into the current one
  69244. * @param r defines the red component to read from
  69245. * @param g defines the green component to read from
  69246. * @param b defines the blue component to read from
  69247. * @param a defines the alpha component to read from
  69248. * @returns the current updated Color4 object
  69249. */
  69250. set(r: number, g: number, b: number, a: number): Color4;
  69251. /**
  69252. * Compute the Color4 hexadecimal code as a string
  69253. * @returns a string containing the hexadecimal representation of the Color4 object
  69254. */
  69255. toHexString(): string;
  69256. /**
  69257. * Computes a new Color4 converted from the current one to linear space
  69258. * @returns a new Color4 object
  69259. */
  69260. toLinearSpace(): Color4;
  69261. /**
  69262. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69263. * @param convertedColor defines the Color4 object where to store the linear space version
  69264. * @returns the unmodified Color4
  69265. */
  69266. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69267. /**
  69268. * Computes a new Color4 converted from the current one to gamma space
  69269. * @returns a new Color4 object
  69270. */
  69271. toGammaSpace(): Color4;
  69272. /**
  69273. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69274. * @param convertedColor defines the Color4 object where to store the gamma space version
  69275. * @returns the unmodified Color4
  69276. */
  69277. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69278. /**
  69279. * Creates a new Color4 from the string containing valid hexadecimal values
  69280. * @param hex defines a string containing valid hexadecimal values
  69281. * @returns a new Color4 object
  69282. */
  69283. static FromHexString(hex: string): Color4;
  69284. /**
  69285. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69286. * @param left defines the start value
  69287. * @param right defines the end value
  69288. * @param amount defines the gradient factor
  69289. * @returns a new Color4 object
  69290. */
  69291. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69292. /**
  69293. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69294. * @param left defines the start value
  69295. * @param right defines the end value
  69296. * @param amount defines the gradient factor
  69297. * @param result defines the Color4 object where to store data
  69298. */
  69299. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69300. /**
  69301. * Creates a new Color4 from a Color3 and an alpha value
  69302. * @param color3 defines the source Color3 to read from
  69303. * @param alpha defines the alpha component (1.0 by default)
  69304. * @returns a new Color4 object
  69305. */
  69306. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69307. /**
  69308. * Creates a new Color4 from the starting index element of the given array
  69309. * @param array defines the source array to read from
  69310. * @param offset defines the offset in the source array
  69311. * @returns a new Color4 object
  69312. */
  69313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69314. /**
  69315. * Creates a new Color3 from integer values (< 256)
  69316. * @param r defines the red component to read from (value between 0 and 255)
  69317. * @param g defines the green component to read from (value between 0 and 255)
  69318. * @param b defines the blue component to read from (value between 0 and 255)
  69319. * @param a defines the alpha component to read from (value between 0 and 255)
  69320. * @returns a new Color3 object
  69321. */
  69322. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69323. /**
  69324. * Check the content of a given array and convert it to an array containing RGBA data
  69325. * If the original array was already containing count * 4 values then it is returned directly
  69326. * @param colors defines the array to check
  69327. * @param count defines the number of RGBA data to expect
  69328. * @returns an array containing count * 4 values (RGBA)
  69329. */
  69330. static CheckColors4(colors: number[], count: number): number[];
  69331. }
  69332. /**
  69333. * @hidden
  69334. */
  69335. export class TmpColors {
  69336. static Color3: Color3[];
  69337. static Color4: Color4[];
  69338. }
  69339. }
  69340. declare module BABYLON {
  69341. /**
  69342. * Class representing spherical harmonics coefficients to the 3rd degree
  69343. */
  69344. export class SphericalHarmonics {
  69345. /**
  69346. * Defines whether or not the harmonics have been prescaled for rendering.
  69347. */
  69348. preScaled: boolean;
  69349. /**
  69350. * The l0,0 coefficients of the spherical harmonics
  69351. */
  69352. l00: Vector3;
  69353. /**
  69354. * The l1,-1 coefficients of the spherical harmonics
  69355. */
  69356. l1_1: Vector3;
  69357. /**
  69358. * The l1,0 coefficients of the spherical harmonics
  69359. */
  69360. l10: Vector3;
  69361. /**
  69362. * The l1,1 coefficients of the spherical harmonics
  69363. */
  69364. l11: Vector3;
  69365. /**
  69366. * The l2,-2 coefficients of the spherical harmonics
  69367. */
  69368. l2_2: Vector3;
  69369. /**
  69370. * The l2,-1 coefficients of the spherical harmonics
  69371. */
  69372. l2_1: Vector3;
  69373. /**
  69374. * The l2,0 coefficients of the spherical harmonics
  69375. */
  69376. l20: Vector3;
  69377. /**
  69378. * The l2,1 coefficients of the spherical harmonics
  69379. */
  69380. l21: Vector3;
  69381. /**
  69382. * The l2,2 coefficients of the spherical harmonics
  69383. */
  69384. l22: Vector3;
  69385. /**
  69386. * Adds a light to the spherical harmonics
  69387. * @param direction the direction of the light
  69388. * @param color the color of the light
  69389. * @param deltaSolidAngle the delta solid angle of the light
  69390. */
  69391. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69392. /**
  69393. * Scales the spherical harmonics by the given amount
  69394. * @param scale the amount to scale
  69395. */
  69396. scaleInPlace(scale: number): void;
  69397. /**
  69398. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69399. *
  69400. * ```
  69401. * E_lm = A_l * L_lm
  69402. * ```
  69403. *
  69404. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69405. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69406. * the scaling factors are given in equation 9.
  69407. */
  69408. convertIncidentRadianceToIrradiance(): void;
  69409. /**
  69410. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69411. *
  69412. * ```
  69413. * L = (1/pi) * E * rho
  69414. * ```
  69415. *
  69416. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69417. */
  69418. convertIrradianceToLambertianRadiance(): void;
  69419. /**
  69420. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69421. * required operations at run time.
  69422. *
  69423. * This is simply done by scaling back the SH with Ylm constants parameter.
  69424. * The trigonometric part being applied by the shader at run time.
  69425. */
  69426. preScaleForRendering(): void;
  69427. /**
  69428. * Constructs a spherical harmonics from an array.
  69429. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69430. * @returns the spherical harmonics
  69431. */
  69432. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69433. /**
  69434. * Gets the spherical harmonics from polynomial
  69435. * @param polynomial the spherical polynomial
  69436. * @returns the spherical harmonics
  69437. */
  69438. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69439. }
  69440. /**
  69441. * Class representing spherical polynomial coefficients to the 3rd degree
  69442. */
  69443. export class SphericalPolynomial {
  69444. private _harmonics;
  69445. /**
  69446. * The spherical harmonics used to create the polynomials.
  69447. */
  69448. readonly preScaledHarmonics: SphericalHarmonics;
  69449. /**
  69450. * The x coefficients of the spherical polynomial
  69451. */
  69452. x: Vector3;
  69453. /**
  69454. * The y coefficients of the spherical polynomial
  69455. */
  69456. y: Vector3;
  69457. /**
  69458. * The z coefficients of the spherical polynomial
  69459. */
  69460. z: Vector3;
  69461. /**
  69462. * The xx coefficients of the spherical polynomial
  69463. */
  69464. xx: Vector3;
  69465. /**
  69466. * The yy coefficients of the spherical polynomial
  69467. */
  69468. yy: Vector3;
  69469. /**
  69470. * The zz coefficients of the spherical polynomial
  69471. */
  69472. zz: Vector3;
  69473. /**
  69474. * The xy coefficients of the spherical polynomial
  69475. */
  69476. xy: Vector3;
  69477. /**
  69478. * The yz coefficients of the spherical polynomial
  69479. */
  69480. yz: Vector3;
  69481. /**
  69482. * The zx coefficients of the spherical polynomial
  69483. */
  69484. zx: Vector3;
  69485. /**
  69486. * Adds an ambient color to the spherical polynomial
  69487. * @param color the color to add
  69488. */
  69489. addAmbient(color: Color3): void;
  69490. /**
  69491. * Scales the spherical polynomial by the given amount
  69492. * @param scale the amount to scale
  69493. */
  69494. scaleInPlace(scale: number): void;
  69495. /**
  69496. * Gets the spherical polynomial from harmonics
  69497. * @param harmonics the spherical harmonics
  69498. * @returns the spherical polynomial
  69499. */
  69500. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69501. /**
  69502. * Constructs a spherical polynomial from an array.
  69503. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69504. * @returns the spherical polynomial
  69505. */
  69506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69507. }
  69508. }
  69509. declare module BABYLON {
  69510. /**
  69511. * Define options used to create a render target texture
  69512. */
  69513. export class RenderTargetCreationOptions {
  69514. /**
  69515. * Specifies is mipmaps must be generated
  69516. */
  69517. generateMipMaps?: boolean;
  69518. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69519. generateDepthBuffer?: boolean;
  69520. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69521. generateStencilBuffer?: boolean;
  69522. /** Defines texture type (int by default) */
  69523. type?: number;
  69524. /** Defines sampling mode (trilinear by default) */
  69525. samplingMode?: number;
  69526. /** Defines format (RGBA by default) */
  69527. format?: number;
  69528. }
  69529. }
  69530. declare module BABYLON {
  69531. /**
  69532. * @hidden
  69533. **/
  69534. export class _AlphaState {
  69535. private _isAlphaBlendDirty;
  69536. private _isBlendFunctionParametersDirty;
  69537. private _isBlendEquationParametersDirty;
  69538. private _isBlendConstantsDirty;
  69539. private _alphaBlend;
  69540. private _blendFunctionParameters;
  69541. private _blendEquationParameters;
  69542. private _blendConstants;
  69543. /**
  69544. * Initializes the state.
  69545. */
  69546. constructor();
  69547. readonly isDirty: boolean;
  69548. alphaBlend: boolean;
  69549. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69550. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69551. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69552. reset(): void;
  69553. apply(gl: WebGLRenderingContext): void;
  69554. }
  69555. }
  69556. declare module BABYLON {
  69557. /**
  69558. * @hidden
  69559. **/
  69560. export class _DepthCullingState {
  69561. private _isDepthTestDirty;
  69562. private _isDepthMaskDirty;
  69563. private _isDepthFuncDirty;
  69564. private _isCullFaceDirty;
  69565. private _isCullDirty;
  69566. private _isZOffsetDirty;
  69567. private _isFrontFaceDirty;
  69568. private _depthTest;
  69569. private _depthMask;
  69570. private _depthFunc;
  69571. private _cull;
  69572. private _cullFace;
  69573. private _zOffset;
  69574. private _frontFace;
  69575. /**
  69576. * Initializes the state.
  69577. */
  69578. constructor();
  69579. readonly isDirty: boolean;
  69580. zOffset: number;
  69581. cullFace: Nullable<number>;
  69582. cull: Nullable<boolean>;
  69583. depthFunc: Nullable<number>;
  69584. depthMask: boolean;
  69585. depthTest: boolean;
  69586. frontFace: Nullable<number>;
  69587. reset(): void;
  69588. apply(gl: WebGLRenderingContext): void;
  69589. }
  69590. }
  69591. declare module BABYLON {
  69592. /**
  69593. * @hidden
  69594. **/
  69595. export class _StencilState {
  69596. /** 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 */
  69597. static readonly ALWAYS: number;
  69598. /** Passed to stencilOperation to specify that stencil value must be kept */
  69599. static readonly KEEP: number;
  69600. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69601. static readonly REPLACE: number;
  69602. private _isStencilTestDirty;
  69603. private _isStencilMaskDirty;
  69604. private _isStencilFuncDirty;
  69605. private _isStencilOpDirty;
  69606. private _stencilTest;
  69607. private _stencilMask;
  69608. private _stencilFunc;
  69609. private _stencilFuncRef;
  69610. private _stencilFuncMask;
  69611. private _stencilOpStencilFail;
  69612. private _stencilOpDepthFail;
  69613. private _stencilOpStencilDepthPass;
  69614. readonly isDirty: boolean;
  69615. stencilFunc: number;
  69616. stencilFuncRef: number;
  69617. stencilFuncMask: number;
  69618. stencilOpStencilFail: number;
  69619. stencilOpDepthFail: number;
  69620. stencilOpStencilDepthPass: number;
  69621. stencilMask: number;
  69622. stencilTest: boolean;
  69623. constructor();
  69624. reset(): void;
  69625. apply(gl: WebGLRenderingContext): void;
  69626. }
  69627. }
  69628. declare module BABYLON {
  69629. /**
  69630. * @hidden
  69631. **/
  69632. export class _TimeToken {
  69633. _startTimeQuery: Nullable<WebGLQuery>;
  69634. _endTimeQuery: Nullable<WebGLQuery>;
  69635. _timeElapsedQuery: Nullable<WebGLQuery>;
  69636. _timeElapsedQueryEnded: boolean;
  69637. }
  69638. }
  69639. declare module BABYLON {
  69640. /**
  69641. * Class used to evalaute queries containing `and` and `or` operators
  69642. */
  69643. export class AndOrNotEvaluator {
  69644. /**
  69645. * Evaluate a query
  69646. * @param query defines the query to evaluate
  69647. * @param evaluateCallback defines the callback used to filter result
  69648. * @returns true if the query matches
  69649. */
  69650. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69651. private static _HandleParenthesisContent;
  69652. private static _SimplifyNegation;
  69653. }
  69654. }
  69655. declare module BABYLON {
  69656. /**
  69657. * Class used to store custom tags
  69658. */
  69659. export class Tags {
  69660. /**
  69661. * Adds support for tags on the given object
  69662. * @param obj defines the object to use
  69663. */
  69664. static EnableFor(obj: any): void;
  69665. /**
  69666. * Removes tags support
  69667. * @param obj defines the object to use
  69668. */
  69669. static DisableFor(obj: any): void;
  69670. /**
  69671. * Gets a boolean indicating if the given object has tags
  69672. * @param obj defines the object to use
  69673. * @returns a boolean
  69674. */
  69675. static HasTags(obj: any): boolean;
  69676. /**
  69677. * Gets the tags available on a given object
  69678. * @param obj defines the object to use
  69679. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69680. * @returns the tags
  69681. */
  69682. static GetTags(obj: any, asString?: boolean): any;
  69683. /**
  69684. * Adds tags to an object
  69685. * @param obj defines the object to use
  69686. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69687. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69688. */
  69689. static AddTagsTo(obj: any, tagsString: string): void;
  69690. /**
  69691. * @hidden
  69692. */
  69693. static _AddTagTo(obj: any, tag: string): void;
  69694. /**
  69695. * Removes specific tags from a specific object
  69696. * @param obj defines the object to use
  69697. * @param tagsString defines the tags to remove
  69698. */
  69699. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69700. /**
  69701. * @hidden
  69702. */
  69703. static _RemoveTagFrom(obj: any, tag: string): void;
  69704. /**
  69705. * Defines if tags hosted on an object match a given query
  69706. * @param obj defines the object to use
  69707. * @param tagsQuery defines the tag query
  69708. * @returns a boolean
  69709. */
  69710. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69711. }
  69712. }
  69713. declare module BABYLON {
  69714. /**
  69715. * Defines potential orientation for back face culling
  69716. */
  69717. export enum Orientation {
  69718. /**
  69719. * Clockwise
  69720. */
  69721. CW = 0,
  69722. /** Counter clockwise */
  69723. CCW = 1
  69724. }
  69725. /** Class used to represent a Bezier curve */
  69726. export class BezierCurve {
  69727. /**
  69728. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69729. * @param t defines the time
  69730. * @param x1 defines the left coordinate on X axis
  69731. * @param y1 defines the left coordinate on Y axis
  69732. * @param x2 defines the right coordinate on X axis
  69733. * @param y2 defines the right coordinate on Y axis
  69734. * @returns the interpolated value
  69735. */
  69736. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69737. }
  69738. /**
  69739. * Defines angle representation
  69740. */
  69741. export class Angle {
  69742. private _radians;
  69743. /**
  69744. * Creates an Angle object of "radians" radians (float).
  69745. * @param radians the angle in radians
  69746. */
  69747. constructor(radians: number);
  69748. /**
  69749. * Get value in degrees
  69750. * @returns the Angle value in degrees (float)
  69751. */
  69752. degrees(): number;
  69753. /**
  69754. * Get value in radians
  69755. * @returns the Angle value in radians (float)
  69756. */
  69757. radians(): number;
  69758. /**
  69759. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69760. * @param a defines first vector
  69761. * @param b defines second vector
  69762. * @returns a new Angle
  69763. */
  69764. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  69765. /**
  69766. * Gets a new Angle object from the given float in radians
  69767. * @param radians defines the angle value in radians
  69768. * @returns a new Angle
  69769. */
  69770. static FromRadians(radians: number): Angle;
  69771. /**
  69772. * Gets a new Angle object from the given float in degrees
  69773. * @param degrees defines the angle value in degrees
  69774. * @returns a new Angle
  69775. */
  69776. static FromDegrees(degrees: number): Angle;
  69777. }
  69778. /**
  69779. * This represents an arc in a 2d space.
  69780. */
  69781. export class Arc2 {
  69782. /** Defines the start point of the arc */
  69783. startPoint: Vector2;
  69784. /** Defines the mid point of the arc */
  69785. midPoint: Vector2;
  69786. /** Defines the end point of the arc */
  69787. endPoint: Vector2;
  69788. /**
  69789. * Defines the center point of the arc.
  69790. */
  69791. centerPoint: Vector2;
  69792. /**
  69793. * Defines the radius of the arc.
  69794. */
  69795. radius: number;
  69796. /**
  69797. * Defines the angle of the arc (from mid point to end point).
  69798. */
  69799. angle: Angle;
  69800. /**
  69801. * Defines the start angle of the arc (from start point to middle point).
  69802. */
  69803. startAngle: Angle;
  69804. /**
  69805. * Defines the orientation of the arc (clock wise/counter clock wise).
  69806. */
  69807. orientation: Orientation;
  69808. /**
  69809. * Creates an Arc object from the three given points : start, middle and end.
  69810. * @param startPoint Defines the start point of the arc
  69811. * @param midPoint Defines the midlle point of the arc
  69812. * @param endPoint Defines the end point of the arc
  69813. */
  69814. constructor(
  69815. /** Defines the start point of the arc */
  69816. startPoint: Vector2,
  69817. /** Defines the mid point of the arc */
  69818. midPoint: Vector2,
  69819. /** Defines the end point of the arc */
  69820. endPoint: Vector2);
  69821. }
  69822. /**
  69823. * Represents a 2D path made up of multiple 2D points
  69824. */
  69825. export class Path2 {
  69826. private _points;
  69827. private _length;
  69828. /**
  69829. * If the path start and end point are the same
  69830. */
  69831. closed: boolean;
  69832. /**
  69833. * Creates a Path2 object from the starting 2D coordinates x and y.
  69834. * @param x the starting points x value
  69835. * @param y the starting points y value
  69836. */
  69837. constructor(x: number, y: number);
  69838. /**
  69839. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69840. * @param x the added points x value
  69841. * @param y the added points y value
  69842. * @returns the updated Path2.
  69843. */
  69844. addLineTo(x: number, y: number): Path2;
  69845. /**
  69846. * 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.
  69847. * @param midX middle point x value
  69848. * @param midY middle point y value
  69849. * @param endX end point x value
  69850. * @param endY end point y value
  69851. * @param numberOfSegments (default: 36)
  69852. * @returns the updated Path2.
  69853. */
  69854. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69855. /**
  69856. * Closes the Path2.
  69857. * @returns the Path2.
  69858. */
  69859. close(): Path2;
  69860. /**
  69861. * Gets the sum of the distance between each sequential point in the path
  69862. * @returns the Path2 total length (float).
  69863. */
  69864. length(): number;
  69865. /**
  69866. * Gets the points which construct the path
  69867. * @returns the Path2 internal array of points.
  69868. */
  69869. getPoints(): Vector2[];
  69870. /**
  69871. * Retreives the point at the distance aways from the starting point
  69872. * @param normalizedLengthPosition the length along the path to retreive the point from
  69873. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69874. */
  69875. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69876. /**
  69877. * Creates a new path starting from an x and y position
  69878. * @param x starting x value
  69879. * @param y starting y value
  69880. * @returns a new Path2 starting at the coordinates (x, y).
  69881. */
  69882. static StartingAt(x: number, y: number): Path2;
  69883. }
  69884. /**
  69885. * Represents a 3D path made up of multiple 3D points
  69886. */
  69887. export class Path3D {
  69888. /**
  69889. * an array of Vector3, the curve axis of the Path3D
  69890. */
  69891. path: Vector3[];
  69892. private _curve;
  69893. private _distances;
  69894. private _tangents;
  69895. private _normals;
  69896. private _binormals;
  69897. private _raw;
  69898. /**
  69899. * new Path3D(path, normal, raw)
  69900. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69901. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69902. * @param path an array of Vector3, the curve axis of the Path3D
  69903. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69904. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69905. */
  69906. constructor(
  69907. /**
  69908. * an array of Vector3, the curve axis of the Path3D
  69909. */
  69910. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69911. /**
  69912. * Returns the Path3D array of successive Vector3 designing its curve.
  69913. * @returns the Path3D array of successive Vector3 designing its curve.
  69914. */
  69915. getCurve(): Vector3[];
  69916. /**
  69917. * Returns an array populated with tangent vectors on each Path3D curve point.
  69918. * @returns an array populated with tangent vectors on each Path3D curve point.
  69919. */
  69920. getTangents(): Vector3[];
  69921. /**
  69922. * Returns an array populated with normal vectors on each Path3D curve point.
  69923. * @returns an array populated with normal vectors on each Path3D curve point.
  69924. */
  69925. getNormals(): Vector3[];
  69926. /**
  69927. * Returns an array populated with binormal vectors on each Path3D curve point.
  69928. * @returns an array populated with binormal vectors on each Path3D curve point.
  69929. */
  69930. getBinormals(): Vector3[];
  69931. /**
  69932. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69933. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69934. */
  69935. getDistances(): number[];
  69936. /**
  69937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69938. * @param path path which all values are copied into the curves points
  69939. * @param firstNormal which should be projected onto the curve
  69940. * @returns the same object updated.
  69941. */
  69942. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69943. private _compute;
  69944. private _getFirstNonNullVector;
  69945. private _getLastNonNullVector;
  69946. private _normalVector;
  69947. }
  69948. /**
  69949. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69950. * A Curve3 is designed from a series of successive Vector3.
  69951. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69952. */
  69953. export class Curve3 {
  69954. private _points;
  69955. private _length;
  69956. /**
  69957. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69958. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69959. * @param v1 (Vector3) the control point
  69960. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69961. * @param nbPoints (integer) the wanted number of points in the curve
  69962. * @returns the created Curve3
  69963. */
  69964. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69965. /**
  69966. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69967. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69968. * @param v1 (Vector3) the first control point
  69969. * @param v2 (Vector3) the second control point
  69970. * @param v3 (Vector3) the end point of the Cubic Bezier
  69971. * @param nbPoints (integer) the wanted number of points in the curve
  69972. * @returns the created Curve3
  69973. */
  69974. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69975. /**
  69976. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69977. * @param p1 (Vector3) the origin point of the Hermite Spline
  69978. * @param t1 (Vector3) the tangent vector at the origin point
  69979. * @param p2 (Vector3) the end point of the Hermite Spline
  69980. * @param t2 (Vector3) the tangent vector at the end point
  69981. * @param nbPoints (integer) the wanted number of points in the curve
  69982. * @returns the created Curve3
  69983. */
  69984. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69985. /**
  69986. * Returns a Curve3 object along a CatmullRom Spline curve :
  69987. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69988. * @param nbPoints (integer) the wanted number of points between each curve control points
  69989. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69990. * @returns the created Curve3
  69991. */
  69992. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69993. /**
  69994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69995. * A Curve3 is designed from a series of successive Vector3.
  69996. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69997. * @param points points which make up the curve
  69998. */
  69999. constructor(points: Vector3[]);
  70000. /**
  70001. * @returns the Curve3 stored array of successive Vector3
  70002. */
  70003. getPoints(): Vector3[];
  70004. /**
  70005. * @returns the computed length (float) of the curve.
  70006. */
  70007. length(): number;
  70008. /**
  70009. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70010. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70011. * curveA and curveB keep unchanged.
  70012. * @param curve the curve to continue from this curve
  70013. * @returns the newly constructed curve
  70014. */
  70015. continue(curve: DeepImmutable<Curve3>): Curve3;
  70016. private _computeLength;
  70017. }
  70018. }
  70019. declare module BABYLON {
  70020. /**
  70021. * This represents the main contract an easing function should follow.
  70022. * Easing functions are used throughout the animation system.
  70023. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70024. */
  70025. export interface IEasingFunction {
  70026. /**
  70027. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70028. * of the easing function.
  70029. * The link below provides some of the most common examples of easing functions.
  70030. * @see https://easings.net/
  70031. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70032. * @returns the corresponding value on the curve defined by the easing function
  70033. */
  70034. ease(gradient: number): number;
  70035. }
  70036. /**
  70037. * Base class used for every default easing function.
  70038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70039. */
  70040. export class EasingFunction implements IEasingFunction {
  70041. /**
  70042. * Interpolation follows the mathematical formula associated with the easing function.
  70043. */
  70044. static readonly EASINGMODE_EASEIN: number;
  70045. /**
  70046. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70047. */
  70048. static readonly EASINGMODE_EASEOUT: number;
  70049. /**
  70050. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70051. */
  70052. static readonly EASINGMODE_EASEINOUT: number;
  70053. private _easingMode;
  70054. /**
  70055. * Sets the easing mode of the current function.
  70056. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70057. */
  70058. setEasingMode(easingMode: number): void;
  70059. /**
  70060. * Gets the current easing mode.
  70061. * @returns the easing mode
  70062. */
  70063. getEasingMode(): number;
  70064. /**
  70065. * @hidden
  70066. */
  70067. easeInCore(gradient: number): number;
  70068. /**
  70069. * Given an input gradient between 0 and 1, this returns the corresponding value
  70070. * of the easing function.
  70071. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70072. * @returns the corresponding value on the curve defined by the easing function
  70073. */
  70074. ease(gradient: number): number;
  70075. }
  70076. /**
  70077. * Easing function with a circle shape (see link below).
  70078. * @see https://easings.net/#easeInCirc
  70079. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70080. */
  70081. export class CircleEase extends EasingFunction implements IEasingFunction {
  70082. /** @hidden */
  70083. easeInCore(gradient: number): number;
  70084. }
  70085. /**
  70086. * Easing function with a ease back shape (see link below).
  70087. * @see https://easings.net/#easeInBack
  70088. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70089. */
  70090. export class BackEase extends EasingFunction implements IEasingFunction {
  70091. /** Defines the amplitude of the function */
  70092. amplitude: number;
  70093. /**
  70094. * Instantiates a back ease easing
  70095. * @see https://easings.net/#easeInBack
  70096. * @param amplitude Defines the amplitude of the function
  70097. */
  70098. constructor(
  70099. /** Defines the amplitude of the function */
  70100. amplitude?: number);
  70101. /** @hidden */
  70102. easeInCore(gradient: number): number;
  70103. }
  70104. /**
  70105. * Easing function with a bouncing shape (see link below).
  70106. * @see https://easings.net/#easeInBounce
  70107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70108. */
  70109. export class BounceEase extends EasingFunction implements IEasingFunction {
  70110. /** Defines the number of bounces */
  70111. bounces: number;
  70112. /** Defines the amplitude of the bounce */
  70113. bounciness: number;
  70114. /**
  70115. * Instantiates a bounce easing
  70116. * @see https://easings.net/#easeInBounce
  70117. * @param bounces Defines the number of bounces
  70118. * @param bounciness Defines the amplitude of the bounce
  70119. */
  70120. constructor(
  70121. /** Defines the number of bounces */
  70122. bounces?: number,
  70123. /** Defines the amplitude of the bounce */
  70124. bounciness?: number);
  70125. /** @hidden */
  70126. easeInCore(gradient: number): number;
  70127. }
  70128. /**
  70129. * Easing function with a power of 3 shape (see link below).
  70130. * @see https://easings.net/#easeInCubic
  70131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70132. */
  70133. export class CubicEase extends EasingFunction implements IEasingFunction {
  70134. /** @hidden */
  70135. easeInCore(gradient: number): number;
  70136. }
  70137. /**
  70138. * Easing function with an elastic shape (see link below).
  70139. * @see https://easings.net/#easeInElastic
  70140. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70141. */
  70142. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70143. /** Defines the number of oscillations*/
  70144. oscillations: number;
  70145. /** Defines the amplitude of the oscillations*/
  70146. springiness: number;
  70147. /**
  70148. * Instantiates an elastic easing function
  70149. * @see https://easings.net/#easeInElastic
  70150. * @param oscillations Defines the number of oscillations
  70151. * @param springiness Defines the amplitude of the oscillations
  70152. */
  70153. constructor(
  70154. /** Defines the number of oscillations*/
  70155. oscillations?: number,
  70156. /** Defines the amplitude of the oscillations*/
  70157. springiness?: number);
  70158. /** @hidden */
  70159. easeInCore(gradient: number): number;
  70160. }
  70161. /**
  70162. * Easing function with an exponential shape (see link below).
  70163. * @see https://easings.net/#easeInExpo
  70164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70165. */
  70166. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70167. /** Defines the exponent of the function */
  70168. exponent: number;
  70169. /**
  70170. * Instantiates an exponential easing function
  70171. * @see https://easings.net/#easeInExpo
  70172. * @param exponent Defines the exponent of the function
  70173. */
  70174. constructor(
  70175. /** Defines the exponent of the function */
  70176. exponent?: number);
  70177. /** @hidden */
  70178. easeInCore(gradient: number): number;
  70179. }
  70180. /**
  70181. * Easing function with a power shape (see link below).
  70182. * @see https://easings.net/#easeInQuad
  70183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70184. */
  70185. export class PowerEase extends EasingFunction implements IEasingFunction {
  70186. /** Defines the power of the function */
  70187. power: number;
  70188. /**
  70189. * Instantiates an power base easing function
  70190. * @see https://easings.net/#easeInQuad
  70191. * @param power Defines the power of the function
  70192. */
  70193. constructor(
  70194. /** Defines the power of the function */
  70195. power?: number);
  70196. /** @hidden */
  70197. easeInCore(gradient: number): number;
  70198. }
  70199. /**
  70200. * Easing function with a power of 2 shape (see link below).
  70201. * @see https://easings.net/#easeInQuad
  70202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70203. */
  70204. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70205. /** @hidden */
  70206. easeInCore(gradient: number): number;
  70207. }
  70208. /**
  70209. * Easing function with a power of 4 shape (see link below).
  70210. * @see https://easings.net/#easeInQuart
  70211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70212. */
  70213. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70214. /** @hidden */
  70215. easeInCore(gradient: number): number;
  70216. }
  70217. /**
  70218. * Easing function with a power of 5 shape (see link below).
  70219. * @see https://easings.net/#easeInQuint
  70220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70221. */
  70222. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70223. /** @hidden */
  70224. easeInCore(gradient: number): number;
  70225. }
  70226. /**
  70227. * Easing function with a sin shape (see link below).
  70228. * @see https://easings.net/#easeInSine
  70229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70230. */
  70231. export class SineEase extends EasingFunction implements IEasingFunction {
  70232. /** @hidden */
  70233. easeInCore(gradient: number): number;
  70234. }
  70235. /**
  70236. * Easing function with a bezier shape (see link below).
  70237. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70239. */
  70240. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70241. /** Defines the x component of the start tangent in the bezier curve */
  70242. x1: number;
  70243. /** Defines the y component of the start tangent in the bezier curve */
  70244. y1: number;
  70245. /** Defines the x component of the end tangent in the bezier curve */
  70246. x2: number;
  70247. /** Defines the y component of the end tangent in the bezier curve */
  70248. y2: number;
  70249. /**
  70250. * Instantiates a bezier function
  70251. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70252. * @param x1 Defines the x component of the start tangent in the bezier curve
  70253. * @param y1 Defines the y component of the start tangent in the bezier curve
  70254. * @param x2 Defines the x component of the end tangent in the bezier curve
  70255. * @param y2 Defines the y component of the end tangent in the bezier curve
  70256. */
  70257. constructor(
  70258. /** Defines the x component of the start tangent in the bezier curve */
  70259. x1?: number,
  70260. /** Defines the y component of the start tangent in the bezier curve */
  70261. y1?: number,
  70262. /** Defines the x component of the end tangent in the bezier curve */
  70263. x2?: number,
  70264. /** Defines the y component of the end tangent in the bezier curve */
  70265. y2?: number);
  70266. /** @hidden */
  70267. easeInCore(gradient: number): number;
  70268. }
  70269. }
  70270. declare module BABYLON {
  70271. /**
  70272. * Defines an interface which represents an animation key frame
  70273. */
  70274. export interface IAnimationKey {
  70275. /**
  70276. * Frame of the key frame
  70277. */
  70278. frame: number;
  70279. /**
  70280. * Value at the specifies key frame
  70281. */
  70282. value: any;
  70283. /**
  70284. * The input tangent for the cubic hermite spline
  70285. */
  70286. inTangent?: any;
  70287. /**
  70288. * The output tangent for the cubic hermite spline
  70289. */
  70290. outTangent?: any;
  70291. /**
  70292. * The animation interpolation type
  70293. */
  70294. interpolation?: AnimationKeyInterpolation;
  70295. }
  70296. /**
  70297. * Enum for the animation key frame interpolation type
  70298. */
  70299. export enum AnimationKeyInterpolation {
  70300. /**
  70301. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70302. */
  70303. STEP = 1
  70304. }
  70305. }
  70306. declare module BABYLON {
  70307. /**
  70308. * Represents the range of an animation
  70309. */
  70310. export class AnimationRange {
  70311. /**The name of the animation range**/
  70312. name: string;
  70313. /**The starting frame of the animation */
  70314. from: number;
  70315. /**The ending frame of the animation*/
  70316. to: number;
  70317. /**
  70318. * Initializes the range of an animation
  70319. * @param name The name of the animation range
  70320. * @param from The starting frame of the animation
  70321. * @param to The ending frame of the animation
  70322. */
  70323. constructor(
  70324. /**The name of the animation range**/
  70325. name: string,
  70326. /**The starting frame of the animation */
  70327. from: number,
  70328. /**The ending frame of the animation*/
  70329. to: number);
  70330. /**
  70331. * Makes a copy of the animation range
  70332. * @returns A copy of the animation range
  70333. */
  70334. clone(): AnimationRange;
  70335. }
  70336. }
  70337. declare module BABYLON {
  70338. /**
  70339. * Composed of a frame, and an action function
  70340. */
  70341. export class AnimationEvent {
  70342. /** The frame for which the event is triggered **/
  70343. frame: number;
  70344. /** The event to perform when triggered **/
  70345. action: (currentFrame: number) => void;
  70346. /** Specifies if the event should be triggered only once**/
  70347. onlyOnce?: boolean | undefined;
  70348. /**
  70349. * Specifies if the animation event is done
  70350. */
  70351. isDone: boolean;
  70352. /**
  70353. * Initializes the animation event
  70354. * @param frame The frame for which the event is triggered
  70355. * @param action The event to perform when triggered
  70356. * @param onlyOnce Specifies if the event should be triggered only once
  70357. */
  70358. constructor(
  70359. /** The frame for which the event is triggered **/
  70360. frame: number,
  70361. /** The event to perform when triggered **/
  70362. action: (currentFrame: number) => void,
  70363. /** Specifies if the event should be triggered only once**/
  70364. onlyOnce?: boolean | undefined);
  70365. /** @hidden */
  70366. _clone(): AnimationEvent;
  70367. }
  70368. }
  70369. declare module BABYLON {
  70370. /**
  70371. * Interface used to define a behavior
  70372. */
  70373. export interface Behavior<T> {
  70374. /** gets or sets behavior's name */
  70375. name: string;
  70376. /**
  70377. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70378. */
  70379. init(): void;
  70380. /**
  70381. * Called when the behavior is attached to a target
  70382. * @param target defines the target where the behavior is attached to
  70383. */
  70384. attach(target: T): void;
  70385. /**
  70386. * Called when the behavior is detached from its target
  70387. */
  70388. detach(): void;
  70389. }
  70390. /**
  70391. * Interface implemented by classes supporting behaviors
  70392. */
  70393. export interface IBehaviorAware<T> {
  70394. /**
  70395. * Attach a behavior
  70396. * @param behavior defines the behavior to attach
  70397. * @returns the current host
  70398. */
  70399. addBehavior(behavior: Behavior<T>): T;
  70400. /**
  70401. * Remove a behavior from the current object
  70402. * @param behavior defines the behavior to detach
  70403. * @returns the current host
  70404. */
  70405. removeBehavior(behavior: Behavior<T>): T;
  70406. /**
  70407. * Gets a behavior using its name to search
  70408. * @param name defines the name to search
  70409. * @returns the behavior or null if not found
  70410. */
  70411. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70412. }
  70413. }
  70414. declare module BABYLON {
  70415. /**
  70416. * Defines an array and its length.
  70417. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70418. */
  70419. export interface ISmartArrayLike<T> {
  70420. /**
  70421. * The data of the array.
  70422. */
  70423. data: Array<T>;
  70424. /**
  70425. * The active length of the array.
  70426. */
  70427. length: number;
  70428. }
  70429. /**
  70430. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70431. */
  70432. export class SmartArray<T> implements ISmartArrayLike<T> {
  70433. /**
  70434. * The full set of data from the array.
  70435. */
  70436. data: Array<T>;
  70437. /**
  70438. * The active length of the array.
  70439. */
  70440. length: number;
  70441. protected _id: number;
  70442. /**
  70443. * Instantiates a Smart Array.
  70444. * @param capacity defines the default capacity of the array.
  70445. */
  70446. constructor(capacity: number);
  70447. /**
  70448. * Pushes a value at the end of the active data.
  70449. * @param value defines the object to push in the array.
  70450. */
  70451. push(value: T): void;
  70452. /**
  70453. * Iterates over the active data and apply the lambda to them.
  70454. * @param func defines the action to apply on each value.
  70455. */
  70456. forEach(func: (content: T) => void): void;
  70457. /**
  70458. * Sorts the full sets of data.
  70459. * @param compareFn defines the comparison function to apply.
  70460. */
  70461. sort(compareFn: (a: T, b: T) => number): void;
  70462. /**
  70463. * Resets the active data to an empty array.
  70464. */
  70465. reset(): void;
  70466. /**
  70467. * Releases all the data from the array as well as the array.
  70468. */
  70469. dispose(): void;
  70470. /**
  70471. * Concats the active data with a given array.
  70472. * @param array defines the data to concatenate with.
  70473. */
  70474. concat(array: any): void;
  70475. /**
  70476. * Returns the position of a value in the active data.
  70477. * @param value defines the value to find the index for
  70478. * @returns the index if found in the active data otherwise -1
  70479. */
  70480. indexOf(value: T): number;
  70481. /**
  70482. * Returns whether an element is part of the active data.
  70483. * @param value defines the value to look for
  70484. * @returns true if found in the active data otherwise false
  70485. */
  70486. contains(value: T): boolean;
  70487. private static _GlobalId;
  70488. }
  70489. /**
  70490. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70491. * The data in this array can only be present once
  70492. */
  70493. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70494. private _duplicateId;
  70495. /**
  70496. * Pushes a value at the end of the active data.
  70497. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70498. * @param value defines the object to push in the array.
  70499. */
  70500. push(value: T): void;
  70501. /**
  70502. * Pushes a value at the end of the active data.
  70503. * If the data is already present, it won t be added again
  70504. * @param value defines the object to push in the array.
  70505. * @returns true if added false if it was already present
  70506. */
  70507. pushNoDuplicate(value: T): boolean;
  70508. /**
  70509. * Resets the active data to an empty array.
  70510. */
  70511. reset(): void;
  70512. /**
  70513. * Concats the active data with a given array.
  70514. * This ensures no dupplicate will be present in the result.
  70515. * @param array defines the data to concatenate with.
  70516. */
  70517. concatWithNoDuplicate(array: any): void;
  70518. }
  70519. }
  70520. declare module BABYLON {
  70521. /**
  70522. * @ignore
  70523. * This is a list of all the different input types that are available in the application.
  70524. * Fo instance: ArcRotateCameraGamepadInput...
  70525. */
  70526. export var CameraInputTypes: {};
  70527. /**
  70528. * This is the contract to implement in order to create a new input class.
  70529. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70530. */
  70531. export interface ICameraInput<TCamera extends Camera> {
  70532. /**
  70533. * Defines the camera the input is attached to.
  70534. */
  70535. camera: Nullable<TCamera>;
  70536. /**
  70537. * Gets the class name of the current intput.
  70538. * @returns the class name
  70539. */
  70540. getClassName(): string;
  70541. /**
  70542. * Get the friendly name associated with the input class.
  70543. * @returns the input friendly name
  70544. */
  70545. getSimpleName(): string;
  70546. /**
  70547. * Attach the input controls to a specific dom element to get the input from.
  70548. * @param element Defines the element the controls should be listened from
  70549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70550. */
  70551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70552. /**
  70553. * Detach the current controls from the specified dom element.
  70554. * @param element Defines the element to stop listening the inputs from
  70555. */
  70556. detachControl(element: Nullable<HTMLElement>): void;
  70557. /**
  70558. * Update the current camera state depending on the inputs that have been used this frame.
  70559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70560. */
  70561. checkInputs?: () => void;
  70562. }
  70563. /**
  70564. * Represents a map of input types to input instance or input index to input instance.
  70565. */
  70566. export interface CameraInputsMap<TCamera extends Camera> {
  70567. /**
  70568. * Accessor to the input by input type.
  70569. */
  70570. [name: string]: ICameraInput<TCamera>;
  70571. /**
  70572. * Accessor to the input by input index.
  70573. */
  70574. [idx: number]: ICameraInput<TCamera>;
  70575. }
  70576. /**
  70577. * This represents the input manager used within a camera.
  70578. * It helps dealing with all the different kind of input attached to a camera.
  70579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70580. */
  70581. export class CameraInputsManager<TCamera extends Camera> {
  70582. /**
  70583. * Defines the list of inputs attahed to the camera.
  70584. */
  70585. attached: CameraInputsMap<TCamera>;
  70586. /**
  70587. * Defines the dom element the camera is collecting inputs from.
  70588. * This is null if the controls have not been attached.
  70589. */
  70590. attachedElement: Nullable<HTMLElement>;
  70591. /**
  70592. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70593. */
  70594. noPreventDefault: boolean;
  70595. /**
  70596. * Defined the camera the input manager belongs to.
  70597. */
  70598. camera: TCamera;
  70599. /**
  70600. * Update the current camera state depending on the inputs that have been used this frame.
  70601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70602. */
  70603. checkInputs: () => void;
  70604. /**
  70605. * Instantiate a new Camera Input Manager.
  70606. * @param camera Defines the camera the input manager blongs to
  70607. */
  70608. constructor(camera: TCamera);
  70609. /**
  70610. * Add an input method to a camera
  70611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70612. * @param input camera input method
  70613. */
  70614. add(input: ICameraInput<TCamera>): void;
  70615. /**
  70616. * Remove a specific input method from a camera
  70617. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70618. * @param inputToRemove camera input method
  70619. */
  70620. remove(inputToRemove: ICameraInput<TCamera>): void;
  70621. /**
  70622. * Remove a specific input type from a camera
  70623. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70624. * @param inputType the type of the input to remove
  70625. */
  70626. removeByType(inputType: string): void;
  70627. private _addCheckInputs;
  70628. /**
  70629. * Attach the input controls to the currently attached dom element to listen the events from.
  70630. * @param input Defines the input to attach
  70631. */
  70632. attachInput(input: ICameraInput<TCamera>): void;
  70633. /**
  70634. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70635. * @param element Defines the dom element to collect the events from
  70636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70637. */
  70638. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70639. /**
  70640. * Detach the current manager inputs controls from a specific dom element.
  70641. * @param element Defines the dom element to collect the events from
  70642. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70643. */
  70644. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70645. /**
  70646. * Rebuild the dynamic inputCheck function from the current list of
  70647. * defined inputs in the manager.
  70648. */
  70649. rebuildInputCheck(): void;
  70650. /**
  70651. * Remove all attached input methods from a camera
  70652. */
  70653. clear(): void;
  70654. /**
  70655. * Serialize the current input manager attached to a camera.
  70656. * This ensures than once parsed,
  70657. * the input associated to the camera will be identical to the current ones
  70658. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70659. */
  70660. serialize(serializedCamera: any): void;
  70661. /**
  70662. * Parses an input manager serialized JSON to restore the previous list of inputs
  70663. * and states associated to a camera.
  70664. * @param parsedCamera Defines the JSON to parse
  70665. */
  70666. parse(parsedCamera: any): void;
  70667. }
  70668. }
  70669. declare module BABYLON {
  70670. /**
  70671. * @hidden
  70672. */
  70673. export class IntersectionInfo {
  70674. bu: Nullable<number>;
  70675. bv: Nullable<number>;
  70676. distance: number;
  70677. faceId: number;
  70678. subMeshId: number;
  70679. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70680. }
  70681. }
  70682. declare module BABYLON {
  70683. /**
  70684. * Represens a plane by the equation ax + by + cz + d = 0
  70685. */
  70686. export class Plane {
  70687. private static _TmpMatrix;
  70688. /**
  70689. * Normal of the plane (a,b,c)
  70690. */
  70691. normal: Vector3;
  70692. /**
  70693. * d component of the plane
  70694. */
  70695. d: number;
  70696. /**
  70697. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70698. * @param a a component of the plane
  70699. * @param b b component of the plane
  70700. * @param c c component of the plane
  70701. * @param d d component of the plane
  70702. */
  70703. constructor(a: number, b: number, c: number, d: number);
  70704. /**
  70705. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70706. */
  70707. asArray(): number[];
  70708. /**
  70709. * @returns a new plane copied from the current Plane.
  70710. */
  70711. clone(): Plane;
  70712. /**
  70713. * @returns the string "Plane".
  70714. */
  70715. getClassName(): string;
  70716. /**
  70717. * @returns the Plane hash code.
  70718. */
  70719. getHashCode(): number;
  70720. /**
  70721. * Normalize the current Plane in place.
  70722. * @returns the updated Plane.
  70723. */
  70724. normalize(): Plane;
  70725. /**
  70726. * Applies a transformation the plane and returns the result
  70727. * @param transformation the transformation matrix to be applied to the plane
  70728. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70729. */
  70730. transform(transformation: DeepImmutable<Matrix>): Plane;
  70731. /**
  70732. * Calcualtte the dot product between the point and the plane normal
  70733. * @param point point to calculate the dot product with
  70734. * @returns the dot product (float) of the point coordinates and the plane normal.
  70735. */
  70736. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70737. /**
  70738. * Updates the current Plane from the plane defined by the three given points.
  70739. * @param point1 one of the points used to contruct the plane
  70740. * @param point2 one of the points used to contruct the plane
  70741. * @param point3 one of the points used to contruct the plane
  70742. * @returns the updated Plane.
  70743. */
  70744. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70745. /**
  70746. * Checks if the plane is facing a given direction
  70747. * @param direction the direction to check if the plane is facing
  70748. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70749. * @returns True is the vector "direction" is the same side than the plane normal.
  70750. */
  70751. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70752. /**
  70753. * Calculates the distance to a point
  70754. * @param point point to calculate distance to
  70755. * @returns the signed distance (float) from the given point to the Plane.
  70756. */
  70757. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70758. /**
  70759. * Creates a plane from an array
  70760. * @param array the array to create a plane from
  70761. * @returns a new Plane from the given array.
  70762. */
  70763. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  70764. /**
  70765. * Creates a plane from three points
  70766. * @param point1 point used to create the plane
  70767. * @param point2 point used to create the plane
  70768. * @param point3 point used to create the plane
  70769. * @returns a new Plane defined by the three given points.
  70770. */
  70771. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70772. /**
  70773. * Creates a plane from an origin point and a normal
  70774. * @param origin origin of the plane to be constructed
  70775. * @param normal normal of the plane to be constructed
  70776. * @returns a new Plane the normal vector to this plane at the given origin point.
  70777. * Note : the vector "normal" is updated because normalized.
  70778. */
  70779. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  70780. /**
  70781. * Calculates the distance from a plane and a point
  70782. * @param origin origin of the plane to be constructed
  70783. * @param normal normal of the plane to be constructed
  70784. * @param point point to calculate distance to
  70785. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  70786. */
  70787. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70788. }
  70789. }
  70790. declare module BABYLON {
  70791. /**
  70792. * Class used to store bounding sphere information
  70793. */
  70794. export class BoundingSphere {
  70795. /**
  70796. * Gets the center of the bounding sphere in local space
  70797. */
  70798. readonly center: Vector3;
  70799. /**
  70800. * Radius of the bounding sphere in local space
  70801. */
  70802. radius: number;
  70803. /**
  70804. * Gets the center of the bounding sphere in world space
  70805. */
  70806. readonly centerWorld: Vector3;
  70807. /**
  70808. * Radius of the bounding sphere in world space
  70809. */
  70810. radiusWorld: number;
  70811. /**
  70812. * Gets the minimum vector in local space
  70813. */
  70814. readonly minimum: Vector3;
  70815. /**
  70816. * Gets the maximum vector in local space
  70817. */
  70818. readonly maximum: Vector3;
  70819. private _worldMatrix;
  70820. private static readonly TmpVector3;
  70821. /**
  70822. * Creates a new bounding sphere
  70823. * @param min defines the minimum vector (in local space)
  70824. * @param max defines the maximum vector (in local space)
  70825. * @param worldMatrix defines the new world matrix
  70826. */
  70827. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70828. /**
  70829. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70830. * @param min defines the new minimum vector (in local space)
  70831. * @param max defines the new maximum vector (in local space)
  70832. * @param worldMatrix defines the new world matrix
  70833. */
  70834. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70835. /**
  70836. * Scale the current bounding sphere by applying a scale factor
  70837. * @param factor defines the scale factor to apply
  70838. * @returns the current bounding box
  70839. */
  70840. scale(factor: number): BoundingSphere;
  70841. /**
  70842. * Gets the world matrix of the bounding box
  70843. * @returns a matrix
  70844. */
  70845. getWorldMatrix(): DeepImmutable<Matrix>;
  70846. /** @hidden */
  70847. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70848. /**
  70849. * Tests if the bounding sphere is intersecting the frustum planes
  70850. * @param frustumPlanes defines the frustum planes to test
  70851. * @returns true if there is an intersection
  70852. */
  70853. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70854. /**
  70855. * Tests if the bounding sphere center is in between the frustum planes.
  70856. * Used for optimistic fast inclusion.
  70857. * @param frustumPlanes defines the frustum planes to test
  70858. * @returns true if the sphere center is in between the frustum planes
  70859. */
  70860. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70861. /**
  70862. * Tests if a point is inside the bounding sphere
  70863. * @param point defines the point to test
  70864. * @returns true if the point is inside the bounding sphere
  70865. */
  70866. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70867. /**
  70868. * Checks if two sphere intersct
  70869. * @param sphere0 sphere 0
  70870. * @param sphere1 sphere 1
  70871. * @returns true if the speres intersect
  70872. */
  70873. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70874. }
  70875. }
  70876. declare module BABYLON {
  70877. /**
  70878. * Class used to store bounding box information
  70879. */
  70880. export class BoundingBox implements ICullable {
  70881. /**
  70882. * Gets the 8 vectors representing the bounding box in local space
  70883. */
  70884. readonly vectors: Vector3[];
  70885. /**
  70886. * Gets the center of the bounding box in local space
  70887. */
  70888. readonly center: Vector3;
  70889. /**
  70890. * Gets the center of the bounding box in world space
  70891. */
  70892. readonly centerWorld: Vector3;
  70893. /**
  70894. * Gets the extend size in local space
  70895. */
  70896. readonly extendSize: Vector3;
  70897. /**
  70898. * Gets the extend size in world space
  70899. */
  70900. readonly extendSizeWorld: Vector3;
  70901. /**
  70902. * Gets the OBB (object bounding box) directions
  70903. */
  70904. readonly directions: Vector3[];
  70905. /**
  70906. * Gets the 8 vectors representing the bounding box in world space
  70907. */
  70908. readonly vectorsWorld: Vector3[];
  70909. /**
  70910. * Gets the minimum vector in world space
  70911. */
  70912. readonly minimumWorld: Vector3;
  70913. /**
  70914. * Gets the maximum vector in world space
  70915. */
  70916. readonly maximumWorld: Vector3;
  70917. /**
  70918. * Gets the minimum vector in local space
  70919. */
  70920. readonly minimum: Vector3;
  70921. /**
  70922. * Gets the maximum vector in local space
  70923. */
  70924. readonly maximum: Vector3;
  70925. private _worldMatrix;
  70926. private static readonly TmpVector3;
  70927. /**
  70928. * @hidden
  70929. */
  70930. _tag: number;
  70931. /**
  70932. * Creates a new bounding box
  70933. * @param min defines the minimum vector (in local space)
  70934. * @param max defines the maximum vector (in local space)
  70935. * @param worldMatrix defines the new world matrix
  70936. */
  70937. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70938. /**
  70939. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70940. * @param min defines the new minimum vector (in local space)
  70941. * @param max defines the new maximum vector (in local space)
  70942. * @param worldMatrix defines the new world matrix
  70943. */
  70944. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70945. /**
  70946. * Scale the current bounding box by applying a scale factor
  70947. * @param factor defines the scale factor to apply
  70948. * @returns the current bounding box
  70949. */
  70950. scale(factor: number): BoundingBox;
  70951. /**
  70952. * Gets the world matrix of the bounding box
  70953. * @returns a matrix
  70954. */
  70955. getWorldMatrix(): DeepImmutable<Matrix>;
  70956. /** @hidden */
  70957. _update(world: DeepImmutable<Matrix>): void;
  70958. /**
  70959. * Tests if the bounding box is intersecting the frustum planes
  70960. * @param frustumPlanes defines the frustum planes to test
  70961. * @returns true if there is an intersection
  70962. */
  70963. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70964. /**
  70965. * Tests if the bounding box is entirely inside the frustum planes
  70966. * @param frustumPlanes defines the frustum planes to test
  70967. * @returns true if there is an inclusion
  70968. */
  70969. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70970. /**
  70971. * Tests if a point is inside the bounding box
  70972. * @param point defines the point to test
  70973. * @returns true if the point is inside the bounding box
  70974. */
  70975. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70976. /**
  70977. * Tests if the bounding box intersects with a bounding sphere
  70978. * @param sphere defines the sphere to test
  70979. * @returns true if there is an intersection
  70980. */
  70981. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70982. /**
  70983. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70984. * @param min defines the min vector to use
  70985. * @param max defines the max vector to use
  70986. * @returns true if there is an intersection
  70987. */
  70988. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70989. /**
  70990. * Tests if two bounding boxes are intersections
  70991. * @param box0 defines the first box to test
  70992. * @param box1 defines the second box to test
  70993. * @returns true if there is an intersection
  70994. */
  70995. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70996. /**
  70997. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70998. * @param minPoint defines the minimum vector of the bounding box
  70999. * @param maxPoint defines the maximum vector of the bounding box
  71000. * @param sphereCenter defines the sphere center
  71001. * @param sphereRadius defines the sphere radius
  71002. * @returns true if there is an intersection
  71003. */
  71004. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71005. /**
  71006. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71007. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71008. * @param frustumPlanes defines the frustum planes to test
  71009. * @return true if there is an inclusion
  71010. */
  71011. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71012. /**
  71013. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71014. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71015. * @param frustumPlanes defines the frustum planes to test
  71016. * @return true if there is an intersection
  71017. */
  71018. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71019. }
  71020. }
  71021. declare module BABYLON {
  71022. /** @hidden */
  71023. export class Collider {
  71024. /** Define if a collision was found */
  71025. collisionFound: boolean;
  71026. /**
  71027. * Define last intersection point in local space
  71028. */
  71029. intersectionPoint: Vector3;
  71030. /**
  71031. * Define last collided mesh
  71032. */
  71033. collidedMesh: Nullable<AbstractMesh>;
  71034. private _collisionPoint;
  71035. private _planeIntersectionPoint;
  71036. private _tempVector;
  71037. private _tempVector2;
  71038. private _tempVector3;
  71039. private _tempVector4;
  71040. private _edge;
  71041. private _baseToVertex;
  71042. private _destinationPoint;
  71043. private _slidePlaneNormal;
  71044. private _displacementVector;
  71045. /** @hidden */
  71046. _radius: Vector3;
  71047. /** @hidden */
  71048. _retry: number;
  71049. private _velocity;
  71050. private _basePoint;
  71051. private _epsilon;
  71052. /** @hidden */
  71053. _velocityWorldLength: number;
  71054. /** @hidden */
  71055. _basePointWorld: Vector3;
  71056. private _velocityWorld;
  71057. private _normalizedVelocity;
  71058. /** @hidden */
  71059. _initialVelocity: Vector3;
  71060. /** @hidden */
  71061. _initialPosition: Vector3;
  71062. private _nearestDistance;
  71063. private _collisionMask;
  71064. collisionMask: number;
  71065. /**
  71066. * Gets the plane normal used to compute the sliding response (in local space)
  71067. */
  71068. readonly slidePlaneNormal: Vector3;
  71069. /** @hidden */
  71070. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71071. /** @hidden */
  71072. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71073. /** @hidden */
  71074. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71075. /** @hidden */
  71076. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71077. /** @hidden */
  71078. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71079. /** @hidden */
  71080. _getResponse(pos: Vector3, vel: Vector3): void;
  71081. }
  71082. }
  71083. declare module BABYLON {
  71084. /**
  71085. * Interface for cullable objects
  71086. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71087. */
  71088. export interface ICullable {
  71089. /**
  71090. * Checks if the object or part of the object is in the frustum
  71091. * @param frustumPlanes Camera near/planes
  71092. * @returns true if the object is in frustum otherwise false
  71093. */
  71094. isInFrustum(frustumPlanes: Plane[]): boolean;
  71095. /**
  71096. * Checks if a cullable object (mesh...) is in the camera frustum
  71097. * Unlike isInFrustum this cheks the full bounding box
  71098. * @param frustumPlanes Camera near/planes
  71099. * @returns true if the object is in frustum otherwise false
  71100. */
  71101. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71102. }
  71103. /**
  71104. * Info for a bounding data of a mesh
  71105. */
  71106. export class BoundingInfo implements ICullable {
  71107. /**
  71108. * Bounding box for the mesh
  71109. */
  71110. readonly boundingBox: BoundingBox;
  71111. /**
  71112. * Bounding sphere for the mesh
  71113. */
  71114. readonly boundingSphere: BoundingSphere;
  71115. private _isLocked;
  71116. private static readonly TmpVector3;
  71117. /**
  71118. * Constructs bounding info
  71119. * @param minimum min vector of the bounding box/sphere
  71120. * @param maximum max vector of the bounding box/sphere
  71121. * @param worldMatrix defines the new world matrix
  71122. */
  71123. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71124. /**
  71125. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71126. * @param min defines the new minimum vector (in local space)
  71127. * @param max defines the new maximum vector (in local space)
  71128. * @param worldMatrix defines the new world matrix
  71129. */
  71130. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71131. /**
  71132. * min vector of the bounding box/sphere
  71133. */
  71134. readonly minimum: Vector3;
  71135. /**
  71136. * max vector of the bounding box/sphere
  71137. */
  71138. readonly maximum: Vector3;
  71139. /**
  71140. * If the info is locked and won't be updated to avoid perf overhead
  71141. */
  71142. isLocked: boolean;
  71143. /**
  71144. * Updates the bounding sphere and box
  71145. * @param world world matrix to be used to update
  71146. */
  71147. update(world: DeepImmutable<Matrix>): void;
  71148. /**
  71149. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71150. * @param center New center of the bounding info
  71151. * @param extend New extend of the bounding info
  71152. * @returns the current bounding info
  71153. */
  71154. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71155. /**
  71156. * Scale the current bounding info by applying a scale factor
  71157. * @param factor defines the scale factor to apply
  71158. * @returns the current bounding info
  71159. */
  71160. scale(factor: number): BoundingInfo;
  71161. /**
  71162. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71163. * @param frustumPlanes defines the frustum to test
  71164. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71165. * @returns true if the bounding info is in the frustum planes
  71166. */
  71167. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71168. /**
  71169. * Gets the world distance between the min and max points of the bounding box
  71170. */
  71171. readonly diagonalLength: number;
  71172. /**
  71173. * Checks if a cullable object (mesh...) is in the camera frustum
  71174. * Unlike isInFrustum this cheks the full bounding box
  71175. * @param frustumPlanes Camera near/planes
  71176. * @returns true if the object is in frustum otherwise false
  71177. */
  71178. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71179. /** @hidden */
  71180. _checkCollision(collider: Collider): boolean;
  71181. /**
  71182. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71183. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71184. * @param point the point to check intersection with
  71185. * @returns if the point intersects
  71186. */
  71187. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71188. /**
  71189. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71190. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71191. * @param boundingInfo the bounding info to check intersection with
  71192. * @param precise if the intersection should be done using OBB
  71193. * @returns if the bounding info intersects
  71194. */
  71195. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71196. }
  71197. }
  71198. declare module BABYLON {
  71199. /**
  71200. * Extracts minimum and maximum values from a list of indexed positions
  71201. * @param positions defines the positions to use
  71202. * @param indices defines the indices to the positions
  71203. * @param indexStart defines the start index
  71204. * @param indexCount defines the end index
  71205. * @param bias defines bias value to add to the result
  71206. * @return minimum and maximum values
  71207. */
  71208. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71209. minimum: Vector3;
  71210. maximum: Vector3;
  71211. };
  71212. /**
  71213. * Extracts minimum and maximum values from a list of positions
  71214. * @param positions defines the positions to use
  71215. * @param start defines the start index in the positions array
  71216. * @param count defines the number of positions to handle
  71217. * @param bias defines bias value to add to the result
  71218. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71219. * @return minimum and maximum values
  71220. */
  71221. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71222. minimum: Vector3;
  71223. maximum: Vector3;
  71224. };
  71225. }
  71226. declare module BABYLON {
  71227. /**
  71228. * Enum that determines the text-wrapping mode to use.
  71229. */
  71230. export enum InspectableType {
  71231. /**
  71232. * Checkbox for booleans
  71233. */
  71234. Checkbox = 0,
  71235. /**
  71236. * Sliders for numbers
  71237. */
  71238. Slider = 1,
  71239. /**
  71240. * Vector3
  71241. */
  71242. Vector3 = 2,
  71243. /**
  71244. * Quaternions
  71245. */
  71246. Quaternion = 3,
  71247. /**
  71248. * Color3
  71249. */
  71250. Color3 = 4,
  71251. /**
  71252. * String
  71253. */
  71254. String = 5
  71255. }
  71256. /**
  71257. * Interface used to define custom inspectable properties.
  71258. * This interface is used by the inspector to display custom property grids
  71259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71260. */
  71261. export interface IInspectable {
  71262. /**
  71263. * Gets the label to display
  71264. */
  71265. label: string;
  71266. /**
  71267. * Gets the name of the property to edit
  71268. */
  71269. propertyName: string;
  71270. /**
  71271. * Gets the type of the editor to use
  71272. */
  71273. type: InspectableType;
  71274. /**
  71275. * Gets the minimum value of the property when using in "slider" mode
  71276. */
  71277. min?: number;
  71278. /**
  71279. * Gets the maximum value of the property when using in "slider" mode
  71280. */
  71281. max?: number;
  71282. /**
  71283. * Gets the setp to use when using in "slider" mode
  71284. */
  71285. step?: number;
  71286. }
  71287. }
  71288. declare module BABYLON {
  71289. /**
  71290. * Class used to provide helper for timing
  71291. */
  71292. export class TimingTools {
  71293. /**
  71294. * Polyfill for setImmediate
  71295. * @param action defines the action to execute after the current execution block
  71296. */
  71297. static SetImmediate(action: () => void): void;
  71298. }
  71299. }
  71300. declare module BABYLON {
  71301. /**
  71302. * Class used to enable instatition of objects by class name
  71303. */
  71304. export class InstantiationTools {
  71305. /**
  71306. * Use this object to register external classes like custom textures or material
  71307. * to allow the laoders to instantiate them
  71308. */
  71309. static RegisteredExternalClasses: {
  71310. [key: string]: Object;
  71311. };
  71312. /**
  71313. * Tries to instantiate a new object from a given class name
  71314. * @param className defines the class name to instantiate
  71315. * @returns the new object or null if the system was not able to do the instantiation
  71316. */
  71317. static Instantiate(className: string): any;
  71318. }
  71319. }
  71320. declare module BABYLON {
  71321. /**
  71322. * This represents the required contract to create a new type of texture loader.
  71323. */
  71324. export interface IInternalTextureLoader {
  71325. /**
  71326. * Defines wether the loader supports cascade loading the different faces.
  71327. */
  71328. supportCascades: boolean;
  71329. /**
  71330. * This returns if the loader support the current file information.
  71331. * @param extension defines the file extension of the file being loaded
  71332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71333. * @param fallback defines the fallback internal texture if any
  71334. * @param isBase64 defines whether the texture is encoded as a base64
  71335. * @param isBuffer defines whether the texture data are stored as a buffer
  71336. * @returns true if the loader can load the specified file
  71337. */
  71338. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71339. /**
  71340. * Transform the url before loading if required.
  71341. * @param rootUrl the url of the texture
  71342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71343. * @returns the transformed texture
  71344. */
  71345. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71346. /**
  71347. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71348. * @param rootUrl the url of the texture
  71349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71350. * @returns the fallback texture
  71351. */
  71352. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71353. /**
  71354. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71355. * @param data contains the texture data
  71356. * @param texture defines the BabylonJS internal texture
  71357. * @param createPolynomials will be true if polynomials have been requested
  71358. * @param onLoad defines the callback to trigger once the texture is ready
  71359. * @param onError defines the callback to trigger in case of error
  71360. */
  71361. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71362. /**
  71363. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71364. * @param data contains the texture data
  71365. * @param texture defines the BabylonJS internal texture
  71366. * @param callback defines the method to call once ready to upload
  71367. */
  71368. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71369. }
  71370. }
  71371. declare module BABYLON {
  71372. interface Engine {
  71373. /**
  71374. * Creates a depth stencil cube texture.
  71375. * This is only available in WebGL 2.
  71376. * @param size The size of face edge in the cube texture.
  71377. * @param options The options defining the cube texture.
  71378. * @returns The cube texture
  71379. */
  71380. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71381. /**
  71382. * Creates a cube texture
  71383. * @param rootUrl defines the url where the files to load is located
  71384. * @param scene defines the current scene
  71385. * @param files defines the list of files to load (1 per face)
  71386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71387. * @param onLoad defines an optional callback raised when the texture is loaded
  71388. * @param onError defines an optional callback raised if there is an issue to load the texture
  71389. * @param format defines the format of the data
  71390. * @param forcedExtension defines the extension to use to pick the right loader
  71391. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71392. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71393. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71394. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71395. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71396. * @returns the cube texture as an InternalTexture
  71397. */
  71398. 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;
  71399. /**
  71400. * Creates a cube texture
  71401. * @param rootUrl defines the url where the files to load is located
  71402. * @param scene defines the current scene
  71403. * @param files defines the list of files to load (1 per face)
  71404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71405. * @param onLoad defines an optional callback raised when the texture is loaded
  71406. * @param onError defines an optional callback raised if there is an issue to load the texture
  71407. * @param format defines the format of the data
  71408. * @param forcedExtension defines the extension to use to pick the right loader
  71409. * @returns the cube texture as an InternalTexture
  71410. */
  71411. 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;
  71412. /**
  71413. * Creates a cube texture
  71414. * @param rootUrl defines the url where the files to load is located
  71415. * @param scene defines the current scene
  71416. * @param files defines the list of files to load (1 per face)
  71417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71418. * @param onLoad defines an optional callback raised when the texture is loaded
  71419. * @param onError defines an optional callback raised if there is an issue to load the texture
  71420. * @param format defines the format of the data
  71421. * @param forcedExtension defines the extension to use to pick the right loader
  71422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71425. * @returns the cube texture as an InternalTexture
  71426. */
  71427. 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;
  71428. /** @hidden */
  71429. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71430. /** @hidden */
  71431. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71432. /** @hidden */
  71433. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71434. /** @hidden */
  71435. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /**
  71440. * Class for creating a cube texture
  71441. */
  71442. export class CubeTexture extends BaseTexture {
  71443. private _delayedOnLoad;
  71444. /**
  71445. * The url of the texture
  71446. */
  71447. url: string;
  71448. /**
  71449. * Gets or sets the center of the bounding box associated with the cube texture.
  71450. * It must define where the camera used to render the texture was set
  71451. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71452. */
  71453. boundingBoxPosition: Vector3;
  71454. private _boundingBoxSize;
  71455. /**
  71456. * Gets or sets the size of the bounding box associated with the cube texture
  71457. * When defined, the cubemap will switch to local mode
  71458. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71459. * @example https://www.babylonjs-playground.com/#RNASML
  71460. */
  71461. /**
  71462. * Returns the bounding box size
  71463. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71464. */
  71465. boundingBoxSize: Vector3;
  71466. protected _rotationY: number;
  71467. /**
  71468. * Sets texture matrix rotation angle around Y axis in radians.
  71469. */
  71470. /**
  71471. * Gets texture matrix rotation angle around Y axis radians.
  71472. */
  71473. rotationY: number;
  71474. /**
  71475. * Are mip maps generated for this texture or not.
  71476. */
  71477. readonly noMipmap: boolean;
  71478. private _noMipmap;
  71479. private _files;
  71480. private _extensions;
  71481. private _textureMatrix;
  71482. private _format;
  71483. private _createPolynomials;
  71484. /** @hidden */
  71485. _prefiltered: boolean;
  71486. /**
  71487. * Creates a cube texture from an array of image urls
  71488. * @param files defines an array of image urls
  71489. * @param scene defines the hosting scene
  71490. * @param noMipmap specifies if mip maps are not used
  71491. * @returns a cube texture
  71492. */
  71493. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71494. /**
  71495. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71496. * @param url defines the url of the prefiltered texture
  71497. * @param scene defines the scene the texture is attached to
  71498. * @param forcedExtension defines the extension of the file if different from the url
  71499. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71500. * @return the prefiltered texture
  71501. */
  71502. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71503. /**
  71504. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71505. * as prefiltered data.
  71506. * @param rootUrl defines the url of the texture or the root name of the six images
  71507. * @param scene defines the scene the texture is attached to
  71508. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71509. * @param noMipmap defines if mipmaps should be created or not
  71510. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71511. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71512. * @param onError defines a callback triggered in case of error during load
  71513. * @param format defines the internal format to use for the texture once loaded
  71514. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71515. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71516. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71519. * @return the cube texture
  71520. */
  71521. 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);
  71522. /**
  71523. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71524. */
  71525. readonly isPrefiltered: boolean;
  71526. /**
  71527. * Get the current class name of the texture useful for serialization or dynamic coding.
  71528. * @returns "CubeTexture"
  71529. */
  71530. getClassName(): string;
  71531. /**
  71532. * Update the url (and optional buffer) of this texture if url was null during construction.
  71533. * @param url the url of the texture
  71534. * @param forcedExtension defines the extension to use
  71535. * @param onLoad callback called when the texture is loaded (defaults to null)
  71536. */
  71537. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71538. /**
  71539. * Delays loading of the cube texture
  71540. * @param forcedExtension defines the extension to use
  71541. */
  71542. delayLoad(forcedExtension?: string): void;
  71543. /**
  71544. * Returns the reflection texture matrix
  71545. * @returns the reflection texture matrix
  71546. */
  71547. getReflectionTextureMatrix(): Matrix;
  71548. /**
  71549. * Sets the reflection texture matrix
  71550. * @param value Reflection texture matrix
  71551. */
  71552. setReflectionTextureMatrix(value: Matrix): void;
  71553. /**
  71554. * Parses text to create a cube texture
  71555. * @param parsedTexture define the serialized text to read from
  71556. * @param scene defines the hosting scene
  71557. * @param rootUrl defines the root url of the cube texture
  71558. * @returns a cube texture
  71559. */
  71560. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71561. /**
  71562. * Makes a clone, or deep copy, of the cube texture
  71563. * @returns a new cube texture
  71564. */
  71565. clone(): CubeTexture;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /**
  71570. * Manages the defines for the Material
  71571. */
  71572. export class MaterialDefines {
  71573. /** @hidden */
  71574. protected _keys: string[];
  71575. private _isDirty;
  71576. /** @hidden */
  71577. _renderId: number;
  71578. /** @hidden */
  71579. _areLightsDirty: boolean;
  71580. /** @hidden */
  71581. _areAttributesDirty: boolean;
  71582. /** @hidden */
  71583. _areTexturesDirty: boolean;
  71584. /** @hidden */
  71585. _areFresnelDirty: boolean;
  71586. /** @hidden */
  71587. _areMiscDirty: boolean;
  71588. /** @hidden */
  71589. _areImageProcessingDirty: boolean;
  71590. /** @hidden */
  71591. _normals: boolean;
  71592. /** @hidden */
  71593. _uvs: boolean;
  71594. /** @hidden */
  71595. _needNormals: boolean;
  71596. /** @hidden */
  71597. _needUVs: boolean;
  71598. [id: string]: any;
  71599. /**
  71600. * Specifies if the material needs to be re-calculated
  71601. */
  71602. readonly isDirty: boolean;
  71603. /**
  71604. * Marks the material to indicate that it has been re-calculated
  71605. */
  71606. markAsProcessed(): void;
  71607. /**
  71608. * Marks the material to indicate that it needs to be re-calculated
  71609. */
  71610. markAsUnprocessed(): void;
  71611. /**
  71612. * Marks the material to indicate all of its defines need to be re-calculated
  71613. */
  71614. markAllAsDirty(): void;
  71615. /**
  71616. * Marks the material to indicate that image processing needs to be re-calculated
  71617. */
  71618. markAsImageProcessingDirty(): void;
  71619. /**
  71620. * Marks the material to indicate the lights need to be re-calculated
  71621. */
  71622. markAsLightDirty(): void;
  71623. /**
  71624. * Marks the attribute state as changed
  71625. */
  71626. markAsAttributesDirty(): void;
  71627. /**
  71628. * Marks the texture state as changed
  71629. */
  71630. markAsTexturesDirty(): void;
  71631. /**
  71632. * Marks the fresnel state as changed
  71633. */
  71634. markAsFresnelDirty(): void;
  71635. /**
  71636. * Marks the misc state as changed
  71637. */
  71638. markAsMiscDirty(): void;
  71639. /**
  71640. * Rebuilds the material defines
  71641. */
  71642. rebuild(): void;
  71643. /**
  71644. * Specifies if two material defines are equal
  71645. * @param other - A material define instance to compare to
  71646. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71647. */
  71648. isEqual(other: MaterialDefines): boolean;
  71649. /**
  71650. * Clones this instance's defines to another instance
  71651. * @param other - material defines to clone values to
  71652. */
  71653. cloneTo(other: MaterialDefines): void;
  71654. /**
  71655. * Resets the material define values
  71656. */
  71657. reset(): void;
  71658. /**
  71659. * Converts the material define values to a string
  71660. * @returns - String of material define information
  71661. */
  71662. toString(): string;
  71663. }
  71664. }
  71665. declare module BABYLON {
  71666. /**
  71667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71669. * 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;
  71670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71671. */
  71672. export class ColorCurves {
  71673. private _dirty;
  71674. private _tempColor;
  71675. private _globalCurve;
  71676. private _highlightsCurve;
  71677. private _midtonesCurve;
  71678. private _shadowsCurve;
  71679. private _positiveCurve;
  71680. private _negativeCurve;
  71681. private _globalHue;
  71682. private _globalDensity;
  71683. private _globalSaturation;
  71684. private _globalExposure;
  71685. /**
  71686. * Gets the global Hue value.
  71687. * 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).
  71688. */
  71689. /**
  71690. * Sets the global Hue value.
  71691. * 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).
  71692. */
  71693. globalHue: number;
  71694. /**
  71695. * Gets the global Density value.
  71696. * 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.
  71697. * Values less than zero provide a filter of opposite hue.
  71698. */
  71699. /**
  71700. * Sets the global Density value.
  71701. * 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.
  71702. * Values less than zero provide a filter of opposite hue.
  71703. */
  71704. globalDensity: number;
  71705. /**
  71706. * Gets the global Saturation value.
  71707. * 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.
  71708. */
  71709. /**
  71710. * Sets the global Saturation value.
  71711. * 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.
  71712. */
  71713. globalSaturation: number;
  71714. /**
  71715. * Gets the global Exposure value.
  71716. * 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.
  71717. */
  71718. /**
  71719. * Sets the global Exposure value.
  71720. * 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.
  71721. */
  71722. globalExposure: number;
  71723. private _highlightsHue;
  71724. private _highlightsDensity;
  71725. private _highlightsSaturation;
  71726. private _highlightsExposure;
  71727. /**
  71728. * Gets the highlights Hue value.
  71729. * 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).
  71730. */
  71731. /**
  71732. * Sets the highlights Hue value.
  71733. * 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).
  71734. */
  71735. highlightsHue: number;
  71736. /**
  71737. * Gets the highlights Density value.
  71738. * 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.
  71739. * Values less than zero provide a filter of opposite hue.
  71740. */
  71741. /**
  71742. * Sets the highlights Density value.
  71743. * 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.
  71744. * Values less than zero provide a filter of opposite hue.
  71745. */
  71746. highlightsDensity: number;
  71747. /**
  71748. * Gets the highlights Saturation value.
  71749. * 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.
  71750. */
  71751. /**
  71752. * Sets the highlights Saturation value.
  71753. * 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.
  71754. */
  71755. highlightsSaturation: number;
  71756. /**
  71757. * Gets the highlights Exposure value.
  71758. * 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.
  71759. */
  71760. /**
  71761. * Sets the highlights Exposure value.
  71762. * 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.
  71763. */
  71764. highlightsExposure: number;
  71765. private _midtonesHue;
  71766. private _midtonesDensity;
  71767. private _midtonesSaturation;
  71768. private _midtonesExposure;
  71769. /**
  71770. * Gets the midtones Hue value.
  71771. * 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).
  71772. */
  71773. /**
  71774. * Sets the midtones Hue value.
  71775. * 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).
  71776. */
  71777. midtonesHue: number;
  71778. /**
  71779. * Gets the midtones Density value.
  71780. * 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.
  71781. * Values less than zero provide a filter of opposite hue.
  71782. */
  71783. /**
  71784. * Sets the midtones Density value.
  71785. * 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.
  71786. * Values less than zero provide a filter of opposite hue.
  71787. */
  71788. midtonesDensity: number;
  71789. /**
  71790. * Gets the midtones Saturation value.
  71791. * 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.
  71792. */
  71793. /**
  71794. * Sets the midtones Saturation value.
  71795. * 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.
  71796. */
  71797. midtonesSaturation: number;
  71798. /**
  71799. * Gets the midtones Exposure value.
  71800. * 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.
  71801. */
  71802. /**
  71803. * Sets the midtones Exposure value.
  71804. * 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.
  71805. */
  71806. midtonesExposure: number;
  71807. private _shadowsHue;
  71808. private _shadowsDensity;
  71809. private _shadowsSaturation;
  71810. private _shadowsExposure;
  71811. /**
  71812. * Gets the shadows Hue value.
  71813. * 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).
  71814. */
  71815. /**
  71816. * Sets the shadows Hue value.
  71817. * 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).
  71818. */
  71819. shadowsHue: number;
  71820. /**
  71821. * Gets the shadows Density value.
  71822. * 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.
  71823. * Values less than zero provide a filter of opposite hue.
  71824. */
  71825. /**
  71826. * Sets the shadows Density value.
  71827. * 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.
  71828. * Values less than zero provide a filter of opposite hue.
  71829. */
  71830. shadowsDensity: number;
  71831. /**
  71832. * Gets the shadows Saturation value.
  71833. * 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.
  71834. */
  71835. /**
  71836. * Sets the shadows Saturation value.
  71837. * 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.
  71838. */
  71839. shadowsSaturation: number;
  71840. /**
  71841. * Gets the shadows Exposure value.
  71842. * 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.
  71843. */
  71844. /**
  71845. * Sets the shadows Exposure value.
  71846. * 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.
  71847. */
  71848. shadowsExposure: number;
  71849. /**
  71850. * Returns the class name
  71851. * @returns The class name
  71852. */
  71853. getClassName(): string;
  71854. /**
  71855. * Binds the color curves to the shader.
  71856. * @param colorCurves The color curve to bind
  71857. * @param effect The effect to bind to
  71858. * @param positiveUniform The positive uniform shader parameter
  71859. * @param neutralUniform The neutral uniform shader parameter
  71860. * @param negativeUniform The negative uniform shader parameter
  71861. */
  71862. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71863. /**
  71864. * Prepare the list of uniforms associated with the ColorCurves effects.
  71865. * @param uniformsList The list of uniforms used in the effect
  71866. */
  71867. static PrepareUniforms(uniformsList: string[]): void;
  71868. /**
  71869. * Returns color grading data based on a hue, density, saturation and exposure value.
  71870. * @param filterHue The hue of the color filter.
  71871. * @param filterDensity The density of the color filter.
  71872. * @param saturation The saturation.
  71873. * @param exposure The exposure.
  71874. * @param result The result data container.
  71875. */
  71876. private getColorGradingDataToRef;
  71877. /**
  71878. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71879. * @param value The input slider value in range [-100,100].
  71880. * @returns Adjusted value.
  71881. */
  71882. private static applyColorGradingSliderNonlinear;
  71883. /**
  71884. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71885. * @param hue The hue (H) input.
  71886. * @param saturation The saturation (S) input.
  71887. * @param brightness The brightness (B) input.
  71888. * @result An RGBA color represented as Vector4.
  71889. */
  71890. private static fromHSBToRef;
  71891. /**
  71892. * Returns a value clamped between min and max
  71893. * @param value The value to clamp
  71894. * @param min The minimum of value
  71895. * @param max The maximum of value
  71896. * @returns The clamped value.
  71897. */
  71898. private static clamp;
  71899. /**
  71900. * Clones the current color curve instance.
  71901. * @return The cloned curves
  71902. */
  71903. clone(): ColorCurves;
  71904. /**
  71905. * Serializes the current color curve instance to a json representation.
  71906. * @return a JSON representation
  71907. */
  71908. serialize(): any;
  71909. /**
  71910. * Parses the color curve from a json representation.
  71911. * @param source the JSON source to parse
  71912. * @return The parsed curves
  71913. */
  71914. static Parse(source: any): ColorCurves;
  71915. }
  71916. }
  71917. declare module BABYLON {
  71918. /**
  71919. * Interface to follow in your material defines to integrate easily the
  71920. * Image proccessing functions.
  71921. * @hidden
  71922. */
  71923. export interface IImageProcessingConfigurationDefines {
  71924. IMAGEPROCESSING: boolean;
  71925. VIGNETTE: boolean;
  71926. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71927. VIGNETTEBLENDMODEOPAQUE: boolean;
  71928. TONEMAPPING: boolean;
  71929. TONEMAPPING_ACES: boolean;
  71930. CONTRAST: boolean;
  71931. EXPOSURE: boolean;
  71932. COLORCURVES: boolean;
  71933. COLORGRADING: boolean;
  71934. COLORGRADING3D: boolean;
  71935. SAMPLER3DGREENDEPTH: boolean;
  71936. SAMPLER3DBGRMAP: boolean;
  71937. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71938. }
  71939. /**
  71940. * @hidden
  71941. */
  71942. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71943. IMAGEPROCESSING: boolean;
  71944. VIGNETTE: boolean;
  71945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71946. VIGNETTEBLENDMODEOPAQUE: boolean;
  71947. TONEMAPPING: boolean;
  71948. TONEMAPPING_ACES: boolean;
  71949. CONTRAST: boolean;
  71950. COLORCURVES: boolean;
  71951. COLORGRADING: boolean;
  71952. COLORGRADING3D: boolean;
  71953. SAMPLER3DGREENDEPTH: boolean;
  71954. SAMPLER3DBGRMAP: boolean;
  71955. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71956. EXPOSURE: boolean;
  71957. constructor();
  71958. }
  71959. /**
  71960. * This groups together the common properties used for image processing either in direct forward pass
  71961. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71962. * or not.
  71963. */
  71964. export class ImageProcessingConfiguration {
  71965. /**
  71966. * Default tone mapping applied in BabylonJS.
  71967. */
  71968. static readonly TONEMAPPING_STANDARD: number;
  71969. /**
  71970. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71971. * to other engines rendering to increase portability.
  71972. */
  71973. static readonly TONEMAPPING_ACES: number;
  71974. /**
  71975. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71976. */
  71977. colorCurves: Nullable<ColorCurves>;
  71978. private _colorCurvesEnabled;
  71979. /**
  71980. * Gets wether the color curves effect is enabled.
  71981. */
  71982. /**
  71983. * Sets wether the color curves effect is enabled.
  71984. */
  71985. colorCurvesEnabled: boolean;
  71986. private _colorGradingTexture;
  71987. /**
  71988. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71989. */
  71990. /**
  71991. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71992. */
  71993. colorGradingTexture: Nullable<BaseTexture>;
  71994. private _colorGradingEnabled;
  71995. /**
  71996. * Gets wether the color grading effect is enabled.
  71997. */
  71998. /**
  71999. * Sets wether the color grading effect is enabled.
  72000. */
  72001. colorGradingEnabled: boolean;
  72002. private _colorGradingWithGreenDepth;
  72003. /**
  72004. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72005. */
  72006. /**
  72007. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72008. */
  72009. colorGradingWithGreenDepth: boolean;
  72010. private _colorGradingBGR;
  72011. /**
  72012. * Gets wether the color grading texture contains BGR values.
  72013. */
  72014. /**
  72015. * Sets wether the color grading texture contains BGR values.
  72016. */
  72017. colorGradingBGR: boolean;
  72018. /** @hidden */
  72019. _exposure: number;
  72020. /**
  72021. * Gets the Exposure used in the effect.
  72022. */
  72023. /**
  72024. * Sets the Exposure used in the effect.
  72025. */
  72026. exposure: number;
  72027. private _toneMappingEnabled;
  72028. /**
  72029. * Gets wether the tone mapping effect is enabled.
  72030. */
  72031. /**
  72032. * Sets wether the tone mapping effect is enabled.
  72033. */
  72034. toneMappingEnabled: boolean;
  72035. private _toneMappingType;
  72036. /**
  72037. * Gets the type of tone mapping effect.
  72038. */
  72039. /**
  72040. * Sets the type of tone mapping effect used in BabylonJS.
  72041. */
  72042. toneMappingType: number;
  72043. protected _contrast: number;
  72044. /**
  72045. * Gets the contrast used in the effect.
  72046. */
  72047. /**
  72048. * Sets the contrast used in the effect.
  72049. */
  72050. contrast: number;
  72051. /**
  72052. * Vignette stretch size.
  72053. */
  72054. vignetteStretch: number;
  72055. /**
  72056. * Vignette centre X Offset.
  72057. */
  72058. vignetteCentreX: number;
  72059. /**
  72060. * Vignette centre Y Offset.
  72061. */
  72062. vignetteCentreY: number;
  72063. /**
  72064. * Vignette weight or intensity of the vignette effect.
  72065. */
  72066. vignetteWeight: number;
  72067. /**
  72068. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72069. * if vignetteEnabled is set to true.
  72070. */
  72071. vignetteColor: Color4;
  72072. /**
  72073. * Camera field of view used by the Vignette effect.
  72074. */
  72075. vignetteCameraFov: number;
  72076. private _vignetteBlendMode;
  72077. /**
  72078. * Gets the vignette blend mode allowing different kind of effect.
  72079. */
  72080. /**
  72081. * Sets the vignette blend mode allowing different kind of effect.
  72082. */
  72083. vignetteBlendMode: number;
  72084. private _vignetteEnabled;
  72085. /**
  72086. * Gets wether the vignette effect is enabled.
  72087. */
  72088. /**
  72089. * Sets wether the vignette effect is enabled.
  72090. */
  72091. vignetteEnabled: boolean;
  72092. private _applyByPostProcess;
  72093. /**
  72094. * Gets wether the image processing is applied through a post process or not.
  72095. */
  72096. /**
  72097. * Sets wether the image processing is applied through a post process or not.
  72098. */
  72099. applyByPostProcess: boolean;
  72100. private _isEnabled;
  72101. /**
  72102. * Gets wether the image processing is enabled or not.
  72103. */
  72104. /**
  72105. * Sets wether the image processing is enabled or not.
  72106. */
  72107. isEnabled: boolean;
  72108. /**
  72109. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72110. */
  72111. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72112. /**
  72113. * Method called each time the image processing information changes requires to recompile the effect.
  72114. */
  72115. protected _updateParameters(): void;
  72116. /**
  72117. * Gets the current class name.
  72118. * @return "ImageProcessingConfiguration"
  72119. */
  72120. getClassName(): string;
  72121. /**
  72122. * Prepare the list of uniforms associated with the Image Processing effects.
  72123. * @param uniforms The list of uniforms used in the effect
  72124. * @param defines the list of defines currently in use
  72125. */
  72126. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72127. /**
  72128. * Prepare the list of samplers associated with the Image Processing effects.
  72129. * @param samplersList The list of uniforms used in the effect
  72130. * @param defines the list of defines currently in use
  72131. */
  72132. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72133. /**
  72134. * Prepare the list of defines associated to the shader.
  72135. * @param defines the list of defines to complete
  72136. * @param forPostProcess Define if we are currently in post process mode or not
  72137. */
  72138. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72139. /**
  72140. * Returns true if all the image processing information are ready.
  72141. * @returns True if ready, otherwise, false
  72142. */
  72143. isReady(): boolean;
  72144. /**
  72145. * Binds the image processing to the shader.
  72146. * @param effect The effect to bind to
  72147. * @param aspectRatio Define the current aspect ratio of the effect
  72148. */
  72149. bind(effect: Effect, aspectRatio?: number): void;
  72150. /**
  72151. * Clones the current image processing instance.
  72152. * @return The cloned image processing
  72153. */
  72154. clone(): ImageProcessingConfiguration;
  72155. /**
  72156. * Serializes the current image processing instance to a json representation.
  72157. * @return a JSON representation
  72158. */
  72159. serialize(): any;
  72160. /**
  72161. * Parses the image processing from a json representation.
  72162. * @param source the JSON source to parse
  72163. * @return The parsed image processing
  72164. */
  72165. static Parse(source: any): ImageProcessingConfiguration;
  72166. private static _VIGNETTEMODE_MULTIPLY;
  72167. private static _VIGNETTEMODE_OPAQUE;
  72168. /**
  72169. * Used to apply the vignette as a mix with the pixel color.
  72170. */
  72171. static readonly VIGNETTEMODE_MULTIPLY: number;
  72172. /**
  72173. * Used to apply the vignette as a replacement of the pixel color.
  72174. */
  72175. static readonly VIGNETTEMODE_OPAQUE: number;
  72176. }
  72177. }
  72178. declare module BABYLON {
  72179. /** @hidden */
  72180. export var postprocessVertexShader: {
  72181. name: string;
  72182. shader: string;
  72183. };
  72184. }
  72185. declare module BABYLON {
  72186. /** Defines supported spaces */
  72187. export enum Space {
  72188. /** Local (object) space */
  72189. LOCAL = 0,
  72190. /** World space */
  72191. WORLD = 1,
  72192. /** Bone space */
  72193. BONE = 2
  72194. }
  72195. /** Defines the 3 main axes */
  72196. export class Axis {
  72197. /** X axis */
  72198. static X: Vector3;
  72199. /** Y axis */
  72200. static Y: Vector3;
  72201. /** Z axis */
  72202. static Z: Vector3;
  72203. }
  72204. }
  72205. declare module BABYLON {
  72206. /**
  72207. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72208. * This is the base of the follow, arc rotate cameras and Free camera
  72209. * @see http://doc.babylonjs.com/features/cameras
  72210. */
  72211. export class TargetCamera extends Camera {
  72212. private static _RigCamTransformMatrix;
  72213. private static _TargetTransformMatrix;
  72214. private static _TargetFocalPoint;
  72215. /**
  72216. * Define the current direction the camera is moving to
  72217. */
  72218. cameraDirection: Vector3;
  72219. /**
  72220. * Define the current rotation the camera is rotating to
  72221. */
  72222. cameraRotation: Vector2;
  72223. /**
  72224. * When set, the up vector of the camera will be updated by the rotation of the camera
  72225. */
  72226. updateUpVectorFromRotation: boolean;
  72227. private _tmpQuaternion;
  72228. /**
  72229. * Define the current rotation of the camera
  72230. */
  72231. rotation: Vector3;
  72232. /**
  72233. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72234. */
  72235. rotationQuaternion: Quaternion;
  72236. /**
  72237. * Define the current speed of the camera
  72238. */
  72239. speed: number;
  72240. /**
  72241. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72242. * around all axis.
  72243. */
  72244. noRotationConstraint: boolean;
  72245. /**
  72246. * Define the current target of the camera as an object or a position.
  72247. */
  72248. lockedTarget: any;
  72249. /** @hidden */
  72250. _currentTarget: Vector3;
  72251. /** @hidden */
  72252. _initialFocalDistance: number;
  72253. /** @hidden */
  72254. _viewMatrix: Matrix;
  72255. /** @hidden */
  72256. _camMatrix: Matrix;
  72257. /** @hidden */
  72258. _cameraTransformMatrix: Matrix;
  72259. /** @hidden */
  72260. _cameraRotationMatrix: Matrix;
  72261. /** @hidden */
  72262. _referencePoint: Vector3;
  72263. /** @hidden */
  72264. _transformedReferencePoint: Vector3;
  72265. protected _globalCurrentTarget: Vector3;
  72266. protected _globalCurrentUpVector: Vector3;
  72267. /** @hidden */
  72268. _reset: () => void;
  72269. private _defaultUp;
  72270. /**
  72271. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72272. * This is the base of the follow, arc rotate cameras and Free camera
  72273. * @see http://doc.babylonjs.com/features/cameras
  72274. * @param name Defines the name of the camera in the scene
  72275. * @param position Defines the start position of the camera in the scene
  72276. * @param scene Defines the scene the camera belongs to
  72277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72278. */
  72279. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72280. /**
  72281. * Gets the position in front of the camera at a given distance.
  72282. * @param distance The distance from the camera we want the position to be
  72283. * @returns the position
  72284. */
  72285. getFrontPosition(distance: number): Vector3;
  72286. /** @hidden */
  72287. _getLockedTargetPosition(): Nullable<Vector3>;
  72288. private _storedPosition;
  72289. private _storedRotation;
  72290. private _storedRotationQuaternion;
  72291. /**
  72292. * Store current camera state of the camera (fov, position, rotation, etc..)
  72293. * @returns the camera
  72294. */
  72295. storeState(): Camera;
  72296. /**
  72297. * Restored camera state. You must call storeState() first
  72298. * @returns whether it was successful or not
  72299. * @hidden
  72300. */
  72301. _restoreStateValues(): boolean;
  72302. /** @hidden */
  72303. _initCache(): void;
  72304. /** @hidden */
  72305. _updateCache(ignoreParentClass?: boolean): void;
  72306. /** @hidden */
  72307. _isSynchronizedViewMatrix(): boolean;
  72308. /** @hidden */
  72309. _computeLocalCameraSpeed(): number;
  72310. /**
  72311. * Defines the target the camera should look at.
  72312. * @param target Defines the new target as a Vector or a mesh
  72313. */
  72314. setTarget(target: Vector3): void;
  72315. /**
  72316. * Return the current target position of the camera. This value is expressed in local space.
  72317. * @returns the target position
  72318. */
  72319. getTarget(): Vector3;
  72320. /** @hidden */
  72321. _decideIfNeedsToMove(): boolean;
  72322. /** @hidden */
  72323. _updatePosition(): void;
  72324. /** @hidden */
  72325. _checkInputs(): void;
  72326. protected _updateCameraRotationMatrix(): void;
  72327. /**
  72328. * 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)
  72329. * @returns the current camera
  72330. */
  72331. private _rotateUpVectorWithCameraRotationMatrix;
  72332. private _cachedRotationZ;
  72333. private _cachedQuaternionRotationZ;
  72334. /** @hidden */
  72335. _getViewMatrix(): Matrix;
  72336. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72337. /**
  72338. * @hidden
  72339. */
  72340. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72341. /**
  72342. * @hidden
  72343. */
  72344. _updateRigCameras(): void;
  72345. private _getRigCamPositionAndTarget;
  72346. /**
  72347. * Gets the current object class name.
  72348. * @return the class name
  72349. */
  72350. getClassName(): string;
  72351. }
  72352. }
  72353. declare module BABYLON {
  72354. /**
  72355. * Gather the list of keyboard event types as constants.
  72356. */
  72357. export class KeyboardEventTypes {
  72358. /**
  72359. * The keydown event is fired when a key becomes active (pressed).
  72360. */
  72361. static readonly KEYDOWN: number;
  72362. /**
  72363. * The keyup event is fired when a key has been released.
  72364. */
  72365. static readonly KEYUP: number;
  72366. }
  72367. /**
  72368. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72369. */
  72370. export class KeyboardInfo {
  72371. /**
  72372. * Defines the type of event (KeyboardEventTypes)
  72373. */
  72374. type: number;
  72375. /**
  72376. * Defines the related dom event
  72377. */
  72378. event: KeyboardEvent;
  72379. /**
  72380. * Instantiates a new keyboard info.
  72381. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72382. * @param type Defines the type of event (KeyboardEventTypes)
  72383. * @param event Defines the related dom event
  72384. */
  72385. constructor(
  72386. /**
  72387. * Defines the type of event (KeyboardEventTypes)
  72388. */
  72389. type: number,
  72390. /**
  72391. * Defines the related dom event
  72392. */
  72393. event: KeyboardEvent);
  72394. }
  72395. /**
  72396. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72397. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72398. */
  72399. export class KeyboardInfoPre extends KeyboardInfo {
  72400. /**
  72401. * Defines the type of event (KeyboardEventTypes)
  72402. */
  72403. type: number;
  72404. /**
  72405. * Defines the related dom event
  72406. */
  72407. event: KeyboardEvent;
  72408. /**
  72409. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72410. */
  72411. skipOnPointerObservable: boolean;
  72412. /**
  72413. * Instantiates a new keyboard pre info.
  72414. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72415. * @param type Defines the type of event (KeyboardEventTypes)
  72416. * @param event Defines the related dom event
  72417. */
  72418. constructor(
  72419. /**
  72420. * Defines the type of event (KeyboardEventTypes)
  72421. */
  72422. type: number,
  72423. /**
  72424. * Defines the related dom event
  72425. */
  72426. event: KeyboardEvent);
  72427. }
  72428. }
  72429. declare module BABYLON {
  72430. /**
  72431. * Manage the keyboard inputs to control the movement of a free camera.
  72432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72433. */
  72434. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72435. /**
  72436. * Defines the camera the input is attached to.
  72437. */
  72438. camera: FreeCamera;
  72439. /**
  72440. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72441. */
  72442. keysUp: number[];
  72443. /**
  72444. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72445. */
  72446. keysDown: number[];
  72447. /**
  72448. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72449. */
  72450. keysLeft: number[];
  72451. /**
  72452. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72453. */
  72454. keysRight: number[];
  72455. private _keys;
  72456. private _onCanvasBlurObserver;
  72457. private _onKeyboardObserver;
  72458. private _engine;
  72459. private _scene;
  72460. /**
  72461. * Attach the input controls to a specific dom element to get the input from.
  72462. * @param element Defines the element the controls should be listened from
  72463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72464. */
  72465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72466. /**
  72467. * Detach the current controls from the specified dom element.
  72468. * @param element Defines the element to stop listening the inputs from
  72469. */
  72470. detachControl(element: Nullable<HTMLElement>): void;
  72471. /**
  72472. * Update the current camera state depending on the inputs that have been used this frame.
  72473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72474. */
  72475. checkInputs(): void;
  72476. /**
  72477. * Gets the class name of the current intput.
  72478. * @returns the class name
  72479. */
  72480. getClassName(): string;
  72481. /** @hidden */
  72482. _onLostFocus(): void;
  72483. /**
  72484. * Get the friendly name associated with the input class.
  72485. * @returns the input friendly name
  72486. */
  72487. getSimpleName(): string;
  72488. }
  72489. }
  72490. declare module BABYLON {
  72491. /**
  72492. * Interface describing all the common properties and methods a shadow light needs to implement.
  72493. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72494. * as well as binding the different shadow properties to the effects.
  72495. */
  72496. export interface IShadowLight extends Light {
  72497. /**
  72498. * The light id in the scene (used in scene.findLighById for instance)
  72499. */
  72500. id: string;
  72501. /**
  72502. * The position the shdow will be casted from.
  72503. */
  72504. position: Vector3;
  72505. /**
  72506. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72507. */
  72508. direction: Vector3;
  72509. /**
  72510. * The transformed position. Position of the light in world space taking parenting in account.
  72511. */
  72512. transformedPosition: Vector3;
  72513. /**
  72514. * The transformed direction. Direction of the light in world space taking parenting in account.
  72515. */
  72516. transformedDirection: Vector3;
  72517. /**
  72518. * The friendly name of the light in the scene.
  72519. */
  72520. name: string;
  72521. /**
  72522. * Defines the shadow projection clipping minimum z value.
  72523. */
  72524. shadowMinZ: number;
  72525. /**
  72526. * Defines the shadow projection clipping maximum z value.
  72527. */
  72528. shadowMaxZ: number;
  72529. /**
  72530. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72531. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72532. */
  72533. computeTransformedInformation(): boolean;
  72534. /**
  72535. * Gets the scene the light belongs to.
  72536. * @returns The scene
  72537. */
  72538. getScene(): Scene;
  72539. /**
  72540. * Callback defining a custom Projection Matrix Builder.
  72541. * This can be used to override the default projection matrix computation.
  72542. */
  72543. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72544. /**
  72545. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72546. * @param matrix The materix to updated with the projection information
  72547. * @param viewMatrix The transform matrix of the light
  72548. * @param renderList The list of mesh to render in the map
  72549. * @returns The current light
  72550. */
  72551. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72552. /**
  72553. * Gets the current depth scale used in ESM.
  72554. * @returns The scale
  72555. */
  72556. getDepthScale(): number;
  72557. /**
  72558. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72559. * @returns true if a cube texture needs to be use
  72560. */
  72561. needCube(): boolean;
  72562. /**
  72563. * Detects if the projection matrix requires to be recomputed this frame.
  72564. * @returns true if it requires to be recomputed otherwise, false.
  72565. */
  72566. needProjectionMatrixCompute(): boolean;
  72567. /**
  72568. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72569. */
  72570. forceProjectionMatrixCompute(): void;
  72571. /**
  72572. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72573. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72574. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72575. */
  72576. getShadowDirection(faceIndex?: number): Vector3;
  72577. /**
  72578. * Gets the minZ used for shadow according to both the scene and the light.
  72579. * @param activeCamera The camera we are returning the min for
  72580. * @returns the depth min z
  72581. */
  72582. getDepthMinZ(activeCamera: Camera): number;
  72583. /**
  72584. * Gets the maxZ used for shadow according to both the scene and the light.
  72585. * @param activeCamera The camera we are returning the max for
  72586. * @returns the depth max z
  72587. */
  72588. getDepthMaxZ(activeCamera: Camera): number;
  72589. }
  72590. /**
  72591. * Base implementation IShadowLight
  72592. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72593. */
  72594. export abstract class ShadowLight extends Light implements IShadowLight {
  72595. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72596. protected _position: Vector3;
  72597. protected _setPosition(value: Vector3): void;
  72598. /**
  72599. * Sets the position the shadow will be casted from. Also use as the light position for both
  72600. * point and spot lights.
  72601. */
  72602. /**
  72603. * Sets the position the shadow will be casted from. Also use as the light position for both
  72604. * point and spot lights.
  72605. */
  72606. position: Vector3;
  72607. protected _direction: Vector3;
  72608. protected _setDirection(value: Vector3): void;
  72609. /**
  72610. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72611. * Also use as the light direction on spot and directional lights.
  72612. */
  72613. /**
  72614. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72615. * Also use as the light direction on spot and directional lights.
  72616. */
  72617. direction: Vector3;
  72618. private _shadowMinZ;
  72619. /**
  72620. * Gets the shadow projection clipping minimum z value.
  72621. */
  72622. /**
  72623. * Sets the shadow projection clipping minimum z value.
  72624. */
  72625. shadowMinZ: number;
  72626. private _shadowMaxZ;
  72627. /**
  72628. * Sets the shadow projection clipping maximum z value.
  72629. */
  72630. /**
  72631. * Gets the shadow projection clipping maximum z value.
  72632. */
  72633. shadowMaxZ: number;
  72634. /**
  72635. * Callback defining a custom Projection Matrix Builder.
  72636. * This can be used to override the default projection matrix computation.
  72637. */
  72638. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72639. /**
  72640. * The transformed position. Position of the light in world space taking parenting in account.
  72641. */
  72642. transformedPosition: Vector3;
  72643. /**
  72644. * The transformed direction. Direction of the light in world space taking parenting in account.
  72645. */
  72646. transformedDirection: Vector3;
  72647. private _needProjectionMatrixCompute;
  72648. /**
  72649. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72650. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72651. */
  72652. computeTransformedInformation(): boolean;
  72653. /**
  72654. * Return the depth scale used for the shadow map.
  72655. * @returns the depth scale.
  72656. */
  72657. getDepthScale(): number;
  72658. /**
  72659. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72660. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72661. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72662. */
  72663. getShadowDirection(faceIndex?: number): Vector3;
  72664. /**
  72665. * Returns the ShadowLight absolute position in the World.
  72666. * @returns the position vector in world space
  72667. */
  72668. getAbsolutePosition(): Vector3;
  72669. /**
  72670. * Sets the ShadowLight direction toward the passed target.
  72671. * @param target The point to target in local space
  72672. * @returns the updated ShadowLight direction
  72673. */
  72674. setDirectionToTarget(target: Vector3): Vector3;
  72675. /**
  72676. * Returns the light rotation in euler definition.
  72677. * @returns the x y z rotation in local space.
  72678. */
  72679. getRotation(): Vector3;
  72680. /**
  72681. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72682. * @returns true if a cube texture needs to be use
  72683. */
  72684. needCube(): boolean;
  72685. /**
  72686. * Detects if the projection matrix requires to be recomputed this frame.
  72687. * @returns true if it requires to be recomputed otherwise, false.
  72688. */
  72689. needProjectionMatrixCompute(): boolean;
  72690. /**
  72691. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72692. */
  72693. forceProjectionMatrixCompute(): void;
  72694. /** @hidden */
  72695. _initCache(): void;
  72696. /** @hidden */
  72697. _isSynchronized(): boolean;
  72698. /**
  72699. * Computes the world matrix of the node
  72700. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72701. * @returns the world matrix
  72702. */
  72703. computeWorldMatrix(force?: boolean): Matrix;
  72704. /**
  72705. * Gets the minZ used for shadow according to both the scene and the light.
  72706. * @param activeCamera The camera we are returning the min for
  72707. * @returns the depth min z
  72708. */
  72709. getDepthMinZ(activeCamera: Camera): number;
  72710. /**
  72711. * Gets the maxZ used for shadow according to both the scene and the light.
  72712. * @param activeCamera The camera we are returning the max for
  72713. * @returns the depth max z
  72714. */
  72715. getDepthMaxZ(activeCamera: Camera): number;
  72716. /**
  72717. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72718. * @param matrix The materix to updated with the projection information
  72719. * @param viewMatrix The transform matrix of the light
  72720. * @param renderList The list of mesh to render in the map
  72721. * @returns The current light
  72722. */
  72723. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72724. }
  72725. }
  72726. declare module BABYLON {
  72727. /**
  72728. * "Static Class" containing the most commonly used helper while dealing with material for
  72729. * rendering purpose.
  72730. *
  72731. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72732. *
  72733. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72734. */
  72735. export class MaterialHelper {
  72736. /**
  72737. * Bind the current view position to an effect.
  72738. * @param effect The effect to be bound
  72739. * @param scene The scene the eyes position is used from
  72740. */
  72741. static BindEyePosition(effect: Effect, scene: Scene): void;
  72742. /**
  72743. * Helps preparing the defines values about the UVs in used in the effect.
  72744. * UVs are shared as much as we can accross channels in the shaders.
  72745. * @param texture The texture we are preparing the UVs for
  72746. * @param defines The defines to update
  72747. * @param key The channel key "diffuse", "specular"... used in the shader
  72748. */
  72749. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72750. /**
  72751. * Binds a texture matrix value to its corrsponding uniform
  72752. * @param texture The texture to bind the matrix for
  72753. * @param uniformBuffer The uniform buffer receivin the data
  72754. * @param key The channel key "diffuse", "specular"... used in the shader
  72755. */
  72756. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72757. /**
  72758. * Gets the current status of the fog (should it be enabled?)
  72759. * @param mesh defines the mesh to evaluate for fog support
  72760. * @param scene defines the hosting scene
  72761. * @returns true if fog must be enabled
  72762. */
  72763. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  72764. /**
  72765. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  72766. * @param mesh defines the current mesh
  72767. * @param scene defines the current scene
  72768. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  72769. * @param pointsCloud defines if point cloud rendering has to be turned on
  72770. * @param fogEnabled defines if fog has to be turned on
  72771. * @param alphaTest defines if alpha testing has to be turned on
  72772. * @param defines defines the current list of defines
  72773. */
  72774. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  72775. /**
  72776. * Helper used to prepare the list of defines associated with frame values for shader compilation
  72777. * @param scene defines the current scene
  72778. * @param engine defines the current engine
  72779. * @param defines specifies the list of active defines
  72780. * @param useInstances defines if instances have to be turned on
  72781. * @param useClipPlane defines if clip plane have to be turned on
  72782. */
  72783. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  72784. /**
  72785. * Prepares the defines for bones
  72786. * @param mesh The mesh containing the geometry data we will draw
  72787. * @param defines The defines to update
  72788. */
  72789. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72790. /**
  72791. * Prepares the defines for morph targets
  72792. * @param mesh The mesh containing the geometry data we will draw
  72793. * @param defines The defines to update
  72794. */
  72795. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72796. /**
  72797. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72798. * @param mesh The mesh containing the geometry data we will draw
  72799. * @param defines The defines to update
  72800. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72801. * @param useBones Precise whether bones should be used or not (override mesh info)
  72802. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72803. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72804. * @returns false if defines are considered not dirty and have not been checked
  72805. */
  72806. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72807. /**
  72808. * Prepares the defines related to multiview
  72809. * @param scene The scene we are intending to draw
  72810. * @param defines The defines to update
  72811. */
  72812. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72813. /**
  72814. * Prepares the defines related to the light information passed in parameter
  72815. * @param scene The scene we are intending to draw
  72816. * @param mesh The mesh the effect is compiling for
  72817. * @param light The light the effect is compiling for
  72818. * @param lightIndex The index of the light
  72819. * @param defines The defines to update
  72820. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72821. * @param state Defines the current state regarding what is needed (normals, etc...)
  72822. */
  72823. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72824. needNormals: boolean;
  72825. needRebuild: boolean;
  72826. shadowEnabled: boolean;
  72827. specularEnabled: boolean;
  72828. lightmapMode: boolean;
  72829. }): void;
  72830. /**
  72831. * Prepares the defines related to the light information passed in parameter
  72832. * @param scene The scene we are intending to draw
  72833. * @param mesh The mesh the effect is compiling for
  72834. * @param defines The defines to update
  72835. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72836. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72837. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72838. * @returns true if normals will be required for the rest of the effect
  72839. */
  72840. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72841. /**
  72842. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72843. * @param lightIndex defines the light index
  72844. * @param uniformsList The uniform list
  72845. * @param samplersList The sampler list
  72846. * @param projectedLightTexture defines if projected texture must be used
  72847. * @param uniformBuffersList defines an optional list of uniform buffers
  72848. */
  72849. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72850. /**
  72851. * Prepares the uniforms and samplers list to be used in the effect
  72852. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72853. * @param samplersList The sampler list
  72854. * @param defines The defines helping in the list generation
  72855. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72856. */
  72857. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72858. /**
  72859. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72860. * @param defines The defines to update while falling back
  72861. * @param fallbacks The authorized effect fallbacks
  72862. * @param maxSimultaneousLights The maximum number of lights allowed
  72863. * @param rank the current rank of the Effect
  72864. * @returns The newly affected rank
  72865. */
  72866. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72867. private static _TmpMorphInfluencers;
  72868. /**
  72869. * Prepares the list of attributes required for morph targets according to the effect defines.
  72870. * @param attribs The current list of supported attribs
  72871. * @param mesh The mesh to prepare the morph targets attributes for
  72872. * @param influencers The number of influencers
  72873. */
  72874. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72875. /**
  72876. * Prepares the list of attributes required for morph targets according to the effect defines.
  72877. * @param attribs The current list of supported attribs
  72878. * @param mesh The mesh to prepare the morph targets attributes for
  72879. * @param defines The current Defines of the effect
  72880. */
  72881. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72882. /**
  72883. * Prepares the list of attributes required for bones according to the effect defines.
  72884. * @param attribs The current list of supported attribs
  72885. * @param mesh The mesh to prepare the bones attributes for
  72886. * @param defines The current Defines of the effect
  72887. * @param fallbacks The current efffect fallback strategy
  72888. */
  72889. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72890. /**
  72891. * Check and prepare the list of attributes required for instances according to the effect defines.
  72892. * @param attribs The current list of supported attribs
  72893. * @param defines The current MaterialDefines of the effect
  72894. */
  72895. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72896. /**
  72897. * Add the list of attributes required for instances to the attribs array.
  72898. * @param attribs The current list of supported attribs
  72899. */
  72900. static PushAttributesForInstances(attribs: string[]): void;
  72901. /**
  72902. * Binds the light shadow information to the effect for the given mesh.
  72903. * @param light The light containing the generator
  72904. * @param scene The scene the lights belongs to
  72905. * @param mesh The mesh we are binding the information to render
  72906. * @param lightIndex The light index in the effect used to render the mesh
  72907. * @param effect The effect we are binding the data to
  72908. */
  72909. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72910. /**
  72911. * Binds the light information to the effect.
  72912. * @param light The light containing the generator
  72913. * @param effect The effect we are binding the data to
  72914. * @param lightIndex The light index in the effect used to render
  72915. */
  72916. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72917. /**
  72918. * Binds the lights information from the scene to the effect for the given mesh.
  72919. * @param light Light to bind
  72920. * @param lightIndex Light index
  72921. * @param scene The scene where the light belongs to
  72922. * @param mesh The mesh we are binding the information to render
  72923. * @param effect The effect we are binding the data to
  72924. * @param useSpecular Defines if specular is supported
  72925. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72926. */
  72927. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72928. /**
  72929. * Binds the lights information from the scene to the effect for the given mesh.
  72930. * @param scene The scene the lights belongs to
  72931. * @param mesh The mesh we are binding the information to render
  72932. * @param effect The effect we are binding the data to
  72933. * @param defines The generated defines for the effect
  72934. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72935. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72936. */
  72937. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72938. private static _tempFogColor;
  72939. /**
  72940. * Binds the fog information from the scene to the effect for the given mesh.
  72941. * @param scene The scene the lights belongs to
  72942. * @param mesh The mesh we are binding the information to render
  72943. * @param effect The effect we are binding the data to
  72944. * @param linearSpace Defines if the fog effect is applied in linear space
  72945. */
  72946. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72947. /**
  72948. * Binds the bones information from the mesh to the effect.
  72949. * @param mesh The mesh we are binding the information to render
  72950. * @param effect The effect we are binding the data to
  72951. */
  72952. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72953. /**
  72954. * Binds the morph targets information from the mesh to the effect.
  72955. * @param abstractMesh The mesh we are binding the information to render
  72956. * @param effect The effect we are binding the data to
  72957. */
  72958. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72959. /**
  72960. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72961. * @param defines The generated defines used in the effect
  72962. * @param effect The effect we are binding the data to
  72963. * @param scene The scene we are willing to render with logarithmic scale for
  72964. */
  72965. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72966. /**
  72967. * Binds the clip plane information from the scene to the effect.
  72968. * @param scene The scene the clip plane information are extracted from
  72969. * @param effect The effect we are binding the data to
  72970. */
  72971. static BindClipPlane(effect: Effect, scene: Scene): void;
  72972. }
  72973. }
  72974. declare module BABYLON {
  72975. /** @hidden */
  72976. export var packingFunctions: {
  72977. name: string;
  72978. shader: string;
  72979. };
  72980. }
  72981. declare module BABYLON {
  72982. /** @hidden */
  72983. export var shadowMapPixelShader: {
  72984. name: string;
  72985. shader: string;
  72986. };
  72987. }
  72988. declare module BABYLON {
  72989. /** @hidden */
  72990. export var bonesDeclaration: {
  72991. name: string;
  72992. shader: string;
  72993. };
  72994. }
  72995. declare module BABYLON {
  72996. /** @hidden */
  72997. export var morphTargetsVertexGlobalDeclaration: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module BABYLON {
  73003. /** @hidden */
  73004. export var morphTargetsVertexDeclaration: {
  73005. name: string;
  73006. shader: string;
  73007. };
  73008. }
  73009. declare module BABYLON {
  73010. /** @hidden */
  73011. export var instancesDeclaration: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module BABYLON {
  73017. /** @hidden */
  73018. export var helperFunctions: {
  73019. name: string;
  73020. shader: string;
  73021. };
  73022. }
  73023. declare module BABYLON {
  73024. /** @hidden */
  73025. export var morphTargetsVertex: {
  73026. name: string;
  73027. shader: string;
  73028. };
  73029. }
  73030. declare module BABYLON {
  73031. /** @hidden */
  73032. export var instancesVertex: {
  73033. name: string;
  73034. shader: string;
  73035. };
  73036. }
  73037. declare module BABYLON {
  73038. /** @hidden */
  73039. export var bonesVertex: {
  73040. name: string;
  73041. shader: string;
  73042. };
  73043. }
  73044. declare module BABYLON {
  73045. /** @hidden */
  73046. export var shadowMapVertexShader: {
  73047. name: string;
  73048. shader: string;
  73049. };
  73050. }
  73051. declare module BABYLON {
  73052. /** @hidden */
  73053. export var depthBoxBlurPixelShader: {
  73054. name: string;
  73055. shader: string;
  73056. };
  73057. }
  73058. declare module BABYLON {
  73059. /**
  73060. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73061. */
  73062. export interface ICustomShaderOptions {
  73063. /**
  73064. * Gets or sets the custom shader name to use
  73065. */
  73066. shaderName: string;
  73067. /**
  73068. * The list of attribute names used in the shader
  73069. */
  73070. attributes?: string[];
  73071. /**
  73072. * The list of unifrom names used in the shader
  73073. */
  73074. uniforms?: string[];
  73075. /**
  73076. * The list of sampler names used in the shader
  73077. */
  73078. samplers?: string[];
  73079. /**
  73080. * The list of defines used in the shader
  73081. */
  73082. defines?: string[];
  73083. }
  73084. /**
  73085. * Interface to implement to create a shadow generator compatible with BJS.
  73086. */
  73087. export interface IShadowGenerator {
  73088. /**
  73089. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73090. * @returns The render target texture if present otherwise, null
  73091. */
  73092. getShadowMap(): Nullable<RenderTargetTexture>;
  73093. /**
  73094. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73095. * @returns The render target texture if the shadow map is present otherwise, null
  73096. */
  73097. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73098. /**
  73099. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73100. * @param subMesh The submesh we want to render in the shadow map
  73101. * @param useInstances Defines wether will draw in the map using instances
  73102. * @returns true if ready otherwise, false
  73103. */
  73104. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73105. /**
  73106. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73107. * @param defines Defines of the material we want to update
  73108. * @param lightIndex Index of the light in the enabled light list of the material
  73109. */
  73110. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73111. /**
  73112. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73113. * defined in the generator but impacting the effect).
  73114. * It implies the unifroms available on the materials are the standard BJS ones.
  73115. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73116. * @param effect The effect we are binfing the information for
  73117. */
  73118. bindShadowLight(lightIndex: string, effect: Effect): void;
  73119. /**
  73120. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73121. * (eq to shadow prjection matrix * light transform matrix)
  73122. * @returns The transform matrix used to create the shadow map
  73123. */
  73124. getTransformMatrix(): Matrix;
  73125. /**
  73126. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73127. * Cube and 2D textures for instance.
  73128. */
  73129. recreateShadowMap(): void;
  73130. /**
  73131. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73132. * @param onCompiled Callback triggered at the and of the effects compilation
  73133. * @param options Sets of optional options forcing the compilation with different modes
  73134. */
  73135. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73136. useInstances: boolean;
  73137. }>): void;
  73138. /**
  73139. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73140. * @param options Sets of optional options forcing the compilation with different modes
  73141. * @returns A promise that resolves when the compilation completes
  73142. */
  73143. forceCompilationAsync(options?: Partial<{
  73144. useInstances: boolean;
  73145. }>): Promise<void>;
  73146. /**
  73147. * Serializes the shadow generator setup to a json object.
  73148. * @returns The serialized JSON object
  73149. */
  73150. serialize(): any;
  73151. /**
  73152. * Disposes the Shadow map and related Textures and effects.
  73153. */
  73154. dispose(): void;
  73155. }
  73156. /**
  73157. * Default implementation IShadowGenerator.
  73158. * This is the main object responsible of generating shadows in the framework.
  73159. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73160. */
  73161. export class ShadowGenerator implements IShadowGenerator {
  73162. /**
  73163. * Shadow generator mode None: no filtering applied.
  73164. */
  73165. static readonly FILTER_NONE: number;
  73166. /**
  73167. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73168. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73169. */
  73170. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73171. /**
  73172. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73173. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73174. */
  73175. static readonly FILTER_POISSONSAMPLING: number;
  73176. /**
  73177. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73178. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73179. */
  73180. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73181. /**
  73182. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73183. * edge artifacts on steep falloff.
  73184. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73185. */
  73186. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73187. /**
  73188. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73189. * edge artifacts on steep falloff.
  73190. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73191. */
  73192. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73193. /**
  73194. * Shadow generator mode PCF: Percentage Closer Filtering
  73195. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73196. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73197. */
  73198. static readonly FILTER_PCF: number;
  73199. /**
  73200. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73201. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73202. * Contact Hardening
  73203. */
  73204. static readonly FILTER_PCSS: number;
  73205. /**
  73206. * Reserved for PCF and PCSS
  73207. * Highest Quality.
  73208. *
  73209. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73210. *
  73211. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73212. */
  73213. static readonly QUALITY_HIGH: number;
  73214. /**
  73215. * Reserved for PCF and PCSS
  73216. * Good tradeoff for quality/perf cross devices
  73217. *
  73218. * Execute PCF on a 3*3 kernel.
  73219. *
  73220. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73221. */
  73222. static readonly QUALITY_MEDIUM: number;
  73223. /**
  73224. * Reserved for PCF and PCSS
  73225. * The lowest quality but the fastest.
  73226. *
  73227. * Execute PCF on a 1*1 kernel.
  73228. *
  73229. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73230. */
  73231. static readonly QUALITY_LOW: number;
  73232. /** Gets or sets the custom shader name to use */
  73233. customShaderOptions: ICustomShaderOptions;
  73234. /**
  73235. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73236. */
  73237. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73238. /**
  73239. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73240. */
  73241. onAfterShadowMapRenderObservable: Observable<Effect>;
  73242. /**
  73243. * Observable triggered before a mesh is rendered in the shadow map.
  73244. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73245. */
  73246. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73247. /**
  73248. * Observable triggered after a mesh is rendered in the shadow map.
  73249. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73250. */
  73251. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73252. private _bias;
  73253. /**
  73254. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73255. */
  73256. /**
  73257. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73258. */
  73259. bias: number;
  73260. private _normalBias;
  73261. /**
  73262. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73263. */
  73264. /**
  73265. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73266. */
  73267. normalBias: number;
  73268. private _blurBoxOffset;
  73269. /**
  73270. * Gets the blur box offset: offset applied during the blur pass.
  73271. * Only useful if useKernelBlur = false
  73272. */
  73273. /**
  73274. * Sets the blur box offset: offset applied during the blur pass.
  73275. * Only useful if useKernelBlur = false
  73276. */
  73277. blurBoxOffset: number;
  73278. private _blurScale;
  73279. /**
  73280. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73281. * 2 means half of the size.
  73282. */
  73283. /**
  73284. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73285. * 2 means half of the size.
  73286. */
  73287. blurScale: number;
  73288. private _blurKernel;
  73289. /**
  73290. * Gets the blur kernel: kernel size of the blur pass.
  73291. * Only useful if useKernelBlur = true
  73292. */
  73293. /**
  73294. * Sets the blur kernel: kernel size of the blur pass.
  73295. * Only useful if useKernelBlur = true
  73296. */
  73297. blurKernel: number;
  73298. private _useKernelBlur;
  73299. /**
  73300. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73301. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73302. */
  73303. /**
  73304. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73305. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73306. */
  73307. useKernelBlur: boolean;
  73308. private _depthScale;
  73309. /**
  73310. * Gets the depth scale used in ESM mode.
  73311. */
  73312. /**
  73313. * Sets the depth scale used in ESM mode.
  73314. * This can override the scale stored on the light.
  73315. */
  73316. depthScale: number;
  73317. private _filter;
  73318. /**
  73319. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73320. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73321. */
  73322. /**
  73323. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73324. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73325. */
  73326. filter: number;
  73327. /**
  73328. * Gets if the current filter is set to Poisson Sampling.
  73329. */
  73330. /**
  73331. * Sets the current filter to Poisson Sampling.
  73332. */
  73333. usePoissonSampling: boolean;
  73334. /**
  73335. * Gets if the current filter is set to ESM.
  73336. */
  73337. /**
  73338. * Sets the current filter is to ESM.
  73339. */
  73340. useExponentialShadowMap: boolean;
  73341. /**
  73342. * Gets if the current filter is set to filtered ESM.
  73343. */
  73344. /**
  73345. * Gets if the current filter is set to filtered ESM.
  73346. */
  73347. useBlurExponentialShadowMap: boolean;
  73348. /**
  73349. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73350. * exponential to prevent steep falloff artifacts).
  73351. */
  73352. /**
  73353. * Sets the current filter to "close ESM" (using the inverse of the
  73354. * exponential to prevent steep falloff artifacts).
  73355. */
  73356. useCloseExponentialShadowMap: boolean;
  73357. /**
  73358. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73359. * exponential to prevent steep falloff artifacts).
  73360. */
  73361. /**
  73362. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73363. * exponential to prevent steep falloff artifacts).
  73364. */
  73365. useBlurCloseExponentialShadowMap: boolean;
  73366. /**
  73367. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73368. */
  73369. /**
  73370. * Sets the current filter to "PCF" (percentage closer filtering).
  73371. */
  73372. usePercentageCloserFiltering: boolean;
  73373. private _filteringQuality;
  73374. /**
  73375. * Gets the PCF or PCSS Quality.
  73376. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73377. */
  73378. /**
  73379. * Sets the PCF or PCSS Quality.
  73380. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73381. */
  73382. filteringQuality: number;
  73383. /**
  73384. * Gets if the current filter is set to "PCSS" (contact hardening).
  73385. */
  73386. /**
  73387. * Sets the current filter to "PCSS" (contact hardening).
  73388. */
  73389. useContactHardeningShadow: boolean;
  73390. private _contactHardeningLightSizeUVRatio;
  73391. /**
  73392. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73393. * Using a ratio helps keeping shape stability independently of the map size.
  73394. *
  73395. * It does not account for the light projection as it was having too much
  73396. * instability during the light setup or during light position changes.
  73397. *
  73398. * Only valid if useContactHardeningShadow is true.
  73399. */
  73400. /**
  73401. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73402. * Using a ratio helps keeping shape stability independently of the map size.
  73403. *
  73404. * It does not account for the light projection as it was having too much
  73405. * instability during the light setup or during light position changes.
  73406. *
  73407. * Only valid if useContactHardeningShadow is true.
  73408. */
  73409. contactHardeningLightSizeUVRatio: number;
  73410. private _darkness;
  73411. /** Gets or sets the actual darkness of a shadow */
  73412. darkness: number;
  73413. /**
  73414. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73415. * 0 means strongest and 1 would means no shadow.
  73416. * @returns the darkness.
  73417. */
  73418. getDarkness(): number;
  73419. /**
  73420. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73421. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73422. * @returns the shadow generator allowing fluent coding.
  73423. */
  73424. setDarkness(darkness: number): ShadowGenerator;
  73425. private _transparencyShadow;
  73426. /** Gets or sets the ability to have transparent shadow */
  73427. transparencyShadow: boolean;
  73428. /**
  73429. * Sets the ability to have transparent shadow (boolean).
  73430. * @param transparent True if transparent else False
  73431. * @returns the shadow generator allowing fluent coding
  73432. */
  73433. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73434. private _shadowMap;
  73435. private _shadowMap2;
  73436. /**
  73437. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73438. * @returns The render target texture if present otherwise, null
  73439. */
  73440. getShadowMap(): Nullable<RenderTargetTexture>;
  73441. /**
  73442. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73443. * @returns The render target texture if the shadow map is present otherwise, null
  73444. */
  73445. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73446. /**
  73447. * Gets the class name of that object
  73448. * @returns "ShadowGenerator"
  73449. */
  73450. getClassName(): string;
  73451. /**
  73452. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73453. * @param mesh Mesh to add
  73454. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73455. * @returns the Shadow Generator itself
  73456. */
  73457. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73458. /**
  73459. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73460. * @param mesh Mesh to remove
  73461. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73462. * @returns the Shadow Generator itself
  73463. */
  73464. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73465. /**
  73466. * Controls the extent to which the shadows fade out at the edge of the frustum
  73467. * Used only by directionals and spots
  73468. */
  73469. frustumEdgeFalloff: number;
  73470. private _light;
  73471. /**
  73472. * Returns the associated light object.
  73473. * @returns the light generating the shadow
  73474. */
  73475. getLight(): IShadowLight;
  73476. /**
  73477. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73478. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73479. * It might on the other hand introduce peter panning.
  73480. */
  73481. forceBackFacesOnly: boolean;
  73482. private _scene;
  73483. private _lightDirection;
  73484. private _effect;
  73485. private _viewMatrix;
  73486. private _projectionMatrix;
  73487. private _transformMatrix;
  73488. private _cachedPosition;
  73489. private _cachedDirection;
  73490. private _cachedDefines;
  73491. private _currentRenderID;
  73492. private _boxBlurPostprocess;
  73493. private _kernelBlurXPostprocess;
  73494. private _kernelBlurYPostprocess;
  73495. private _blurPostProcesses;
  73496. private _mapSize;
  73497. private _currentFaceIndex;
  73498. private _currentFaceIndexCache;
  73499. private _textureType;
  73500. private _defaultTextureMatrix;
  73501. /** @hidden */
  73502. static _SceneComponentInitialization: (scene: Scene) => void;
  73503. /**
  73504. * Creates a ShadowGenerator object.
  73505. * A ShadowGenerator is the required tool to use the shadows.
  73506. * Each light casting shadows needs to use its own ShadowGenerator.
  73507. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73508. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73509. * @param light The light object generating the shadows.
  73510. * @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.
  73511. */
  73512. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73513. private _initializeGenerator;
  73514. private _initializeShadowMap;
  73515. private _initializeBlurRTTAndPostProcesses;
  73516. private _renderForShadowMap;
  73517. private _renderSubMeshForShadowMap;
  73518. private _applyFilterValues;
  73519. /**
  73520. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73521. * @param onCompiled Callback triggered at the and of the effects compilation
  73522. * @param options Sets of optional options forcing the compilation with different modes
  73523. */
  73524. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73525. useInstances: boolean;
  73526. }>): void;
  73527. /**
  73528. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73529. * @param options Sets of optional options forcing the compilation with different modes
  73530. * @returns A promise that resolves when the compilation completes
  73531. */
  73532. forceCompilationAsync(options?: Partial<{
  73533. useInstances: boolean;
  73534. }>): Promise<void>;
  73535. /**
  73536. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73537. * @param subMesh The submesh we want to render in the shadow map
  73538. * @param useInstances Defines wether will draw in the map using instances
  73539. * @returns true if ready otherwise, false
  73540. */
  73541. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73542. /**
  73543. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73544. * @param defines Defines of the material we want to update
  73545. * @param lightIndex Index of the light in the enabled light list of the material
  73546. */
  73547. prepareDefines(defines: any, lightIndex: number): void;
  73548. /**
  73549. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73550. * defined in the generator but impacting the effect).
  73551. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73552. * @param effect The effect we are binfing the information for
  73553. */
  73554. bindShadowLight(lightIndex: string, effect: Effect): void;
  73555. /**
  73556. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73557. * (eq to shadow prjection matrix * light transform matrix)
  73558. * @returns The transform matrix used to create the shadow map
  73559. */
  73560. getTransformMatrix(): Matrix;
  73561. /**
  73562. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73563. * Cube and 2D textures for instance.
  73564. */
  73565. recreateShadowMap(): void;
  73566. private _disposeBlurPostProcesses;
  73567. private _disposeRTTandPostProcesses;
  73568. /**
  73569. * Disposes the ShadowGenerator.
  73570. * Returns nothing.
  73571. */
  73572. dispose(): void;
  73573. /**
  73574. * Serializes the shadow generator setup to a json object.
  73575. * @returns The serialized JSON object
  73576. */
  73577. serialize(): any;
  73578. /**
  73579. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73580. * @param parsedShadowGenerator The JSON object to parse
  73581. * @param scene The scene to create the shadow map for
  73582. * @returns The parsed shadow generator
  73583. */
  73584. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73585. }
  73586. }
  73587. declare module BABYLON {
  73588. /**
  73589. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73590. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73591. * 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.
  73592. */
  73593. export abstract class Light extends Node {
  73594. /**
  73595. * Falloff Default: light is falling off following the material specification:
  73596. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73597. */
  73598. static readonly FALLOFF_DEFAULT: number;
  73599. /**
  73600. * Falloff Physical: light is falling off following the inverse squared distance law.
  73601. */
  73602. static readonly FALLOFF_PHYSICAL: number;
  73603. /**
  73604. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73605. * to enhance interoperability with other engines.
  73606. */
  73607. static readonly FALLOFF_GLTF: number;
  73608. /**
  73609. * Falloff Standard: light is falling off like in the standard material
  73610. * to enhance interoperability with other materials.
  73611. */
  73612. static readonly FALLOFF_STANDARD: number;
  73613. /**
  73614. * If every light affecting the material is in this lightmapMode,
  73615. * material.lightmapTexture adds or multiplies
  73616. * (depends on material.useLightmapAsShadowmap)
  73617. * after every other light calculations.
  73618. */
  73619. static readonly LIGHTMAP_DEFAULT: number;
  73620. /**
  73621. * material.lightmapTexture as only diffuse lighting from this light
  73622. * adds only specular lighting from this light
  73623. * adds dynamic shadows
  73624. */
  73625. static readonly LIGHTMAP_SPECULAR: number;
  73626. /**
  73627. * material.lightmapTexture as only lighting
  73628. * no light calculation from this light
  73629. * only adds dynamic shadows from this light
  73630. */
  73631. static readonly LIGHTMAP_SHADOWSONLY: number;
  73632. /**
  73633. * Each light type uses the default quantity according to its type:
  73634. * point/spot lights use luminous intensity
  73635. * directional lights use illuminance
  73636. */
  73637. static readonly INTENSITYMODE_AUTOMATIC: number;
  73638. /**
  73639. * lumen (lm)
  73640. */
  73641. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73642. /**
  73643. * candela (lm/sr)
  73644. */
  73645. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73646. /**
  73647. * lux (lm/m^2)
  73648. */
  73649. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73650. /**
  73651. * nit (cd/m^2)
  73652. */
  73653. static readonly INTENSITYMODE_LUMINANCE: number;
  73654. /**
  73655. * Light type const id of the point light.
  73656. */
  73657. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73658. /**
  73659. * Light type const id of the directional light.
  73660. */
  73661. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73662. /**
  73663. * Light type const id of the spot light.
  73664. */
  73665. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73666. /**
  73667. * Light type const id of the hemispheric light.
  73668. */
  73669. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73670. /**
  73671. * Diffuse gives the basic color to an object.
  73672. */
  73673. diffuse: Color3;
  73674. /**
  73675. * Specular produces a highlight color on an object.
  73676. * Note: This is note affecting PBR materials.
  73677. */
  73678. specular: Color3;
  73679. /**
  73680. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73681. * falling off base on range or angle.
  73682. * This can be set to any values in Light.FALLOFF_x.
  73683. *
  73684. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73685. * other types of materials.
  73686. */
  73687. falloffType: number;
  73688. /**
  73689. * Strength of the light.
  73690. * Note: By default it is define in the framework own unit.
  73691. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73692. */
  73693. intensity: number;
  73694. private _range;
  73695. protected _inverseSquaredRange: number;
  73696. /**
  73697. * Defines how far from the source the light is impacting in scene units.
  73698. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73699. */
  73700. /**
  73701. * Defines how far from the source the light is impacting in scene units.
  73702. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73703. */
  73704. range: number;
  73705. /**
  73706. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73707. * of light.
  73708. */
  73709. private _photometricScale;
  73710. private _intensityMode;
  73711. /**
  73712. * Gets the photometric scale used to interpret the intensity.
  73713. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73714. */
  73715. /**
  73716. * Sets the photometric scale used to interpret the intensity.
  73717. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73718. */
  73719. intensityMode: number;
  73720. private _radius;
  73721. /**
  73722. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73723. */
  73724. /**
  73725. * sets the light radius used by PBR Materials to simulate soft area lights.
  73726. */
  73727. radius: number;
  73728. private _renderPriority;
  73729. /**
  73730. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73731. * exceeding the number allowed of the materials.
  73732. */
  73733. renderPriority: number;
  73734. private _shadowEnabled;
  73735. /**
  73736. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73737. * the current shadow generator.
  73738. */
  73739. /**
  73740. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73741. * the current shadow generator.
  73742. */
  73743. shadowEnabled: boolean;
  73744. private _includedOnlyMeshes;
  73745. /**
  73746. * Gets the only meshes impacted by this light.
  73747. */
  73748. /**
  73749. * Sets the only meshes impacted by this light.
  73750. */
  73751. includedOnlyMeshes: AbstractMesh[];
  73752. private _excludedMeshes;
  73753. /**
  73754. * Gets the meshes not impacted by this light.
  73755. */
  73756. /**
  73757. * Sets the meshes not impacted by this light.
  73758. */
  73759. excludedMeshes: AbstractMesh[];
  73760. private _excludeWithLayerMask;
  73761. /**
  73762. * Gets the layer id use to find what meshes are not impacted by the light.
  73763. * Inactive if 0
  73764. */
  73765. /**
  73766. * Sets the layer id use to find what meshes are not impacted by the light.
  73767. * Inactive if 0
  73768. */
  73769. excludeWithLayerMask: number;
  73770. private _includeOnlyWithLayerMask;
  73771. /**
  73772. * Gets the layer id use to find what meshes are impacted by the light.
  73773. * Inactive if 0
  73774. */
  73775. /**
  73776. * Sets the layer id use to find what meshes are impacted by the light.
  73777. * Inactive if 0
  73778. */
  73779. includeOnlyWithLayerMask: number;
  73780. private _lightmapMode;
  73781. /**
  73782. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73783. */
  73784. /**
  73785. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73786. */
  73787. lightmapMode: number;
  73788. /**
  73789. * Shadow generator associted to the light.
  73790. * @hidden Internal use only.
  73791. */
  73792. _shadowGenerator: Nullable<IShadowGenerator>;
  73793. /**
  73794. * @hidden Internal use only.
  73795. */
  73796. _excludedMeshesIds: string[];
  73797. /**
  73798. * @hidden Internal use only.
  73799. */
  73800. _includedOnlyMeshesIds: string[];
  73801. /**
  73802. * The current light unifom buffer.
  73803. * @hidden Internal use only.
  73804. */
  73805. _uniformBuffer: UniformBuffer;
  73806. /**
  73807. * Creates a Light object in the scene.
  73808. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73809. * @param name The firendly name of the light
  73810. * @param scene The scene the light belongs too
  73811. */
  73812. constructor(name: string, scene: Scene);
  73813. protected abstract _buildUniformLayout(): void;
  73814. /**
  73815. * Sets the passed Effect "effect" with the Light information.
  73816. * @param effect The effect to update
  73817. * @param lightIndex The index of the light in the effect to update
  73818. * @returns The light
  73819. */
  73820. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73821. /**
  73822. * Returns the string "Light".
  73823. * @returns the class name
  73824. */
  73825. getClassName(): string;
  73826. /** @hidden */
  73827. readonly _isLight: boolean;
  73828. /**
  73829. * Converts the light information to a readable string for debug purpose.
  73830. * @param fullDetails Supports for multiple levels of logging within scene loading
  73831. * @returns the human readable light info
  73832. */
  73833. toString(fullDetails?: boolean): string;
  73834. /** @hidden */
  73835. protected _syncParentEnabledState(): void;
  73836. /**
  73837. * Set the enabled state of this node.
  73838. * @param value - the new enabled state
  73839. */
  73840. setEnabled(value: boolean): void;
  73841. /**
  73842. * Returns the Light associated shadow generator if any.
  73843. * @return the associated shadow generator.
  73844. */
  73845. getShadowGenerator(): Nullable<IShadowGenerator>;
  73846. /**
  73847. * Returns a Vector3, the absolute light position in the World.
  73848. * @returns the world space position of the light
  73849. */
  73850. getAbsolutePosition(): Vector3;
  73851. /**
  73852. * Specifies if the light will affect the passed mesh.
  73853. * @param mesh The mesh to test against the light
  73854. * @return true the mesh is affected otherwise, false.
  73855. */
  73856. canAffectMesh(mesh: AbstractMesh): boolean;
  73857. /**
  73858. * Sort function to order lights for rendering.
  73859. * @param a First Light object to compare to second.
  73860. * @param b Second Light object to compare first.
  73861. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73862. */
  73863. static CompareLightsPriority(a: Light, b: Light): number;
  73864. /**
  73865. * Releases resources associated with this node.
  73866. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73867. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73868. */
  73869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73870. /**
  73871. * Returns the light type ID (integer).
  73872. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73873. */
  73874. getTypeID(): number;
  73875. /**
  73876. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73877. * @returns the scaled intensity in intensity mode unit
  73878. */
  73879. getScaledIntensity(): number;
  73880. /**
  73881. * Returns a new Light object, named "name", from the current one.
  73882. * @param name The name of the cloned light
  73883. * @returns the new created light
  73884. */
  73885. clone(name: string): Nullable<Light>;
  73886. /**
  73887. * Serializes the current light into a Serialization object.
  73888. * @returns the serialized object.
  73889. */
  73890. serialize(): any;
  73891. /**
  73892. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73893. * This new light is named "name" and added to the passed scene.
  73894. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73895. * @param name The friendly name of the light
  73896. * @param scene The scene the new light will belong to
  73897. * @returns the constructor function
  73898. */
  73899. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73900. /**
  73901. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73902. * @param parsedLight The JSON representation of the light
  73903. * @param scene The scene to create the parsed light in
  73904. * @returns the created light after parsing
  73905. */
  73906. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73907. private _hookArrayForExcluded;
  73908. private _hookArrayForIncludedOnly;
  73909. private _resyncMeshes;
  73910. /**
  73911. * Forces the meshes to update their light related information in their rendering used effects
  73912. * @hidden Internal Use Only
  73913. */
  73914. _markMeshesAsLightDirty(): void;
  73915. /**
  73916. * Recomputes the cached photometric scale if needed.
  73917. */
  73918. private _computePhotometricScale;
  73919. /**
  73920. * Returns the Photometric Scale according to the light type and intensity mode.
  73921. */
  73922. private _getPhotometricScale;
  73923. /**
  73924. * Reorder the light in the scene according to their defined priority.
  73925. * @hidden Internal Use Only
  73926. */
  73927. _reorderLightsInScene(): void;
  73928. /**
  73929. * Prepares the list of defines specific to the light type.
  73930. * @param defines the list of defines
  73931. * @param lightIndex defines the index of the light for the effect
  73932. */
  73933. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73934. }
  73935. }
  73936. declare module BABYLON {
  73937. /**
  73938. * Interface used to define Action
  73939. */
  73940. export interface IAction {
  73941. /**
  73942. * Trigger for the action
  73943. */
  73944. trigger: number;
  73945. /** Options of the trigger */
  73946. triggerOptions: any;
  73947. /**
  73948. * Gets the trigger parameters
  73949. * @returns the trigger parameters
  73950. */
  73951. getTriggerParameter(): any;
  73952. /**
  73953. * Internal only - executes current action event
  73954. * @hidden
  73955. */
  73956. _executeCurrent(evt?: ActionEvent): void;
  73957. /**
  73958. * Serialize placeholder for child classes
  73959. * @param parent of child
  73960. * @returns the serialized object
  73961. */
  73962. serialize(parent: any): any;
  73963. /**
  73964. * Internal only
  73965. * @hidden
  73966. */
  73967. _prepare(): void;
  73968. /**
  73969. * Internal only - manager for action
  73970. * @hidden
  73971. */
  73972. _actionManager: AbstractActionManager;
  73973. /**
  73974. * Adds action to chain of actions, may be a DoNothingAction
  73975. * @param action defines the next action to execute
  73976. * @returns The action passed in
  73977. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73978. */
  73979. then(action: IAction): IAction;
  73980. }
  73981. /**
  73982. * The action to be carried out following a trigger
  73983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73984. */
  73985. export class Action implements IAction {
  73986. /** the trigger, with or without parameters, for the action */
  73987. triggerOptions: any;
  73988. /**
  73989. * Trigger for the action
  73990. */
  73991. trigger: number;
  73992. /**
  73993. * Internal only - manager for action
  73994. * @hidden
  73995. */
  73996. _actionManager: ActionManager;
  73997. private _nextActiveAction;
  73998. private _child;
  73999. private _condition?;
  74000. private _triggerParameter;
  74001. /**
  74002. * An event triggered prior to action being executed.
  74003. */
  74004. onBeforeExecuteObservable: Observable<Action>;
  74005. /**
  74006. * Creates a new Action
  74007. * @param triggerOptions the trigger, with or without parameters, for the action
  74008. * @param condition an optional determinant of action
  74009. */
  74010. constructor(
  74011. /** the trigger, with or without parameters, for the action */
  74012. triggerOptions: any, condition?: Condition);
  74013. /**
  74014. * Internal only
  74015. * @hidden
  74016. */
  74017. _prepare(): void;
  74018. /**
  74019. * Gets the trigger parameters
  74020. * @returns the trigger parameters
  74021. */
  74022. getTriggerParameter(): any;
  74023. /**
  74024. * Internal only - executes current action event
  74025. * @hidden
  74026. */
  74027. _executeCurrent(evt?: ActionEvent): void;
  74028. /**
  74029. * Execute placeholder for child classes
  74030. * @param evt optional action event
  74031. */
  74032. execute(evt?: ActionEvent): void;
  74033. /**
  74034. * Skips to next active action
  74035. */
  74036. skipToNextActiveAction(): void;
  74037. /**
  74038. * Adds action to chain of actions, may be a DoNothingAction
  74039. * @param action defines the next action to execute
  74040. * @returns The action passed in
  74041. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74042. */
  74043. then(action: Action): Action;
  74044. /**
  74045. * Internal only
  74046. * @hidden
  74047. */
  74048. _getProperty(propertyPath: string): string;
  74049. /**
  74050. * Internal only
  74051. * @hidden
  74052. */
  74053. _getEffectiveTarget(target: any, propertyPath: string): any;
  74054. /**
  74055. * Serialize placeholder for child classes
  74056. * @param parent of child
  74057. * @returns the serialized object
  74058. */
  74059. serialize(parent: any): any;
  74060. /**
  74061. * Internal only called by serialize
  74062. * @hidden
  74063. */
  74064. protected _serialize(serializedAction: any, parent?: any): any;
  74065. /**
  74066. * Internal only
  74067. * @hidden
  74068. */
  74069. static _SerializeValueAsString: (value: any) => string;
  74070. /**
  74071. * Internal only
  74072. * @hidden
  74073. */
  74074. static _GetTargetProperty: (target: Node | Scene) => {
  74075. name: string;
  74076. targetType: string;
  74077. value: string;
  74078. };
  74079. }
  74080. }
  74081. declare module BABYLON {
  74082. /**
  74083. * A Condition applied to an Action
  74084. */
  74085. export class Condition {
  74086. /**
  74087. * Internal only - manager for action
  74088. * @hidden
  74089. */
  74090. _actionManager: ActionManager;
  74091. /**
  74092. * Internal only
  74093. * @hidden
  74094. */
  74095. _evaluationId: number;
  74096. /**
  74097. * Internal only
  74098. * @hidden
  74099. */
  74100. _currentResult: boolean;
  74101. /**
  74102. * Creates a new Condition
  74103. * @param actionManager the manager of the action the condition is applied to
  74104. */
  74105. constructor(actionManager: ActionManager);
  74106. /**
  74107. * Check if the current condition is valid
  74108. * @returns a boolean
  74109. */
  74110. isValid(): boolean;
  74111. /**
  74112. * Internal only
  74113. * @hidden
  74114. */
  74115. _getProperty(propertyPath: string): string;
  74116. /**
  74117. * Internal only
  74118. * @hidden
  74119. */
  74120. _getEffectiveTarget(target: any, propertyPath: string): any;
  74121. /**
  74122. * Serialize placeholder for child classes
  74123. * @returns the serialized object
  74124. */
  74125. serialize(): any;
  74126. /**
  74127. * Internal only
  74128. * @hidden
  74129. */
  74130. protected _serialize(serializedCondition: any): any;
  74131. }
  74132. /**
  74133. * Defines specific conditional operators as extensions of Condition
  74134. */
  74135. export class ValueCondition extends Condition {
  74136. /** path to specify the property of the target the conditional operator uses */
  74137. propertyPath: string;
  74138. /** the value compared by the conditional operator against the current value of the property */
  74139. value: any;
  74140. /** the conditional operator, default ValueCondition.IsEqual */
  74141. operator: number;
  74142. /**
  74143. * Internal only
  74144. * @hidden
  74145. */
  74146. private static _IsEqual;
  74147. /**
  74148. * Internal only
  74149. * @hidden
  74150. */
  74151. private static _IsDifferent;
  74152. /**
  74153. * Internal only
  74154. * @hidden
  74155. */
  74156. private static _IsGreater;
  74157. /**
  74158. * Internal only
  74159. * @hidden
  74160. */
  74161. private static _IsLesser;
  74162. /**
  74163. * returns the number for IsEqual
  74164. */
  74165. static readonly IsEqual: number;
  74166. /**
  74167. * Returns the number for IsDifferent
  74168. */
  74169. static readonly IsDifferent: number;
  74170. /**
  74171. * Returns the number for IsGreater
  74172. */
  74173. static readonly IsGreater: number;
  74174. /**
  74175. * Returns the number for IsLesser
  74176. */
  74177. static readonly IsLesser: number;
  74178. /**
  74179. * Internal only The action manager for the condition
  74180. * @hidden
  74181. */
  74182. _actionManager: ActionManager;
  74183. /**
  74184. * Internal only
  74185. * @hidden
  74186. */
  74187. private _target;
  74188. /**
  74189. * Internal only
  74190. * @hidden
  74191. */
  74192. private _effectiveTarget;
  74193. /**
  74194. * Internal only
  74195. * @hidden
  74196. */
  74197. private _property;
  74198. /**
  74199. * Creates a new ValueCondition
  74200. * @param actionManager manager for the action the condition applies to
  74201. * @param target for the action
  74202. * @param propertyPath path to specify the property of the target the conditional operator uses
  74203. * @param value the value compared by the conditional operator against the current value of the property
  74204. * @param operator the conditional operator, default ValueCondition.IsEqual
  74205. */
  74206. constructor(actionManager: ActionManager, target: any,
  74207. /** path to specify the property of the target the conditional operator uses */
  74208. propertyPath: string,
  74209. /** the value compared by the conditional operator against the current value of the property */
  74210. value: any,
  74211. /** the conditional operator, default ValueCondition.IsEqual */
  74212. operator?: number);
  74213. /**
  74214. * Compares the given value with the property value for the specified conditional operator
  74215. * @returns the result of the comparison
  74216. */
  74217. isValid(): boolean;
  74218. /**
  74219. * Serialize the ValueCondition into a JSON compatible object
  74220. * @returns serialization object
  74221. */
  74222. serialize(): any;
  74223. /**
  74224. * Gets the name of the conditional operator for the ValueCondition
  74225. * @param operator the conditional operator
  74226. * @returns the name
  74227. */
  74228. static GetOperatorName(operator: number): string;
  74229. }
  74230. /**
  74231. * Defines a predicate condition as an extension of Condition
  74232. */
  74233. export class PredicateCondition extends Condition {
  74234. /** defines the predicate function used to validate the condition */
  74235. predicate: () => boolean;
  74236. /**
  74237. * Internal only - manager for action
  74238. * @hidden
  74239. */
  74240. _actionManager: ActionManager;
  74241. /**
  74242. * Creates a new PredicateCondition
  74243. * @param actionManager manager for the action the condition applies to
  74244. * @param predicate defines the predicate function used to validate the condition
  74245. */
  74246. constructor(actionManager: ActionManager,
  74247. /** defines the predicate function used to validate the condition */
  74248. predicate: () => boolean);
  74249. /**
  74250. * @returns the validity of the predicate condition
  74251. */
  74252. isValid(): boolean;
  74253. }
  74254. /**
  74255. * Defines a state condition as an extension of Condition
  74256. */
  74257. export class StateCondition extends Condition {
  74258. /** Value to compare with target state */
  74259. value: string;
  74260. /**
  74261. * Internal only - manager for action
  74262. * @hidden
  74263. */
  74264. _actionManager: ActionManager;
  74265. /**
  74266. * Internal only
  74267. * @hidden
  74268. */
  74269. private _target;
  74270. /**
  74271. * Creates a new StateCondition
  74272. * @param actionManager manager for the action the condition applies to
  74273. * @param target of the condition
  74274. * @param value to compare with target state
  74275. */
  74276. constructor(actionManager: ActionManager, target: any,
  74277. /** Value to compare with target state */
  74278. value: string);
  74279. /**
  74280. * Gets a boolean indicating if the current condition is met
  74281. * @returns the validity of the state
  74282. */
  74283. isValid(): boolean;
  74284. /**
  74285. * Serialize the StateCondition into a JSON compatible object
  74286. * @returns serialization object
  74287. */
  74288. serialize(): any;
  74289. }
  74290. }
  74291. declare module BABYLON {
  74292. /**
  74293. * This defines an action responsible to toggle a boolean once triggered.
  74294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74295. */
  74296. export class SwitchBooleanAction extends Action {
  74297. /**
  74298. * The path to the boolean property in the target object
  74299. */
  74300. propertyPath: string;
  74301. private _target;
  74302. private _effectiveTarget;
  74303. private _property;
  74304. /**
  74305. * Instantiate the action
  74306. * @param triggerOptions defines the trigger options
  74307. * @param target defines the object containing the boolean
  74308. * @param propertyPath defines the path to the boolean property in the target object
  74309. * @param condition defines the trigger related conditions
  74310. */
  74311. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74312. /** @hidden */
  74313. _prepare(): void;
  74314. /**
  74315. * Execute the action toggle the boolean value.
  74316. */
  74317. execute(): void;
  74318. /**
  74319. * Serializes the actions and its related information.
  74320. * @param parent defines the object to serialize in
  74321. * @returns the serialized object
  74322. */
  74323. serialize(parent: any): any;
  74324. }
  74325. /**
  74326. * This defines an action responsible to set a the state field of the target
  74327. * to a desired value once triggered.
  74328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74329. */
  74330. export class SetStateAction extends Action {
  74331. /**
  74332. * The value to store in the state field.
  74333. */
  74334. value: string;
  74335. private _target;
  74336. /**
  74337. * Instantiate the action
  74338. * @param triggerOptions defines the trigger options
  74339. * @param target defines the object containing the state property
  74340. * @param value defines the value to store in the state field
  74341. * @param condition defines the trigger related conditions
  74342. */
  74343. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74344. /**
  74345. * Execute the action and store the value on the target state property.
  74346. */
  74347. execute(): void;
  74348. /**
  74349. * Serializes the actions and its related information.
  74350. * @param parent defines the object to serialize in
  74351. * @returns the serialized object
  74352. */
  74353. serialize(parent: any): any;
  74354. }
  74355. /**
  74356. * This defines an action responsible to set a property of the target
  74357. * to a desired value once triggered.
  74358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74359. */
  74360. export class SetValueAction extends Action {
  74361. /**
  74362. * The path of the property to set in the target.
  74363. */
  74364. propertyPath: string;
  74365. /**
  74366. * The value to set in the property
  74367. */
  74368. value: any;
  74369. private _target;
  74370. private _effectiveTarget;
  74371. private _property;
  74372. /**
  74373. * Instantiate the action
  74374. * @param triggerOptions defines the trigger options
  74375. * @param target defines the object containing the property
  74376. * @param propertyPath defines the path of the property to set in the target
  74377. * @param value defines the value to set in the property
  74378. * @param condition defines the trigger related conditions
  74379. */
  74380. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74381. /** @hidden */
  74382. _prepare(): void;
  74383. /**
  74384. * Execute the action and set the targetted property to the desired value.
  74385. */
  74386. execute(): void;
  74387. /**
  74388. * Serializes the actions and its related information.
  74389. * @param parent defines the object to serialize in
  74390. * @returns the serialized object
  74391. */
  74392. serialize(parent: any): any;
  74393. }
  74394. /**
  74395. * This defines an action responsible to increment the target value
  74396. * to a desired value once triggered.
  74397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74398. */
  74399. export class IncrementValueAction extends Action {
  74400. /**
  74401. * The path of the property to increment in the target.
  74402. */
  74403. propertyPath: string;
  74404. /**
  74405. * The value we should increment the property by.
  74406. */
  74407. value: any;
  74408. private _target;
  74409. private _effectiveTarget;
  74410. private _property;
  74411. /**
  74412. * Instantiate the action
  74413. * @param triggerOptions defines the trigger options
  74414. * @param target defines the object containing the property
  74415. * @param propertyPath defines the path of the property to increment in the target
  74416. * @param value defines the value value we should increment the property by
  74417. * @param condition defines the trigger related conditions
  74418. */
  74419. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74420. /** @hidden */
  74421. _prepare(): void;
  74422. /**
  74423. * Execute the action and increment the target of the value amount.
  74424. */
  74425. execute(): void;
  74426. /**
  74427. * Serializes the actions and its related information.
  74428. * @param parent defines the object to serialize in
  74429. * @returns the serialized object
  74430. */
  74431. serialize(parent: any): any;
  74432. }
  74433. /**
  74434. * This defines an action responsible to start an animation once triggered.
  74435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74436. */
  74437. export class PlayAnimationAction extends Action {
  74438. /**
  74439. * Where the animation should start (animation frame)
  74440. */
  74441. from: number;
  74442. /**
  74443. * Where the animation should stop (animation frame)
  74444. */
  74445. to: number;
  74446. /**
  74447. * Define if the animation should loop or stop after the first play.
  74448. */
  74449. loop?: boolean;
  74450. private _target;
  74451. /**
  74452. * Instantiate the action
  74453. * @param triggerOptions defines the trigger options
  74454. * @param target defines the target animation or animation name
  74455. * @param from defines from where the animation should start (animation frame)
  74456. * @param end defines where the animation should stop (animation frame)
  74457. * @param loop defines if the animation should loop or stop after the first play
  74458. * @param condition defines the trigger related conditions
  74459. */
  74460. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74461. /** @hidden */
  74462. _prepare(): void;
  74463. /**
  74464. * Execute the action and play the animation.
  74465. */
  74466. execute(): void;
  74467. /**
  74468. * Serializes the actions and its related information.
  74469. * @param parent defines the object to serialize in
  74470. * @returns the serialized object
  74471. */
  74472. serialize(parent: any): any;
  74473. }
  74474. /**
  74475. * This defines an action responsible to stop an animation once triggered.
  74476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74477. */
  74478. export class StopAnimationAction extends Action {
  74479. private _target;
  74480. /**
  74481. * Instantiate the action
  74482. * @param triggerOptions defines the trigger options
  74483. * @param target defines the target animation or animation name
  74484. * @param condition defines the trigger related conditions
  74485. */
  74486. constructor(triggerOptions: any, target: any, condition?: Condition);
  74487. /** @hidden */
  74488. _prepare(): void;
  74489. /**
  74490. * Execute the action and stop the animation.
  74491. */
  74492. execute(): void;
  74493. /**
  74494. * Serializes the actions and its related information.
  74495. * @param parent defines the object to serialize in
  74496. * @returns the serialized object
  74497. */
  74498. serialize(parent: any): any;
  74499. }
  74500. /**
  74501. * This defines an action responsible that does nothing once triggered.
  74502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74503. */
  74504. export class DoNothingAction extends Action {
  74505. /**
  74506. * Instantiate the action
  74507. * @param triggerOptions defines the trigger options
  74508. * @param condition defines the trigger related conditions
  74509. */
  74510. constructor(triggerOptions?: any, condition?: Condition);
  74511. /**
  74512. * Execute the action and do nothing.
  74513. */
  74514. execute(): void;
  74515. /**
  74516. * Serializes the actions and its related information.
  74517. * @param parent defines the object to serialize in
  74518. * @returns the serialized object
  74519. */
  74520. serialize(parent: any): any;
  74521. }
  74522. /**
  74523. * This defines an action responsible to trigger several actions once triggered.
  74524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74525. */
  74526. export class CombineAction extends Action {
  74527. /**
  74528. * The list of aggregated animations to run.
  74529. */
  74530. children: Action[];
  74531. /**
  74532. * Instantiate the action
  74533. * @param triggerOptions defines the trigger options
  74534. * @param children defines the list of aggregated animations to run
  74535. * @param condition defines the trigger related conditions
  74536. */
  74537. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74538. /** @hidden */
  74539. _prepare(): void;
  74540. /**
  74541. * Execute the action and executes all the aggregated actions.
  74542. */
  74543. execute(evt: ActionEvent): void;
  74544. /**
  74545. * Serializes the actions and its related information.
  74546. * @param parent defines the object to serialize in
  74547. * @returns the serialized object
  74548. */
  74549. serialize(parent: any): any;
  74550. }
  74551. /**
  74552. * This defines an action responsible to run code (external event) once triggered.
  74553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74554. */
  74555. export class ExecuteCodeAction extends Action {
  74556. /**
  74557. * The callback function to run.
  74558. */
  74559. func: (evt: ActionEvent) => void;
  74560. /**
  74561. * Instantiate the action
  74562. * @param triggerOptions defines the trigger options
  74563. * @param func defines the callback function to run
  74564. * @param condition defines the trigger related conditions
  74565. */
  74566. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74567. /**
  74568. * Execute the action and run the attached code.
  74569. */
  74570. execute(evt: ActionEvent): void;
  74571. }
  74572. /**
  74573. * This defines an action responsible to set the parent property of the target once triggered.
  74574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74575. */
  74576. export class SetParentAction extends Action {
  74577. private _parent;
  74578. private _target;
  74579. /**
  74580. * Instantiate the action
  74581. * @param triggerOptions defines the trigger options
  74582. * @param target defines the target containing the parent property
  74583. * @param parent defines from where the animation should start (animation frame)
  74584. * @param condition defines the trigger related conditions
  74585. */
  74586. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74587. /** @hidden */
  74588. _prepare(): void;
  74589. /**
  74590. * Execute the action and set the parent property.
  74591. */
  74592. execute(): void;
  74593. /**
  74594. * Serializes the actions and its related information.
  74595. * @param parent defines the object to serialize in
  74596. * @returns the serialized object
  74597. */
  74598. serialize(parent: any): any;
  74599. }
  74600. }
  74601. declare module BABYLON {
  74602. /**
  74603. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74604. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74606. */
  74607. export class ActionManager extends AbstractActionManager {
  74608. /**
  74609. * Nothing
  74610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74611. */
  74612. static readonly NothingTrigger: number;
  74613. /**
  74614. * On pick
  74615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74616. */
  74617. static readonly OnPickTrigger: number;
  74618. /**
  74619. * On left pick
  74620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74621. */
  74622. static readonly OnLeftPickTrigger: number;
  74623. /**
  74624. * On right pick
  74625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74626. */
  74627. static readonly OnRightPickTrigger: number;
  74628. /**
  74629. * On center pick
  74630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74631. */
  74632. static readonly OnCenterPickTrigger: number;
  74633. /**
  74634. * On pick down
  74635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74636. */
  74637. static readonly OnPickDownTrigger: number;
  74638. /**
  74639. * On double pick
  74640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74641. */
  74642. static readonly OnDoublePickTrigger: number;
  74643. /**
  74644. * On pick up
  74645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74646. */
  74647. static readonly OnPickUpTrigger: number;
  74648. /**
  74649. * On pick out.
  74650. * This trigger will only be raised if you also declared a OnPickDown
  74651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74652. */
  74653. static readonly OnPickOutTrigger: number;
  74654. /**
  74655. * On long press
  74656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74657. */
  74658. static readonly OnLongPressTrigger: number;
  74659. /**
  74660. * On pointer over
  74661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74662. */
  74663. static readonly OnPointerOverTrigger: number;
  74664. /**
  74665. * On pointer out
  74666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74667. */
  74668. static readonly OnPointerOutTrigger: number;
  74669. /**
  74670. * On every frame
  74671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74672. */
  74673. static readonly OnEveryFrameTrigger: number;
  74674. /**
  74675. * On intersection enter
  74676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74677. */
  74678. static readonly OnIntersectionEnterTrigger: number;
  74679. /**
  74680. * On intersection exit
  74681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74682. */
  74683. static readonly OnIntersectionExitTrigger: number;
  74684. /**
  74685. * On key down
  74686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74687. */
  74688. static readonly OnKeyDownTrigger: number;
  74689. /**
  74690. * On key up
  74691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74692. */
  74693. static readonly OnKeyUpTrigger: number;
  74694. private _scene;
  74695. /**
  74696. * Creates a new action manager
  74697. * @param scene defines the hosting scene
  74698. */
  74699. constructor(scene: Scene);
  74700. /**
  74701. * Releases all associated resources
  74702. */
  74703. dispose(): void;
  74704. /**
  74705. * Gets hosting scene
  74706. * @returns the hosting scene
  74707. */
  74708. getScene(): Scene;
  74709. /**
  74710. * Does this action manager handles actions of any of the given triggers
  74711. * @param triggers defines the triggers to be tested
  74712. * @return a boolean indicating whether one (or more) of the triggers is handled
  74713. */
  74714. hasSpecificTriggers(triggers: number[]): boolean;
  74715. /**
  74716. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74717. * speed.
  74718. * @param triggerA defines the trigger to be tested
  74719. * @param triggerB defines the trigger to be tested
  74720. * @return a boolean indicating whether one (or more) of the triggers is handled
  74721. */
  74722. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74723. /**
  74724. * Does this action manager handles actions of a given trigger
  74725. * @param trigger defines the trigger to be tested
  74726. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74727. * @return whether the trigger is handled
  74728. */
  74729. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74730. /**
  74731. * Does this action manager has pointer triggers
  74732. */
  74733. readonly hasPointerTriggers: boolean;
  74734. /**
  74735. * Does this action manager has pick triggers
  74736. */
  74737. readonly hasPickTriggers: boolean;
  74738. /**
  74739. * Registers an action to this action manager
  74740. * @param action defines the action to be registered
  74741. * @return the action amended (prepared) after registration
  74742. */
  74743. registerAction(action: IAction): Nullable<IAction>;
  74744. /**
  74745. * Unregisters an action to this action manager
  74746. * @param action defines the action to be unregistered
  74747. * @return a boolean indicating whether the action has been unregistered
  74748. */
  74749. unregisterAction(action: IAction): Boolean;
  74750. /**
  74751. * Process a specific trigger
  74752. * @param trigger defines the trigger to process
  74753. * @param evt defines the event details to be processed
  74754. */
  74755. processTrigger(trigger: number, evt?: IActionEvent): void;
  74756. /** @hidden */
  74757. _getEffectiveTarget(target: any, propertyPath: string): any;
  74758. /** @hidden */
  74759. _getProperty(propertyPath: string): string;
  74760. /**
  74761. * Serialize this manager to a JSON object
  74762. * @param name defines the property name to store this manager
  74763. * @returns a JSON representation of this manager
  74764. */
  74765. serialize(name: string): any;
  74766. /**
  74767. * Creates a new ActionManager from a JSON data
  74768. * @param parsedActions defines the JSON data to read from
  74769. * @param object defines the hosting mesh
  74770. * @param scene defines the hosting scene
  74771. */
  74772. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  74773. /**
  74774. * Get a trigger name by index
  74775. * @param trigger defines the trigger index
  74776. * @returns a trigger name
  74777. */
  74778. static GetTriggerName(trigger: number): string;
  74779. }
  74780. }
  74781. declare module BABYLON {
  74782. /**
  74783. * Class representing a ray with position and direction
  74784. */
  74785. export class Ray {
  74786. /** origin point */
  74787. origin: Vector3;
  74788. /** direction */
  74789. direction: Vector3;
  74790. /** length of the ray */
  74791. length: number;
  74792. private static readonly TmpVector3;
  74793. private _tmpRay;
  74794. /**
  74795. * Creates a new ray
  74796. * @param origin origin point
  74797. * @param direction direction
  74798. * @param length length of the ray
  74799. */
  74800. constructor(
  74801. /** origin point */
  74802. origin: Vector3,
  74803. /** direction */
  74804. direction: Vector3,
  74805. /** length of the ray */
  74806. length?: number);
  74807. /**
  74808. * Checks if the ray intersects a box
  74809. * @param minimum bound of the box
  74810. * @param maximum bound of the box
  74811. * @param intersectionTreshold extra extend to be added to the box in all direction
  74812. * @returns if the box was hit
  74813. */
  74814. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74815. /**
  74816. * Checks if the ray intersects a box
  74817. * @param box the bounding box to check
  74818. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74819. * @returns if the box was hit
  74820. */
  74821. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74822. /**
  74823. * If the ray hits a sphere
  74824. * @param sphere the bounding sphere to check
  74825. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74826. * @returns true if it hits the sphere
  74827. */
  74828. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74829. /**
  74830. * If the ray hits a triange
  74831. * @param vertex0 triangle vertex
  74832. * @param vertex1 triangle vertex
  74833. * @param vertex2 triangle vertex
  74834. * @returns intersection information if hit
  74835. */
  74836. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74837. /**
  74838. * Checks if ray intersects a plane
  74839. * @param plane the plane to check
  74840. * @returns the distance away it was hit
  74841. */
  74842. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74843. /**
  74844. * Calculate the intercept of a ray on a given axis
  74845. * @param axis to check 'x' | 'y' | 'z'
  74846. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74847. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74848. */
  74849. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74850. /**
  74851. * Checks if ray intersects a mesh
  74852. * @param mesh the mesh to check
  74853. * @param fastCheck if only the bounding box should checked
  74854. * @returns picking info of the intersecton
  74855. */
  74856. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74857. /**
  74858. * Checks if ray intersects a mesh
  74859. * @param meshes the meshes to check
  74860. * @param fastCheck if only the bounding box should checked
  74861. * @param results array to store result in
  74862. * @returns Array of picking infos
  74863. */
  74864. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74865. private _comparePickingInfo;
  74866. private static smallnum;
  74867. private static rayl;
  74868. /**
  74869. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74870. * @param sega the first point of the segment to test the intersection against
  74871. * @param segb the second point of the segment to test the intersection against
  74872. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74873. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74874. */
  74875. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74876. /**
  74877. * Update the ray from viewport position
  74878. * @param x position
  74879. * @param y y position
  74880. * @param viewportWidth viewport width
  74881. * @param viewportHeight viewport height
  74882. * @param world world matrix
  74883. * @param view view matrix
  74884. * @param projection projection matrix
  74885. * @returns this ray updated
  74886. */
  74887. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74888. /**
  74889. * Creates a ray with origin and direction of 0,0,0
  74890. * @returns the new ray
  74891. */
  74892. static Zero(): Ray;
  74893. /**
  74894. * Creates a new ray from screen space and viewport
  74895. * @param x position
  74896. * @param y y position
  74897. * @param viewportWidth viewport width
  74898. * @param viewportHeight viewport height
  74899. * @param world world matrix
  74900. * @param view view matrix
  74901. * @param projection projection matrix
  74902. * @returns new ray
  74903. */
  74904. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74905. /**
  74906. * 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
  74907. * transformed to the given world matrix.
  74908. * @param origin The origin point
  74909. * @param end The end point
  74910. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74911. * @returns the new ray
  74912. */
  74913. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74914. /**
  74915. * Transforms a ray by a matrix
  74916. * @param ray ray to transform
  74917. * @param matrix matrix to apply
  74918. * @returns the resulting new ray
  74919. */
  74920. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74921. /**
  74922. * Transforms a ray by a matrix
  74923. * @param ray ray to transform
  74924. * @param matrix matrix to apply
  74925. * @param result ray to store result in
  74926. */
  74927. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74928. /**
  74929. * Unproject a ray from screen space to object space
  74930. * @param sourceX defines the screen space x coordinate to use
  74931. * @param sourceY defines the screen space y coordinate to use
  74932. * @param viewportWidth defines the current width of the viewport
  74933. * @param viewportHeight defines the current height of the viewport
  74934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74935. * @param view defines the view matrix to use
  74936. * @param projection defines the projection matrix to use
  74937. */
  74938. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74939. }
  74940. /**
  74941. * Type used to define predicate used to select faces when a mesh intersection is detected
  74942. */
  74943. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74944. interface Scene {
  74945. /** @hidden */
  74946. _tempPickingRay: Nullable<Ray>;
  74947. /** @hidden */
  74948. _cachedRayForTransform: Ray;
  74949. /** @hidden */
  74950. _pickWithRayInverseMatrix: Matrix;
  74951. /** @hidden */
  74952. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74953. /** @hidden */
  74954. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74955. }
  74956. }
  74957. declare module BABYLON {
  74958. /**
  74959. * Groups all the scene component constants in one place to ease maintenance.
  74960. * @hidden
  74961. */
  74962. export class SceneComponentConstants {
  74963. static readonly NAME_EFFECTLAYER: string;
  74964. static readonly NAME_LAYER: string;
  74965. static readonly NAME_LENSFLARESYSTEM: string;
  74966. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74967. static readonly NAME_PARTICLESYSTEM: string;
  74968. static readonly NAME_GAMEPAD: string;
  74969. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74970. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74971. static readonly NAME_DEPTHRENDERER: string;
  74972. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74973. static readonly NAME_SPRITE: string;
  74974. static readonly NAME_OUTLINERENDERER: string;
  74975. static readonly NAME_PROCEDURALTEXTURE: string;
  74976. static readonly NAME_SHADOWGENERATOR: string;
  74977. static readonly NAME_OCTREE: string;
  74978. static readonly NAME_PHYSICSENGINE: string;
  74979. static readonly NAME_AUDIO: string;
  74980. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74981. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74982. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74983. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74984. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74985. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74986. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74987. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74988. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74989. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74990. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74991. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74992. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74993. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74994. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74995. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74996. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74997. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74998. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74999. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75000. static readonly STEP_AFTERRENDER_AUDIO: number;
  75001. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75002. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75003. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75004. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75005. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75006. static readonly STEP_POINTERMOVE_SPRITE: number;
  75007. static readonly STEP_POINTERDOWN_SPRITE: number;
  75008. static readonly STEP_POINTERUP_SPRITE: number;
  75009. }
  75010. /**
  75011. * This represents a scene component.
  75012. *
  75013. * This is used to decouple the dependency the scene is having on the different workloads like
  75014. * layers, post processes...
  75015. */
  75016. export interface ISceneComponent {
  75017. /**
  75018. * The name of the component. Each component must have a unique name.
  75019. */
  75020. name: string;
  75021. /**
  75022. * The scene the component belongs to.
  75023. */
  75024. scene: Scene;
  75025. /**
  75026. * Register the component to one instance of a scene.
  75027. */
  75028. register(): void;
  75029. /**
  75030. * Rebuilds the elements related to this component in case of
  75031. * context lost for instance.
  75032. */
  75033. rebuild(): void;
  75034. /**
  75035. * Disposes the component and the associated ressources.
  75036. */
  75037. dispose(): void;
  75038. }
  75039. /**
  75040. * This represents a SERIALIZABLE scene component.
  75041. *
  75042. * This extends Scene Component to add Serialization methods on top.
  75043. */
  75044. export interface ISceneSerializableComponent extends ISceneComponent {
  75045. /**
  75046. * Adds all the elements from the container to the scene
  75047. * @param container the container holding the elements
  75048. */
  75049. addFromContainer(container: AbstractScene): void;
  75050. /**
  75051. * Removes all the elements in the container from the scene
  75052. * @param container contains the elements to remove
  75053. * @param dispose if the removed element should be disposed (default: false)
  75054. */
  75055. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75056. /**
  75057. * Serializes the component data to the specified json object
  75058. * @param serializationObject The object to serialize to
  75059. */
  75060. serialize(serializationObject: any): void;
  75061. }
  75062. /**
  75063. * Strong typing of a Mesh related stage step action
  75064. */
  75065. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75066. /**
  75067. * Strong typing of a Evaluate Sub Mesh related stage step action
  75068. */
  75069. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75070. /**
  75071. * Strong typing of a Active Mesh related stage step action
  75072. */
  75073. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75074. /**
  75075. * Strong typing of a Camera related stage step action
  75076. */
  75077. export type CameraStageAction = (camera: Camera) => void;
  75078. /**
  75079. * Strong typing of a Camera Frame buffer related stage step action
  75080. */
  75081. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75082. /**
  75083. * Strong typing of a Render Target related stage step action
  75084. */
  75085. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75086. /**
  75087. * Strong typing of a RenderingGroup related stage step action
  75088. */
  75089. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75090. /**
  75091. * Strong typing of a Mesh Render related stage step action
  75092. */
  75093. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75094. /**
  75095. * Strong typing of a simple stage step action
  75096. */
  75097. export type SimpleStageAction = () => void;
  75098. /**
  75099. * Strong typing of a render target action.
  75100. */
  75101. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75102. /**
  75103. * Strong typing of a pointer move action.
  75104. */
  75105. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75106. /**
  75107. * Strong typing of a pointer up/down action.
  75108. */
  75109. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75110. /**
  75111. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75112. * @hidden
  75113. */
  75114. export class Stage<T extends Function> extends Array<{
  75115. index: number;
  75116. component: ISceneComponent;
  75117. action: T;
  75118. }> {
  75119. /**
  75120. * Hide ctor from the rest of the world.
  75121. * @param items The items to add.
  75122. */
  75123. private constructor();
  75124. /**
  75125. * Creates a new Stage.
  75126. * @returns A new instance of a Stage
  75127. */
  75128. static Create<T extends Function>(): Stage<T>;
  75129. /**
  75130. * Registers a step in an ordered way in the targeted stage.
  75131. * @param index Defines the position to register the step in
  75132. * @param component Defines the component attached to the step
  75133. * @param action Defines the action to launch during the step
  75134. */
  75135. registerStep(index: number, component: ISceneComponent, action: T): void;
  75136. /**
  75137. * Clears all the steps from the stage.
  75138. */
  75139. clear(): void;
  75140. }
  75141. }
  75142. declare module BABYLON {
  75143. interface Scene {
  75144. /** @hidden */
  75145. _pointerOverSprite: Nullable<Sprite>;
  75146. /** @hidden */
  75147. _pickedDownSprite: Nullable<Sprite>;
  75148. /** @hidden */
  75149. _tempSpritePickingRay: Nullable<Ray>;
  75150. /**
  75151. * All of the sprite managers added to this scene
  75152. * @see http://doc.babylonjs.com/babylon101/sprites
  75153. */
  75154. spriteManagers: Array<ISpriteManager>;
  75155. /**
  75156. * An event triggered when sprites rendering is about to start
  75157. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75158. */
  75159. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75160. /**
  75161. * An event triggered when sprites rendering is done
  75162. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75163. */
  75164. onAfterSpritesRenderingObservable: Observable<Scene>;
  75165. /** @hidden */
  75166. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75167. /** Launch a ray to try to pick a sprite in the scene
  75168. * @param x position on screen
  75169. * @param y position on screen
  75170. * @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
  75171. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75172. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75173. * @returns a PickingInfo
  75174. */
  75175. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75176. /** Use the given ray to pick a sprite in the scene
  75177. * @param ray The ray (in world space) to use to pick meshes
  75178. * @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
  75179. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75180. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75181. * @returns a PickingInfo
  75182. */
  75183. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75184. /**
  75185. * Force the sprite under the pointer
  75186. * @param sprite defines the sprite to use
  75187. */
  75188. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75189. /**
  75190. * Gets the sprite under the pointer
  75191. * @returns a Sprite or null if no sprite is under the pointer
  75192. */
  75193. getPointerOverSprite(): Nullable<Sprite>;
  75194. }
  75195. /**
  75196. * Defines the sprite scene component responsible to manage sprites
  75197. * in a given scene.
  75198. */
  75199. export class SpriteSceneComponent implements ISceneComponent {
  75200. /**
  75201. * The component name helpfull to identify the component in the list of scene components.
  75202. */
  75203. readonly name: string;
  75204. /**
  75205. * The scene the component belongs to.
  75206. */
  75207. scene: Scene;
  75208. /** @hidden */
  75209. private _spritePredicate;
  75210. /**
  75211. * Creates a new instance of the component for the given scene
  75212. * @param scene Defines the scene to register the component in
  75213. */
  75214. constructor(scene: Scene);
  75215. /**
  75216. * Registers the component in a given scene
  75217. */
  75218. register(): void;
  75219. /**
  75220. * Rebuilds the elements related to this component in case of
  75221. * context lost for instance.
  75222. */
  75223. rebuild(): void;
  75224. /**
  75225. * Disposes the component and the associated ressources.
  75226. */
  75227. dispose(): void;
  75228. private _pickSpriteButKeepRay;
  75229. private _pointerMove;
  75230. private _pointerDown;
  75231. private _pointerUp;
  75232. }
  75233. }
  75234. declare module BABYLON {
  75235. /** @hidden */
  75236. export var fogFragmentDeclaration: {
  75237. name: string;
  75238. shader: string;
  75239. };
  75240. }
  75241. declare module BABYLON {
  75242. /** @hidden */
  75243. export var fogFragment: {
  75244. name: string;
  75245. shader: string;
  75246. };
  75247. }
  75248. declare module BABYLON {
  75249. /** @hidden */
  75250. export var spritesPixelShader: {
  75251. name: string;
  75252. shader: string;
  75253. };
  75254. }
  75255. declare module BABYLON {
  75256. /** @hidden */
  75257. export var fogVertexDeclaration: {
  75258. name: string;
  75259. shader: string;
  75260. };
  75261. }
  75262. declare module BABYLON {
  75263. /** @hidden */
  75264. export var spritesVertexShader: {
  75265. name: string;
  75266. shader: string;
  75267. };
  75268. }
  75269. declare module BABYLON {
  75270. /**
  75271. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75272. */
  75273. export interface ISpriteManager extends IDisposable {
  75274. /**
  75275. * Restricts the camera to viewing objects with the same layerMask.
  75276. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75277. */
  75278. layerMask: number;
  75279. /**
  75280. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75281. */
  75282. isPickable: boolean;
  75283. /**
  75284. * Specifies the rendering group id for this mesh (0 by default)
  75285. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75286. */
  75287. renderingGroupId: number;
  75288. /**
  75289. * Defines the list of sprites managed by the manager.
  75290. */
  75291. sprites: Array<Sprite>;
  75292. /**
  75293. * Tests the intersection of a sprite with a specific ray.
  75294. * @param ray The ray we are sending to test the collision
  75295. * @param camera The camera space we are sending rays in
  75296. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75297. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75298. * @returns picking info or null.
  75299. */
  75300. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75301. /**
  75302. * Renders the list of sprites on screen.
  75303. */
  75304. render(): void;
  75305. }
  75306. /**
  75307. * Class used to manage multiple sprites on the same spritesheet
  75308. * @see http://doc.babylonjs.com/babylon101/sprites
  75309. */
  75310. export class SpriteManager implements ISpriteManager {
  75311. /** defines the manager's name */
  75312. name: string;
  75313. /** Gets the list of sprites */
  75314. sprites: Sprite[];
  75315. /** Gets or sets the rendering group id (0 by default) */
  75316. renderingGroupId: number;
  75317. /** Gets or sets camera layer mask */
  75318. layerMask: number;
  75319. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75320. fogEnabled: boolean;
  75321. /** Gets or sets a boolean indicating if the sprites are pickable */
  75322. isPickable: boolean;
  75323. /** Defines the default width of a cell in the spritesheet */
  75324. cellWidth: number;
  75325. /** Defines the default height of a cell in the spritesheet */
  75326. cellHeight: number;
  75327. /**
  75328. * An event triggered when the manager is disposed.
  75329. */
  75330. onDisposeObservable: Observable<SpriteManager>;
  75331. private _onDisposeObserver;
  75332. /**
  75333. * Callback called when the manager is disposed
  75334. */
  75335. onDispose: () => void;
  75336. private _capacity;
  75337. private _spriteTexture;
  75338. private _epsilon;
  75339. private _scene;
  75340. private _vertexData;
  75341. private _buffer;
  75342. private _vertexBuffers;
  75343. private _indexBuffer;
  75344. private _effectBase;
  75345. private _effectFog;
  75346. /**
  75347. * Gets or sets the spritesheet texture
  75348. */
  75349. texture: Texture;
  75350. /**
  75351. * Creates a new sprite manager
  75352. * @param name defines the manager's name
  75353. * @param imgUrl defines the sprite sheet url
  75354. * @param capacity defines the maximum allowed number of sprites
  75355. * @param cellSize defines the size of a sprite cell
  75356. * @param scene defines the hosting scene
  75357. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75358. * @param samplingMode defines the smapling mode to use with spritesheet
  75359. */
  75360. constructor(
  75361. /** defines the manager's name */
  75362. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75363. private _appendSpriteVertex;
  75364. /**
  75365. * Intersects the sprites with a ray
  75366. * @param ray defines the ray to intersect with
  75367. * @param camera defines the current active camera
  75368. * @param predicate defines a predicate used to select candidate sprites
  75369. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75370. * @returns null if no hit or a PickingInfo
  75371. */
  75372. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75373. /**
  75374. * Render all child sprites
  75375. */
  75376. render(): void;
  75377. /**
  75378. * Release associated resources
  75379. */
  75380. dispose(): void;
  75381. }
  75382. }
  75383. declare module BABYLON {
  75384. /**
  75385. * Class used to represent a sprite
  75386. * @see http://doc.babylonjs.com/babylon101/sprites
  75387. */
  75388. export class Sprite {
  75389. /** defines the name */
  75390. name: string;
  75391. /** Gets or sets the current world position */
  75392. position: Vector3;
  75393. /** Gets or sets the main color */
  75394. color: Color4;
  75395. /** Gets or sets the width */
  75396. width: number;
  75397. /** Gets or sets the height */
  75398. height: number;
  75399. /** Gets or sets rotation angle */
  75400. angle: number;
  75401. /** Gets or sets the cell index in the sprite sheet */
  75402. cellIndex: number;
  75403. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75404. invertU: number;
  75405. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75406. invertV: number;
  75407. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75408. disposeWhenFinishedAnimating: boolean;
  75409. /** Gets the list of attached animations */
  75410. animations: Animation[];
  75411. /** Gets or sets a boolean indicating if the sprite can be picked */
  75412. isPickable: boolean;
  75413. /**
  75414. * Gets or sets the associated action manager
  75415. */
  75416. actionManager: Nullable<ActionManager>;
  75417. private _animationStarted;
  75418. private _loopAnimation;
  75419. private _fromIndex;
  75420. private _toIndex;
  75421. private _delay;
  75422. private _direction;
  75423. private _manager;
  75424. private _time;
  75425. private _onAnimationEnd;
  75426. /**
  75427. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75428. */
  75429. isVisible: boolean;
  75430. /**
  75431. * Gets or sets the sprite size
  75432. */
  75433. size: number;
  75434. /**
  75435. * Creates a new Sprite
  75436. * @param name defines the name
  75437. * @param manager defines the manager
  75438. */
  75439. constructor(
  75440. /** defines the name */
  75441. name: string, manager: ISpriteManager);
  75442. /**
  75443. * Starts an animation
  75444. * @param from defines the initial key
  75445. * @param to defines the end key
  75446. * @param loop defines if the animation must loop
  75447. * @param delay defines the start delay (in ms)
  75448. * @param onAnimationEnd defines a callback to call when animation ends
  75449. */
  75450. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75451. /** Stops current animation (if any) */
  75452. stopAnimation(): void;
  75453. /** @hidden */
  75454. _animate(deltaTime: number): void;
  75455. /** Release associated resources */
  75456. dispose(): void;
  75457. }
  75458. }
  75459. declare module BABYLON {
  75460. /**
  75461. * Information about the result of picking within a scene
  75462. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75463. */
  75464. export class PickingInfo {
  75465. /** @hidden */
  75466. _pickingUnavailable: boolean;
  75467. /**
  75468. * If the pick collided with an object
  75469. */
  75470. hit: boolean;
  75471. /**
  75472. * Distance away where the pick collided
  75473. */
  75474. distance: number;
  75475. /**
  75476. * The location of pick collision
  75477. */
  75478. pickedPoint: Nullable<Vector3>;
  75479. /**
  75480. * The mesh corresponding the the pick collision
  75481. */
  75482. pickedMesh: Nullable<AbstractMesh>;
  75483. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75484. bu: number;
  75485. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75486. bv: number;
  75487. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75488. faceId: number;
  75489. /** Id of the the submesh that was picked */
  75490. subMeshId: number;
  75491. /** If a sprite was picked, this will be the sprite the pick collided with */
  75492. pickedSprite: Nullable<Sprite>;
  75493. /**
  75494. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75495. */
  75496. originMesh: Nullable<AbstractMesh>;
  75497. /**
  75498. * The ray that was used to perform the picking.
  75499. */
  75500. ray: Nullable<Ray>;
  75501. /**
  75502. * Gets the normal correspodning to the face the pick collided with
  75503. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75504. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75505. * @returns The normal correspodning to the face the pick collided with
  75506. */
  75507. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75508. /**
  75509. * Gets the texture coordinates of where the pick occured
  75510. * @returns the vector containing the coordnates of the texture
  75511. */
  75512. getTextureCoordinates(): Nullable<Vector2>;
  75513. }
  75514. }
  75515. declare module BABYLON {
  75516. /**
  75517. * Gather the list of pointer event types as constants.
  75518. */
  75519. export class PointerEventTypes {
  75520. /**
  75521. * 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.
  75522. */
  75523. static readonly POINTERDOWN: number;
  75524. /**
  75525. * The pointerup event is fired when a pointer is no longer active.
  75526. */
  75527. static readonly POINTERUP: number;
  75528. /**
  75529. * The pointermove event is fired when a pointer changes coordinates.
  75530. */
  75531. static readonly POINTERMOVE: number;
  75532. /**
  75533. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75534. */
  75535. static readonly POINTERWHEEL: number;
  75536. /**
  75537. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75538. */
  75539. static readonly POINTERPICK: number;
  75540. /**
  75541. * The pointertap event is fired when a the object has been touched and released without drag.
  75542. */
  75543. static readonly POINTERTAP: number;
  75544. /**
  75545. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75546. */
  75547. static readonly POINTERDOUBLETAP: number;
  75548. }
  75549. /**
  75550. * Base class of pointer info types.
  75551. */
  75552. export class PointerInfoBase {
  75553. /**
  75554. * Defines the type of event (PointerEventTypes)
  75555. */
  75556. type: number;
  75557. /**
  75558. * Defines the related dom event
  75559. */
  75560. event: PointerEvent | MouseWheelEvent;
  75561. /**
  75562. * Instantiates the base class of pointers info.
  75563. * @param type Defines the type of event (PointerEventTypes)
  75564. * @param event Defines the related dom event
  75565. */
  75566. constructor(
  75567. /**
  75568. * Defines the type of event (PointerEventTypes)
  75569. */
  75570. type: number,
  75571. /**
  75572. * Defines the related dom event
  75573. */
  75574. event: PointerEvent | MouseWheelEvent);
  75575. }
  75576. /**
  75577. * This class is used to store pointer related info for the onPrePointerObservable event.
  75578. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75579. */
  75580. export class PointerInfoPre extends PointerInfoBase {
  75581. /**
  75582. * Ray from a pointer if availible (eg. 6dof controller)
  75583. */
  75584. ray: Nullable<Ray>;
  75585. /**
  75586. * Defines the local position of the pointer on the canvas.
  75587. */
  75588. localPosition: Vector2;
  75589. /**
  75590. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75591. */
  75592. skipOnPointerObservable: boolean;
  75593. /**
  75594. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75595. * @param type Defines the type of event (PointerEventTypes)
  75596. * @param event Defines the related dom event
  75597. * @param localX Defines the local x coordinates of the pointer when the event occured
  75598. * @param localY Defines the local y coordinates of the pointer when the event occured
  75599. */
  75600. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75601. }
  75602. /**
  75603. * This type contains all the data related to a pointer event in Babylon.js.
  75604. * 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.
  75605. */
  75606. export class PointerInfo extends PointerInfoBase {
  75607. /**
  75608. * Defines the picking info associated to the info (if any)\
  75609. */
  75610. pickInfo: Nullable<PickingInfo>;
  75611. /**
  75612. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75613. * @param type Defines the type of event (PointerEventTypes)
  75614. * @param event Defines the related dom event
  75615. * @param pickInfo Defines the picking info associated to the info (if any)\
  75616. */
  75617. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75618. /**
  75619. * Defines the picking info associated to the info (if any)\
  75620. */
  75621. pickInfo: Nullable<PickingInfo>);
  75622. }
  75623. /**
  75624. * Data relating to a touch event on the screen.
  75625. */
  75626. export interface PointerTouch {
  75627. /**
  75628. * X coordinate of touch.
  75629. */
  75630. x: number;
  75631. /**
  75632. * Y coordinate of touch.
  75633. */
  75634. y: number;
  75635. /**
  75636. * Id of touch. Unique for each finger.
  75637. */
  75638. pointerId: number;
  75639. /**
  75640. * Event type passed from DOM.
  75641. */
  75642. type: any;
  75643. }
  75644. }
  75645. declare module BABYLON {
  75646. /**
  75647. * Manage the mouse inputs to control the movement of a free camera.
  75648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75649. */
  75650. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75651. /**
  75652. * Define if touch is enabled in the mouse input
  75653. */
  75654. touchEnabled: boolean;
  75655. /**
  75656. * Defines the camera the input is attached to.
  75657. */
  75658. camera: FreeCamera;
  75659. /**
  75660. * Defines the buttons associated with the input to handle camera move.
  75661. */
  75662. buttons: number[];
  75663. /**
  75664. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75665. */
  75666. angularSensibility: number;
  75667. private _pointerInput;
  75668. private _onMouseMove;
  75669. private _observer;
  75670. private previousPosition;
  75671. /**
  75672. * Observable for when a pointer move event occurs containing the move offset
  75673. */
  75674. onPointerMovedObservable: Observable<{
  75675. offsetX: number;
  75676. offsetY: number;
  75677. }>;
  75678. /**
  75679. * @hidden
  75680. * If the camera should be rotated automatically based on pointer movement
  75681. */
  75682. _allowCameraRotation: boolean;
  75683. /**
  75684. * Manage the mouse inputs to control the movement of a free camera.
  75685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75686. * @param touchEnabled Defines if touch is enabled or not
  75687. */
  75688. constructor(
  75689. /**
  75690. * Define if touch is enabled in the mouse input
  75691. */
  75692. touchEnabled?: boolean);
  75693. /**
  75694. * Attach the input controls to a specific dom element to get the input from.
  75695. * @param element Defines the element the controls should be listened from
  75696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75697. */
  75698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75699. /**
  75700. * Called on JS contextmenu event.
  75701. * Override this method to provide functionality.
  75702. */
  75703. protected onContextMenu(evt: PointerEvent): void;
  75704. /**
  75705. * Detach the current controls from the specified dom element.
  75706. * @param element Defines the element to stop listening the inputs from
  75707. */
  75708. detachControl(element: Nullable<HTMLElement>): void;
  75709. /**
  75710. * Gets the class name of the current intput.
  75711. * @returns the class name
  75712. */
  75713. getClassName(): string;
  75714. /**
  75715. * Get the friendly name associated with the input class.
  75716. * @returns the input friendly name
  75717. */
  75718. getSimpleName(): string;
  75719. }
  75720. }
  75721. declare module BABYLON {
  75722. /**
  75723. * Manage the touch inputs to control the movement of a free camera.
  75724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75725. */
  75726. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75727. /**
  75728. * Defines the camera the input is attached to.
  75729. */
  75730. camera: FreeCamera;
  75731. /**
  75732. * Defines the touch sensibility for rotation.
  75733. * The higher the faster.
  75734. */
  75735. touchAngularSensibility: number;
  75736. /**
  75737. * Defines the touch sensibility for move.
  75738. * The higher the faster.
  75739. */
  75740. touchMoveSensibility: number;
  75741. private _offsetX;
  75742. private _offsetY;
  75743. private _pointerPressed;
  75744. private _pointerInput;
  75745. private _observer;
  75746. private _onLostFocus;
  75747. /**
  75748. * Attach the input controls to a specific dom element to get the input from.
  75749. * @param element Defines the element the controls should be listened from
  75750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75751. */
  75752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75753. /**
  75754. * Detach the current controls from the specified dom element.
  75755. * @param element Defines the element to stop listening the inputs from
  75756. */
  75757. detachControl(element: Nullable<HTMLElement>): void;
  75758. /**
  75759. * Update the current camera state depending on the inputs that have been used this frame.
  75760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75761. */
  75762. checkInputs(): void;
  75763. /**
  75764. * Gets the class name of the current intput.
  75765. * @returns the class name
  75766. */
  75767. getClassName(): string;
  75768. /**
  75769. * Get the friendly name associated with the input class.
  75770. * @returns the input friendly name
  75771. */
  75772. getSimpleName(): string;
  75773. }
  75774. }
  75775. declare module BABYLON {
  75776. /**
  75777. * Default Inputs manager for the FreeCamera.
  75778. * It groups all the default supported inputs for ease of use.
  75779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75780. */
  75781. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  75782. /**
  75783. * @hidden
  75784. */
  75785. _mouseInput: Nullable<FreeCameraMouseInput>;
  75786. /**
  75787. * Instantiates a new FreeCameraInputsManager.
  75788. * @param camera Defines the camera the inputs belong to
  75789. */
  75790. constructor(camera: FreeCamera);
  75791. /**
  75792. * Add keyboard input support to the input manager.
  75793. * @returns the current input manager
  75794. */
  75795. addKeyboard(): FreeCameraInputsManager;
  75796. /**
  75797. * Add mouse input support to the input manager.
  75798. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75799. * @returns the current input manager
  75800. */
  75801. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75802. /**
  75803. * Removes the mouse input support from the manager
  75804. * @returns the current input manager
  75805. */
  75806. removeMouse(): FreeCameraInputsManager;
  75807. /**
  75808. * Add touch input support to the input manager.
  75809. * @returns the current input manager
  75810. */
  75811. addTouch(): FreeCameraInputsManager;
  75812. /**
  75813. * Remove all attached input methods from a camera
  75814. */
  75815. clear(): void;
  75816. }
  75817. }
  75818. declare module BABYLON {
  75819. /**
  75820. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75821. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75822. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75823. */
  75824. export class FreeCamera extends TargetCamera {
  75825. /**
  75826. * Define the collision ellipsoid of the camera.
  75827. * This is helpful to simulate a camera body like the player body around the camera
  75828. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75829. */
  75830. ellipsoid: Vector3;
  75831. /**
  75832. * Define an offset for the position of the ellipsoid around the camera.
  75833. * This can be helpful to determine the center of the body near the gravity center of the body
  75834. * instead of its head.
  75835. */
  75836. ellipsoidOffset: Vector3;
  75837. /**
  75838. * Enable or disable collisions of the camera with the rest of the scene objects.
  75839. */
  75840. checkCollisions: boolean;
  75841. /**
  75842. * Enable or disable gravity on the camera.
  75843. */
  75844. applyGravity: boolean;
  75845. /**
  75846. * Define the input manager associated to the camera.
  75847. */
  75848. inputs: FreeCameraInputsManager;
  75849. /**
  75850. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75851. * Higher values reduce sensitivity.
  75852. */
  75853. /**
  75854. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75855. * Higher values reduce sensitivity.
  75856. */
  75857. angularSensibility: number;
  75858. /**
  75859. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75860. */
  75861. keysUp: number[];
  75862. /**
  75863. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75864. */
  75865. keysDown: number[];
  75866. /**
  75867. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75868. */
  75869. keysLeft: number[];
  75870. /**
  75871. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75872. */
  75873. keysRight: number[];
  75874. /**
  75875. * Event raised when the camera collide with a mesh in the scene.
  75876. */
  75877. onCollide: (collidedMesh: AbstractMesh) => void;
  75878. private _collider;
  75879. private _needMoveForGravity;
  75880. private _oldPosition;
  75881. private _diffPosition;
  75882. private _newPosition;
  75883. /** @hidden */
  75884. _localDirection: Vector3;
  75885. /** @hidden */
  75886. _transformedDirection: Vector3;
  75887. /**
  75888. * Instantiates a Free Camera.
  75889. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75890. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75891. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75892. * @param name Define the name of the camera in the scene
  75893. * @param position Define the start position of the camera in the scene
  75894. * @param scene Define the scene the camera belongs to
  75895. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75896. */
  75897. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75898. /**
  75899. * Attached controls to the current camera.
  75900. * @param element Defines the element the controls should be listened from
  75901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75902. */
  75903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75904. /**
  75905. * Detach the current controls from the camera.
  75906. * The camera will stop reacting to inputs.
  75907. * @param element Defines the element to stop listening the inputs from
  75908. */
  75909. detachControl(element: HTMLElement): void;
  75910. private _collisionMask;
  75911. /**
  75912. * Define a collision mask to limit the list of object the camera can collide with
  75913. */
  75914. collisionMask: number;
  75915. /** @hidden */
  75916. _collideWithWorld(displacement: Vector3): void;
  75917. private _onCollisionPositionChange;
  75918. /** @hidden */
  75919. _checkInputs(): void;
  75920. /** @hidden */
  75921. _decideIfNeedsToMove(): boolean;
  75922. /** @hidden */
  75923. _updatePosition(): void;
  75924. /**
  75925. * Destroy the camera and release the current resources hold by it.
  75926. */
  75927. dispose(): void;
  75928. /**
  75929. * Gets the current object class name.
  75930. * @return the class name
  75931. */
  75932. getClassName(): string;
  75933. }
  75934. }
  75935. declare module BABYLON {
  75936. /**
  75937. * Represents a gamepad control stick position
  75938. */
  75939. export class StickValues {
  75940. /**
  75941. * The x component of the control stick
  75942. */
  75943. x: number;
  75944. /**
  75945. * The y component of the control stick
  75946. */
  75947. y: number;
  75948. /**
  75949. * Initializes the gamepad x and y control stick values
  75950. * @param x The x component of the gamepad control stick value
  75951. * @param y The y component of the gamepad control stick value
  75952. */
  75953. constructor(
  75954. /**
  75955. * The x component of the control stick
  75956. */
  75957. x: number,
  75958. /**
  75959. * The y component of the control stick
  75960. */
  75961. y: number);
  75962. }
  75963. /**
  75964. * An interface which manages callbacks for gamepad button changes
  75965. */
  75966. export interface GamepadButtonChanges {
  75967. /**
  75968. * Called when a gamepad has been changed
  75969. */
  75970. changed: boolean;
  75971. /**
  75972. * Called when a gamepad press event has been triggered
  75973. */
  75974. pressChanged: boolean;
  75975. /**
  75976. * Called when a touch event has been triggered
  75977. */
  75978. touchChanged: boolean;
  75979. /**
  75980. * Called when a value has changed
  75981. */
  75982. valueChanged: boolean;
  75983. }
  75984. /**
  75985. * Represents a gamepad
  75986. */
  75987. export class Gamepad {
  75988. /**
  75989. * The id of the gamepad
  75990. */
  75991. id: string;
  75992. /**
  75993. * The index of the gamepad
  75994. */
  75995. index: number;
  75996. /**
  75997. * The browser gamepad
  75998. */
  75999. browserGamepad: any;
  76000. /**
  76001. * Specifies what type of gamepad this represents
  76002. */
  76003. type: number;
  76004. private _leftStick;
  76005. private _rightStick;
  76006. /** @hidden */
  76007. _isConnected: boolean;
  76008. private _leftStickAxisX;
  76009. private _leftStickAxisY;
  76010. private _rightStickAxisX;
  76011. private _rightStickAxisY;
  76012. /**
  76013. * Triggered when the left control stick has been changed
  76014. */
  76015. private _onleftstickchanged;
  76016. /**
  76017. * Triggered when the right control stick has been changed
  76018. */
  76019. private _onrightstickchanged;
  76020. /**
  76021. * Represents a gamepad controller
  76022. */
  76023. static GAMEPAD: number;
  76024. /**
  76025. * Represents a generic controller
  76026. */
  76027. static GENERIC: number;
  76028. /**
  76029. * Represents an XBox controller
  76030. */
  76031. static XBOX: number;
  76032. /**
  76033. * Represents a pose-enabled controller
  76034. */
  76035. static POSE_ENABLED: number;
  76036. /**
  76037. * Specifies whether the left control stick should be Y-inverted
  76038. */
  76039. protected _invertLeftStickY: boolean;
  76040. /**
  76041. * Specifies if the gamepad has been connected
  76042. */
  76043. readonly isConnected: boolean;
  76044. /**
  76045. * Initializes the gamepad
  76046. * @param id The id of the gamepad
  76047. * @param index The index of the gamepad
  76048. * @param browserGamepad The browser gamepad
  76049. * @param leftStickX The x component of the left joystick
  76050. * @param leftStickY The y component of the left joystick
  76051. * @param rightStickX The x component of the right joystick
  76052. * @param rightStickY The y component of the right joystick
  76053. */
  76054. constructor(
  76055. /**
  76056. * The id of the gamepad
  76057. */
  76058. id: string,
  76059. /**
  76060. * The index of the gamepad
  76061. */
  76062. index: number,
  76063. /**
  76064. * The browser gamepad
  76065. */
  76066. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76067. /**
  76068. * Callback triggered when the left joystick has changed
  76069. * @param callback
  76070. */
  76071. onleftstickchanged(callback: (values: StickValues) => void): void;
  76072. /**
  76073. * Callback triggered when the right joystick has changed
  76074. * @param callback
  76075. */
  76076. onrightstickchanged(callback: (values: StickValues) => void): void;
  76077. /**
  76078. * Gets the left joystick
  76079. */
  76080. /**
  76081. * Sets the left joystick values
  76082. */
  76083. leftStick: StickValues;
  76084. /**
  76085. * Gets the right joystick
  76086. */
  76087. /**
  76088. * Sets the right joystick value
  76089. */
  76090. rightStick: StickValues;
  76091. /**
  76092. * Updates the gamepad joystick positions
  76093. */
  76094. update(): void;
  76095. /**
  76096. * Disposes the gamepad
  76097. */
  76098. dispose(): void;
  76099. }
  76100. /**
  76101. * Represents a generic gamepad
  76102. */
  76103. export class GenericPad extends Gamepad {
  76104. private _buttons;
  76105. private _onbuttondown;
  76106. private _onbuttonup;
  76107. /**
  76108. * Observable triggered when a button has been pressed
  76109. */
  76110. onButtonDownObservable: Observable<number>;
  76111. /**
  76112. * Observable triggered when a button has been released
  76113. */
  76114. onButtonUpObservable: Observable<number>;
  76115. /**
  76116. * Callback triggered when a button has been pressed
  76117. * @param callback Called when a button has been pressed
  76118. */
  76119. onbuttondown(callback: (buttonPressed: number) => void): void;
  76120. /**
  76121. * Callback triggered when a button has been released
  76122. * @param callback Called when a button has been released
  76123. */
  76124. onbuttonup(callback: (buttonReleased: number) => void): void;
  76125. /**
  76126. * Initializes the generic gamepad
  76127. * @param id The id of the generic gamepad
  76128. * @param index The index of the generic gamepad
  76129. * @param browserGamepad The browser gamepad
  76130. */
  76131. constructor(id: string, index: number, browserGamepad: any);
  76132. private _setButtonValue;
  76133. /**
  76134. * Updates the generic gamepad
  76135. */
  76136. update(): void;
  76137. /**
  76138. * Disposes the generic gamepad
  76139. */
  76140. dispose(): void;
  76141. }
  76142. }
  76143. declare module BABYLON {
  76144. interface Engine {
  76145. /**
  76146. * Creates a raw texture
  76147. * @param data defines the data to store in the texture
  76148. * @param width defines the width of the texture
  76149. * @param height defines the height of the texture
  76150. * @param format defines the format of the data
  76151. * @param generateMipMaps defines if the engine should generate the mip levels
  76152. * @param invertY defines if data must be stored with Y axis inverted
  76153. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76154. * @param compression defines the compression used (null by default)
  76155. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76156. * @returns the raw texture inside an InternalTexture
  76157. */
  76158. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76159. /**
  76160. * Update a raw texture
  76161. * @param texture defines the texture to update
  76162. * @param data defines the data to store in the texture
  76163. * @param format defines the format of the data
  76164. * @param invertY defines if data must be stored with Y axis inverted
  76165. */
  76166. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76167. /**
  76168. * Update a raw texture
  76169. * @param texture defines the texture to update
  76170. * @param data defines the data to store in the texture
  76171. * @param format defines the format of the data
  76172. * @param invertY defines if data must be stored with Y axis inverted
  76173. * @param compression defines the compression used (null by default)
  76174. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76175. */
  76176. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76177. /**
  76178. * Creates a new raw cube texture
  76179. * @param data defines the array of data to use to create each face
  76180. * @param size defines the size of the textures
  76181. * @param format defines the format of the data
  76182. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76183. * @param generateMipMaps defines if the engine should generate the mip levels
  76184. * @param invertY defines if data must be stored with Y axis inverted
  76185. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76186. * @param compression defines the compression used (null by default)
  76187. * @returns the cube texture as an InternalTexture
  76188. */
  76189. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76190. /**
  76191. * Update a raw cube texture
  76192. * @param texture defines the texture to udpdate
  76193. * @param data defines the data to store
  76194. * @param format defines the data format
  76195. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76196. * @param invertY defines if data must be stored with Y axis inverted
  76197. */
  76198. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76199. /**
  76200. * Update a raw cube texture
  76201. * @param texture defines the texture to udpdate
  76202. * @param data defines the data to store
  76203. * @param format defines the data format
  76204. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76205. * @param invertY defines if data must be stored with Y axis inverted
  76206. * @param compression defines the compression used (null by default)
  76207. */
  76208. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76209. /**
  76210. * Update a raw cube texture
  76211. * @param texture defines the texture to udpdate
  76212. * @param data defines the data to store
  76213. * @param format defines the data format
  76214. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76215. * @param invertY defines if data must be stored with Y axis inverted
  76216. * @param compression defines the compression used (null by default)
  76217. * @param level defines which level of the texture to update
  76218. */
  76219. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76220. /**
  76221. * Creates a new raw cube texture from a specified url
  76222. * @param url defines the url where the data is located
  76223. * @param scene defines the current scene
  76224. * @param size defines the size of the textures
  76225. * @param format defines the format of the data
  76226. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76227. * @param noMipmap defines if the engine should avoid generating the mip levels
  76228. * @param callback defines a callback used to extract texture data from loaded data
  76229. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76230. * @param onLoad defines a callback called when texture is loaded
  76231. * @param onError defines a callback called if there is an error
  76232. * @returns the cube texture as an InternalTexture
  76233. */
  76234. 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;
  76235. /**
  76236. * Creates a new raw cube texture from a specified url
  76237. * @param url defines the url where the data is located
  76238. * @param scene defines the current scene
  76239. * @param size defines the size of the textures
  76240. * @param format defines the format of the data
  76241. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76242. * @param noMipmap defines if the engine should avoid generating the mip levels
  76243. * @param callback defines a callback used to extract texture data from loaded data
  76244. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76245. * @param onLoad defines a callback called when texture is loaded
  76246. * @param onError defines a callback called if there is an error
  76247. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76248. * @param invertY defines if data must be stored with Y axis inverted
  76249. * @returns the cube texture as an InternalTexture
  76250. */
  76251. 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;
  76252. /**
  76253. * Creates a new raw 3D texture
  76254. * @param data defines the data used to create the texture
  76255. * @param width defines the width of the texture
  76256. * @param height defines the height of the texture
  76257. * @param depth defines the depth of the texture
  76258. * @param format defines the format of the texture
  76259. * @param generateMipMaps defines if the engine must generate mip levels
  76260. * @param invertY defines if data must be stored with Y axis inverted
  76261. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76262. * @param compression defines the compressed used (can be null)
  76263. * @param textureType defines the compressed used (can be null)
  76264. * @returns a new raw 3D texture (stored in an InternalTexture)
  76265. */
  76266. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76267. /**
  76268. * Update a raw 3D texture
  76269. * @param texture defines the texture to update
  76270. * @param data defines the data to store
  76271. * @param format defines the data format
  76272. * @param invertY defines if data must be stored with Y axis inverted
  76273. */
  76274. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76275. /**
  76276. * Update a raw 3D texture
  76277. * @param texture defines the texture to update
  76278. * @param data defines the data to store
  76279. * @param format defines the data format
  76280. * @param invertY defines if data must be stored with Y axis inverted
  76281. * @param compression defines the used compression (can be null)
  76282. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76283. */
  76284. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76285. }
  76286. }
  76287. declare module BABYLON {
  76288. /**
  76289. * Raw texture can help creating a texture directly from an array of data.
  76290. * This can be super useful if you either get the data from an uncompressed source or
  76291. * if you wish to create your texture pixel by pixel.
  76292. */
  76293. export class RawTexture extends Texture {
  76294. /**
  76295. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76296. */
  76297. format: number;
  76298. private _engine;
  76299. /**
  76300. * Instantiates a new RawTexture.
  76301. * Raw texture can help creating a texture directly from an array of data.
  76302. * This can be super useful if you either get the data from an uncompressed source or
  76303. * if you wish to create your texture pixel by pixel.
  76304. * @param data define the array of data to use to create the texture
  76305. * @param width define the width of the texture
  76306. * @param height define the height of the texture
  76307. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76308. * @param scene define the scene the texture belongs to
  76309. * @param generateMipMaps define whether mip maps should be generated or not
  76310. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76311. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76312. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76313. */
  76314. constructor(data: ArrayBufferView, width: number, height: number,
  76315. /**
  76316. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76317. */
  76318. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76319. /**
  76320. * Updates the texture underlying data.
  76321. * @param data Define the new data of the texture
  76322. */
  76323. update(data: ArrayBufferView): void;
  76324. /**
  76325. * Creates a luminance texture from some data.
  76326. * @param data Define the texture data
  76327. * @param width Define the width of the texture
  76328. * @param height Define the height of the texture
  76329. * @param scene Define the scene the texture belongs to
  76330. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76331. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76332. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76333. * @returns the luminance texture
  76334. */
  76335. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76336. /**
  76337. * Creates a luminance alpha texture from some data.
  76338. * @param data Define the texture data
  76339. * @param width Define the width of the texture
  76340. * @param height Define the height of the texture
  76341. * @param scene Define the scene the texture belongs to
  76342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76345. * @returns the luminance alpha texture
  76346. */
  76347. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76348. /**
  76349. * Creates an alpha texture from some data.
  76350. * @param data Define the texture data
  76351. * @param width Define the width of the texture
  76352. * @param height Define the height of the texture
  76353. * @param scene Define the scene the texture belongs to
  76354. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76355. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76356. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76357. * @returns the alpha texture
  76358. */
  76359. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76360. /**
  76361. * Creates a RGB texture from some data.
  76362. * @param data Define the texture data
  76363. * @param width Define the width of the texture
  76364. * @param height Define the height of the texture
  76365. * @param scene Define the scene the texture belongs to
  76366. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76367. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76368. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76369. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76370. * @returns the RGB alpha texture
  76371. */
  76372. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76373. /**
  76374. * Creates a RGBA texture from some data.
  76375. * @param data Define the texture data
  76376. * @param width Define the width of the texture
  76377. * @param height Define the height of the texture
  76378. * @param scene Define the scene the texture belongs to
  76379. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76380. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76381. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76382. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76383. * @returns the RGBA texture
  76384. */
  76385. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76386. /**
  76387. * Creates a R texture from some data.
  76388. * @param data Define the texture data
  76389. * @param width Define the width of the texture
  76390. * @param height Define the height of the texture
  76391. * @param scene Define the scene the texture belongs to
  76392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76395. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76396. * @returns the R texture
  76397. */
  76398. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76399. }
  76400. }
  76401. declare module BABYLON {
  76402. /**
  76403. * Interface for the size containing width and height
  76404. */
  76405. export interface ISize {
  76406. /**
  76407. * Width
  76408. */
  76409. width: number;
  76410. /**
  76411. * Heighht
  76412. */
  76413. height: number;
  76414. }
  76415. /**
  76416. * Size containing widht and height
  76417. */
  76418. export class Size implements ISize {
  76419. /**
  76420. * Width
  76421. */
  76422. width: number;
  76423. /**
  76424. * Height
  76425. */
  76426. height: number;
  76427. /**
  76428. * Creates a Size object from the given width and height (floats).
  76429. * @param width width of the new size
  76430. * @param height height of the new size
  76431. */
  76432. constructor(width: number, height: number);
  76433. /**
  76434. * Returns a string with the Size width and height
  76435. * @returns a string with the Size width and height
  76436. */
  76437. toString(): string;
  76438. /**
  76439. * "Size"
  76440. * @returns the string "Size"
  76441. */
  76442. getClassName(): string;
  76443. /**
  76444. * Returns the Size hash code.
  76445. * @returns a hash code for a unique width and height
  76446. */
  76447. getHashCode(): number;
  76448. /**
  76449. * Updates the current size from the given one.
  76450. * @param src the given size
  76451. */
  76452. copyFrom(src: Size): void;
  76453. /**
  76454. * Updates in place the current Size from the given floats.
  76455. * @param width width of the new size
  76456. * @param height height of the new size
  76457. * @returns the updated Size.
  76458. */
  76459. copyFromFloats(width: number, height: number): Size;
  76460. /**
  76461. * Updates in place the current Size from the given floats.
  76462. * @param width width to set
  76463. * @param height height to set
  76464. * @returns the updated Size.
  76465. */
  76466. set(width: number, height: number): Size;
  76467. /**
  76468. * Multiplies the width and height by numbers
  76469. * @param w factor to multiple the width by
  76470. * @param h factor to multiple the height by
  76471. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76472. */
  76473. multiplyByFloats(w: number, h: number): Size;
  76474. /**
  76475. * Clones the size
  76476. * @returns a new Size copied from the given one.
  76477. */
  76478. clone(): Size;
  76479. /**
  76480. * True if the current Size and the given one width and height are strictly equal.
  76481. * @param other the other size to compare against
  76482. * @returns True if the current Size and the given one width and height are strictly equal.
  76483. */
  76484. equals(other: Size): boolean;
  76485. /**
  76486. * The surface of the Size : width * height (float).
  76487. */
  76488. readonly surface: number;
  76489. /**
  76490. * Create a new size of zero
  76491. * @returns a new Size set to (0.0, 0.0)
  76492. */
  76493. static Zero(): Size;
  76494. /**
  76495. * Sums the width and height of two sizes
  76496. * @param otherSize size to add to this size
  76497. * @returns a new Size set as the addition result of the current Size and the given one.
  76498. */
  76499. add(otherSize: Size): Size;
  76500. /**
  76501. * Subtracts the width and height of two
  76502. * @param otherSize size to subtract to this size
  76503. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76504. */
  76505. subtract(otherSize: Size): Size;
  76506. /**
  76507. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76508. * @param start starting size to lerp between
  76509. * @param end end size to lerp between
  76510. * @param amount amount to lerp between the start and end values
  76511. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76512. */
  76513. static Lerp(start: Size, end: Size, amount: number): Size;
  76514. }
  76515. }
  76516. declare module BABYLON {
  76517. /**
  76518. * Defines a runtime animation
  76519. */
  76520. export class RuntimeAnimation {
  76521. private _events;
  76522. /**
  76523. * The current frame of the runtime animation
  76524. */
  76525. private _currentFrame;
  76526. /**
  76527. * The animation used by the runtime animation
  76528. */
  76529. private _animation;
  76530. /**
  76531. * The target of the runtime animation
  76532. */
  76533. private _target;
  76534. /**
  76535. * The initiating animatable
  76536. */
  76537. private _host;
  76538. /**
  76539. * The original value of the runtime animation
  76540. */
  76541. private _originalValue;
  76542. /**
  76543. * The original blend value of the runtime animation
  76544. */
  76545. private _originalBlendValue;
  76546. /**
  76547. * The offsets cache of the runtime animation
  76548. */
  76549. private _offsetsCache;
  76550. /**
  76551. * The high limits cache of the runtime animation
  76552. */
  76553. private _highLimitsCache;
  76554. /**
  76555. * Specifies if the runtime animation has been stopped
  76556. */
  76557. private _stopped;
  76558. /**
  76559. * The blending factor of the runtime animation
  76560. */
  76561. private _blendingFactor;
  76562. /**
  76563. * The BabylonJS scene
  76564. */
  76565. private _scene;
  76566. /**
  76567. * The current value of the runtime animation
  76568. */
  76569. private _currentValue;
  76570. /** @hidden */
  76571. _animationState: _IAnimationState;
  76572. /**
  76573. * The active target of the runtime animation
  76574. */
  76575. private _activeTargets;
  76576. private _currentActiveTarget;
  76577. private _directTarget;
  76578. /**
  76579. * The target path of the runtime animation
  76580. */
  76581. private _targetPath;
  76582. /**
  76583. * The weight of the runtime animation
  76584. */
  76585. private _weight;
  76586. /**
  76587. * The ratio offset of the runtime animation
  76588. */
  76589. private _ratioOffset;
  76590. /**
  76591. * The previous delay of the runtime animation
  76592. */
  76593. private _previousDelay;
  76594. /**
  76595. * The previous ratio of the runtime animation
  76596. */
  76597. private _previousRatio;
  76598. private _enableBlending;
  76599. private _keys;
  76600. private _minFrame;
  76601. private _maxFrame;
  76602. private _minValue;
  76603. private _maxValue;
  76604. private _targetIsArray;
  76605. /**
  76606. * Gets the current frame of the runtime animation
  76607. */
  76608. readonly currentFrame: number;
  76609. /**
  76610. * Gets the weight of the runtime animation
  76611. */
  76612. readonly weight: number;
  76613. /**
  76614. * Gets the current value of the runtime animation
  76615. */
  76616. readonly currentValue: any;
  76617. /**
  76618. * Gets the target path of the runtime animation
  76619. */
  76620. readonly targetPath: string;
  76621. /**
  76622. * Gets the actual target of the runtime animation
  76623. */
  76624. readonly target: any;
  76625. /** @hidden */
  76626. _onLoop: () => void;
  76627. /**
  76628. * Create a new RuntimeAnimation object
  76629. * @param target defines the target of the animation
  76630. * @param animation defines the source animation object
  76631. * @param scene defines the hosting scene
  76632. * @param host defines the initiating Animatable
  76633. */
  76634. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76635. private _preparePath;
  76636. /**
  76637. * Gets the animation from the runtime animation
  76638. */
  76639. readonly animation: Animation;
  76640. /**
  76641. * Resets the runtime animation to the beginning
  76642. * @param restoreOriginal defines whether to restore the target property to the original value
  76643. */
  76644. reset(restoreOriginal?: boolean): void;
  76645. /**
  76646. * Specifies if the runtime animation is stopped
  76647. * @returns Boolean specifying if the runtime animation is stopped
  76648. */
  76649. isStopped(): boolean;
  76650. /**
  76651. * Disposes of the runtime animation
  76652. */
  76653. dispose(): void;
  76654. /**
  76655. * Apply the interpolated value to the target
  76656. * @param currentValue defines the value computed by the animation
  76657. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76658. */
  76659. setValue(currentValue: any, weight: number): void;
  76660. private _getOriginalValues;
  76661. private _setValue;
  76662. /**
  76663. * Gets the loop pmode of the runtime animation
  76664. * @returns Loop Mode
  76665. */
  76666. private _getCorrectLoopMode;
  76667. /**
  76668. * Move the current animation to a given frame
  76669. * @param frame defines the frame to move to
  76670. */
  76671. goToFrame(frame: number): void;
  76672. /**
  76673. * @hidden Internal use only
  76674. */
  76675. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76676. /**
  76677. * Execute the current animation
  76678. * @param delay defines the delay to add to the current frame
  76679. * @param from defines the lower bound of the animation range
  76680. * @param to defines the upper bound of the animation range
  76681. * @param loop defines if the current animation must loop
  76682. * @param speedRatio defines the current speed ratio
  76683. * @param weight defines the weight of the animation (default is -1 so no weight)
  76684. * @param onLoop optional callback called when animation loops
  76685. * @returns a boolean indicating if the animation is running
  76686. */
  76687. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76688. }
  76689. }
  76690. declare module BABYLON {
  76691. /**
  76692. * Class used to store an actual running animation
  76693. */
  76694. export class Animatable {
  76695. /** defines the target object */
  76696. target: any;
  76697. /** defines the starting frame number (default is 0) */
  76698. fromFrame: number;
  76699. /** defines the ending frame number (default is 100) */
  76700. toFrame: number;
  76701. /** defines if the animation must loop (default is false) */
  76702. loopAnimation: boolean;
  76703. /** defines a callback to call when animation ends if it is not looping */
  76704. onAnimationEnd?: (() => void) | null | undefined;
  76705. /** defines a callback to call when animation loops */
  76706. onAnimationLoop?: (() => void) | null | undefined;
  76707. private _localDelayOffset;
  76708. private _pausedDelay;
  76709. private _runtimeAnimations;
  76710. private _paused;
  76711. private _scene;
  76712. private _speedRatio;
  76713. private _weight;
  76714. private _syncRoot;
  76715. /**
  76716. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76717. * This will only apply for non looping animation (default is true)
  76718. */
  76719. disposeOnEnd: boolean;
  76720. /**
  76721. * Gets a boolean indicating if the animation has started
  76722. */
  76723. animationStarted: boolean;
  76724. /**
  76725. * Observer raised when the animation ends
  76726. */
  76727. onAnimationEndObservable: Observable<Animatable>;
  76728. /**
  76729. * Observer raised when the animation loops
  76730. */
  76731. onAnimationLoopObservable: Observable<Animatable>;
  76732. /**
  76733. * Gets the root Animatable used to synchronize and normalize animations
  76734. */
  76735. readonly syncRoot: Nullable<Animatable>;
  76736. /**
  76737. * Gets the current frame of the first RuntimeAnimation
  76738. * Used to synchronize Animatables
  76739. */
  76740. readonly masterFrame: number;
  76741. /**
  76742. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76743. */
  76744. weight: number;
  76745. /**
  76746. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76747. */
  76748. speedRatio: number;
  76749. /**
  76750. * Creates a new Animatable
  76751. * @param scene defines the hosting scene
  76752. * @param target defines the target object
  76753. * @param fromFrame defines the starting frame number (default is 0)
  76754. * @param toFrame defines the ending frame number (default is 100)
  76755. * @param loopAnimation defines if the animation must loop (default is false)
  76756. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76757. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76758. * @param animations defines a group of animation to add to the new Animatable
  76759. * @param onAnimationLoop defines a callback to call when animation loops
  76760. */
  76761. constructor(scene: Scene,
  76762. /** defines the target object */
  76763. target: any,
  76764. /** defines the starting frame number (default is 0) */
  76765. fromFrame?: number,
  76766. /** defines the ending frame number (default is 100) */
  76767. toFrame?: number,
  76768. /** defines if the animation must loop (default is false) */
  76769. loopAnimation?: boolean, speedRatio?: number,
  76770. /** defines a callback to call when animation ends if it is not looping */
  76771. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76772. /** defines a callback to call when animation loops */
  76773. onAnimationLoop?: (() => void) | null | undefined);
  76774. /**
  76775. * Synchronize and normalize current Animatable with a source Animatable
  76776. * This is useful when using animation weights and when animations are not of the same length
  76777. * @param root defines the root Animatable to synchronize with
  76778. * @returns the current Animatable
  76779. */
  76780. syncWith(root: Animatable): Animatable;
  76781. /**
  76782. * Gets the list of runtime animations
  76783. * @returns an array of RuntimeAnimation
  76784. */
  76785. getAnimations(): RuntimeAnimation[];
  76786. /**
  76787. * Adds more animations to the current animatable
  76788. * @param target defines the target of the animations
  76789. * @param animations defines the new animations to add
  76790. */
  76791. appendAnimations(target: any, animations: Animation[]): void;
  76792. /**
  76793. * Gets the source animation for a specific property
  76794. * @param property defines the propertyu to look for
  76795. * @returns null or the source animation for the given property
  76796. */
  76797. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76798. /**
  76799. * Gets the runtime animation for a specific property
  76800. * @param property defines the propertyu to look for
  76801. * @returns null or the runtime animation for the given property
  76802. */
  76803. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76804. /**
  76805. * Resets the animatable to its original state
  76806. */
  76807. reset(): void;
  76808. /**
  76809. * Allows the animatable to blend with current running animations
  76810. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76811. * @param blendingSpeed defines the blending speed to use
  76812. */
  76813. enableBlending(blendingSpeed: number): void;
  76814. /**
  76815. * Disable animation blending
  76816. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76817. */
  76818. disableBlending(): void;
  76819. /**
  76820. * Jump directly to a given frame
  76821. * @param frame defines the frame to jump to
  76822. */
  76823. goToFrame(frame: number): void;
  76824. /**
  76825. * Pause the animation
  76826. */
  76827. pause(): void;
  76828. /**
  76829. * Restart the animation
  76830. */
  76831. restart(): void;
  76832. private _raiseOnAnimationEnd;
  76833. /**
  76834. * Stop and delete the current animation
  76835. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76836. * @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)
  76837. */
  76838. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76839. /**
  76840. * Wait asynchronously for the animation to end
  76841. * @returns a promise which will be fullfilled when the animation ends
  76842. */
  76843. waitAsync(): Promise<Animatable>;
  76844. /** @hidden */
  76845. _animate(delay: number): boolean;
  76846. }
  76847. interface Scene {
  76848. /** @hidden */
  76849. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76850. /** @hidden */
  76851. _processLateAnimationBindingsForMatrices(holder: {
  76852. totalWeight: number;
  76853. animations: RuntimeAnimation[];
  76854. originalValue: Matrix;
  76855. }): any;
  76856. /** @hidden */
  76857. _processLateAnimationBindingsForQuaternions(holder: {
  76858. totalWeight: number;
  76859. animations: RuntimeAnimation[];
  76860. originalValue: Quaternion;
  76861. }, refQuaternion: Quaternion): Quaternion;
  76862. /** @hidden */
  76863. _processLateAnimationBindings(): void;
  76864. /**
  76865. * Will start the animation sequence of a given target
  76866. * @param target defines the target
  76867. * @param from defines from which frame should animation start
  76868. * @param to defines until which frame should animation run.
  76869. * @param weight defines the weight to apply to the animation (1.0 by default)
  76870. * @param loop defines if the animation loops
  76871. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76872. * @param onAnimationEnd defines the function to be executed when the animation ends
  76873. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76874. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76875. * @param onAnimationLoop defines the callback to call when an animation loops
  76876. * @returns the animatable object created for this animation
  76877. */
  76878. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76879. /**
  76880. * Will start the animation sequence of a given target
  76881. * @param target defines the target
  76882. * @param from defines from which frame should animation start
  76883. * @param to defines until which frame should animation run.
  76884. * @param loop defines if the animation loops
  76885. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76886. * @param onAnimationEnd defines the function to be executed when the animation ends
  76887. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76888. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76889. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76890. * @param onAnimationLoop defines the callback to call when an animation loops
  76891. * @returns the animatable object created for this animation
  76892. */
  76893. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76894. /**
  76895. * Will start the animation sequence of a given target and its hierarchy
  76896. * @param target defines the target
  76897. * @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.
  76898. * @param from defines from which frame should animation start
  76899. * @param to defines until which frame should animation run.
  76900. * @param loop defines if the animation loops
  76901. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76902. * @param onAnimationEnd defines the function to be executed when the animation ends
  76903. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76904. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76905. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76906. * @param onAnimationLoop defines the callback to call when an animation loops
  76907. * @returns the list of created animatables
  76908. */
  76909. 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[];
  76910. /**
  76911. * Begin a new animation on a given node
  76912. * @param target defines the target where the animation will take place
  76913. * @param animations defines the list of animations to start
  76914. * @param from defines the initial value
  76915. * @param to defines the final value
  76916. * @param loop defines if you want animation to loop (off by default)
  76917. * @param speedRatio defines the speed ratio to apply to all animations
  76918. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76919. * @param onAnimationLoop defines the callback to call when an animation loops
  76920. * @returns the list of created animatables
  76921. */
  76922. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76923. /**
  76924. * Begin a new animation on a given node and its hierarchy
  76925. * @param target defines the root node where the animation will take place
  76926. * @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.
  76927. * @param animations defines the list of animations to start
  76928. * @param from defines the initial value
  76929. * @param to defines the final value
  76930. * @param loop defines if you want animation to loop (off by default)
  76931. * @param speedRatio defines the speed ratio to apply to all animations
  76932. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76933. * @param onAnimationLoop defines the callback to call when an animation loops
  76934. * @returns the list of animatables created for all nodes
  76935. */
  76936. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76937. /**
  76938. * Gets the animatable associated with a specific target
  76939. * @param target defines the target of the animatable
  76940. * @returns the required animatable if found
  76941. */
  76942. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76943. /**
  76944. * Gets all animatables associated with a given target
  76945. * @param target defines the target to look animatables for
  76946. * @returns an array of Animatables
  76947. */
  76948. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76949. /**
  76950. * Stops and removes all animations that have been applied to the scene
  76951. */
  76952. stopAllAnimations(): void;
  76953. }
  76954. interface Bone {
  76955. /**
  76956. * Copy an animation range from another bone
  76957. * @param source defines the source bone
  76958. * @param rangeName defines the range name to copy
  76959. * @param frameOffset defines the frame offset
  76960. * @param rescaleAsRequired defines if rescaling must be applied if required
  76961. * @param skelDimensionsRatio defines the scaling ratio
  76962. * @returns true if operation was successful
  76963. */
  76964. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76965. }
  76966. }
  76967. declare module BABYLON {
  76968. /**
  76969. * Class used to override all child animations of a given target
  76970. */
  76971. export class AnimationPropertiesOverride {
  76972. /**
  76973. * Gets or sets a value indicating if animation blending must be used
  76974. */
  76975. enableBlending: boolean;
  76976. /**
  76977. * Gets or sets the blending speed to use when enableBlending is true
  76978. */
  76979. blendingSpeed: number;
  76980. /**
  76981. * Gets or sets the default loop mode to use
  76982. */
  76983. loopMode: number;
  76984. }
  76985. }
  76986. declare module BABYLON {
  76987. /**
  76988. * Class used to handle skinning animations
  76989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76990. */
  76991. export class Skeleton implements IAnimatable {
  76992. /** defines the skeleton name */
  76993. name: string;
  76994. /** defines the skeleton Id */
  76995. id: string;
  76996. /**
  76997. * Defines the list of child bones
  76998. */
  76999. bones: Bone[];
  77000. /**
  77001. * Defines an estimate of the dimension of the skeleton at rest
  77002. */
  77003. dimensionsAtRest: Vector3;
  77004. /**
  77005. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77006. */
  77007. needInitialSkinMatrix: boolean;
  77008. /**
  77009. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77010. */
  77011. overrideMesh: Nullable<AbstractMesh>;
  77012. /**
  77013. * Gets the list of animations attached to this skeleton
  77014. */
  77015. animations: Array<Animation>;
  77016. private _scene;
  77017. private _isDirty;
  77018. private _transformMatrices;
  77019. private _transformMatrixTexture;
  77020. private _meshesWithPoseMatrix;
  77021. private _animatables;
  77022. private _identity;
  77023. private _synchronizedWithMesh;
  77024. private _ranges;
  77025. private _lastAbsoluteTransformsUpdateId;
  77026. private _canUseTextureForBones;
  77027. private _uniqueId;
  77028. /** @hidden */
  77029. _numBonesWithLinkedTransformNode: number;
  77030. /** @hidden */
  77031. _hasWaitingData: Nullable<boolean>;
  77032. /**
  77033. * Specifies if the skeleton should be serialized
  77034. */
  77035. doNotSerialize: boolean;
  77036. private _useTextureToStoreBoneMatrices;
  77037. /**
  77038. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77039. * Please note that this option is not available if the hardware does not support it
  77040. */
  77041. useTextureToStoreBoneMatrices: boolean;
  77042. private _animationPropertiesOverride;
  77043. /**
  77044. * Gets or sets the animation properties override
  77045. */
  77046. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77047. /**
  77048. * List of inspectable custom properties (used by the Inspector)
  77049. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77050. */
  77051. inspectableCustomProperties: IInspectable[];
  77052. /**
  77053. * An observable triggered before computing the skeleton's matrices
  77054. */
  77055. onBeforeComputeObservable: Observable<Skeleton>;
  77056. /**
  77057. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77058. */
  77059. readonly isUsingTextureForMatrices: boolean;
  77060. /**
  77061. * Gets the unique ID of this skeleton
  77062. */
  77063. readonly uniqueId: number;
  77064. /**
  77065. * Creates a new skeleton
  77066. * @param name defines the skeleton name
  77067. * @param id defines the skeleton Id
  77068. * @param scene defines the hosting scene
  77069. */
  77070. constructor(
  77071. /** defines the skeleton name */
  77072. name: string,
  77073. /** defines the skeleton Id */
  77074. id: string, scene: Scene);
  77075. /**
  77076. * Gets the current object class name.
  77077. * @return the class name
  77078. */
  77079. getClassName(): string;
  77080. /**
  77081. * Returns an array containing the root bones
  77082. * @returns an array containing the root bones
  77083. */
  77084. getChildren(): Array<Bone>;
  77085. /**
  77086. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77087. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77088. * @returns a Float32Array containing matrices data
  77089. */
  77090. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77091. /**
  77092. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77093. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77094. * @returns a raw texture containing the data
  77095. */
  77096. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77097. /**
  77098. * Gets the current hosting scene
  77099. * @returns a scene object
  77100. */
  77101. getScene(): Scene;
  77102. /**
  77103. * Gets a string representing the current skeleton data
  77104. * @param fullDetails defines a boolean indicating if we want a verbose version
  77105. * @returns a string representing the current skeleton data
  77106. */
  77107. toString(fullDetails?: boolean): string;
  77108. /**
  77109. * Get bone's index searching by name
  77110. * @param name defines bone's name to search for
  77111. * @return the indice of the bone. Returns -1 if not found
  77112. */
  77113. getBoneIndexByName(name: string): number;
  77114. /**
  77115. * Creater a new animation range
  77116. * @param name defines the name of the range
  77117. * @param from defines the start key
  77118. * @param to defines the end key
  77119. */
  77120. createAnimationRange(name: string, from: number, to: number): void;
  77121. /**
  77122. * Delete a specific animation range
  77123. * @param name defines the name of the range
  77124. * @param deleteFrames defines if frames must be removed as well
  77125. */
  77126. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77127. /**
  77128. * Gets a specific animation range
  77129. * @param name defines the name of the range to look for
  77130. * @returns the requested animation range or null if not found
  77131. */
  77132. getAnimationRange(name: string): Nullable<AnimationRange>;
  77133. /**
  77134. * Gets the list of all animation ranges defined on this skeleton
  77135. * @returns an array
  77136. */
  77137. getAnimationRanges(): Nullable<AnimationRange>[];
  77138. /**
  77139. * Copy animation range from a source skeleton.
  77140. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77141. * @param source defines the source skeleton
  77142. * @param name defines the name of the range to copy
  77143. * @param rescaleAsRequired defines if rescaling must be applied if required
  77144. * @returns true if operation was successful
  77145. */
  77146. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77147. /**
  77148. * Forces the skeleton to go to rest pose
  77149. */
  77150. returnToRest(): void;
  77151. private _getHighestAnimationFrame;
  77152. /**
  77153. * Begin a specific animation range
  77154. * @param name defines the name of the range to start
  77155. * @param loop defines if looping must be turned on (false by default)
  77156. * @param speedRatio defines the speed ratio to apply (1 by default)
  77157. * @param onAnimationEnd defines a callback which will be called when animation will end
  77158. * @returns a new animatable
  77159. */
  77160. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77161. /** @hidden */
  77162. _markAsDirty(): void;
  77163. /** @hidden */
  77164. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77165. /** @hidden */
  77166. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77167. private _computeTransformMatrices;
  77168. /**
  77169. * Build all resources required to render a skeleton
  77170. */
  77171. prepare(): void;
  77172. /**
  77173. * Gets the list of animatables currently running for this skeleton
  77174. * @returns an array of animatables
  77175. */
  77176. getAnimatables(): IAnimatable[];
  77177. /**
  77178. * Clone the current skeleton
  77179. * @param name defines the name of the new skeleton
  77180. * @param id defines the id of the new skeleton
  77181. * @returns the new skeleton
  77182. */
  77183. clone(name: string, id: string): Skeleton;
  77184. /**
  77185. * Enable animation blending for this skeleton
  77186. * @param blendingSpeed defines the blending speed to apply
  77187. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77188. */
  77189. enableBlending(blendingSpeed?: number): void;
  77190. /**
  77191. * Releases all resources associated with the current skeleton
  77192. */
  77193. dispose(): void;
  77194. /**
  77195. * Serialize the skeleton in a JSON object
  77196. * @returns a JSON object
  77197. */
  77198. serialize(): any;
  77199. /**
  77200. * Creates a new skeleton from serialized data
  77201. * @param parsedSkeleton defines the serialized data
  77202. * @param scene defines the hosting scene
  77203. * @returns a new skeleton
  77204. */
  77205. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77206. /**
  77207. * Compute all node absolute transforms
  77208. * @param forceUpdate defines if computation must be done even if cache is up to date
  77209. */
  77210. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77211. /**
  77212. * Gets the root pose matrix
  77213. * @returns a matrix
  77214. */
  77215. getPoseMatrix(): Nullable<Matrix>;
  77216. /**
  77217. * Sorts bones per internal index
  77218. */
  77219. sortBones(): void;
  77220. private _sortBones;
  77221. }
  77222. }
  77223. declare module BABYLON {
  77224. /**
  77225. * Class used to store bone information
  77226. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77227. */
  77228. export class Bone extends Node {
  77229. /**
  77230. * defines the bone name
  77231. */
  77232. name: string;
  77233. private static _tmpVecs;
  77234. private static _tmpQuat;
  77235. private static _tmpMats;
  77236. /**
  77237. * Gets the list of child bones
  77238. */
  77239. children: Bone[];
  77240. /** Gets the animations associated with this bone */
  77241. animations: Animation[];
  77242. /**
  77243. * Gets or sets bone length
  77244. */
  77245. length: number;
  77246. /**
  77247. * @hidden Internal only
  77248. * Set this value to map this bone to a different index in the transform matrices
  77249. * Set this value to -1 to exclude the bone from the transform matrices
  77250. */
  77251. _index: Nullable<number>;
  77252. private _skeleton;
  77253. private _localMatrix;
  77254. private _restPose;
  77255. private _baseMatrix;
  77256. private _absoluteTransform;
  77257. private _invertedAbsoluteTransform;
  77258. private _parent;
  77259. private _scalingDeterminant;
  77260. private _worldTransform;
  77261. private _localScaling;
  77262. private _localRotation;
  77263. private _localPosition;
  77264. private _needToDecompose;
  77265. private _needToCompose;
  77266. /** @hidden */
  77267. _linkedTransformNode: Nullable<TransformNode>;
  77268. /** @hidden */
  77269. _waitingTransformNodeId: Nullable<string>;
  77270. /** @hidden */
  77271. /** @hidden */
  77272. _matrix: Matrix;
  77273. /**
  77274. * Create a new bone
  77275. * @param name defines the bone name
  77276. * @param skeleton defines the parent skeleton
  77277. * @param parentBone defines the parent (can be null if the bone is the root)
  77278. * @param localMatrix defines the local matrix
  77279. * @param restPose defines the rest pose matrix
  77280. * @param baseMatrix defines the base matrix
  77281. * @param index defines index of the bone in the hiearchy
  77282. */
  77283. constructor(
  77284. /**
  77285. * defines the bone name
  77286. */
  77287. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77288. /**
  77289. * Gets the current object class name.
  77290. * @return the class name
  77291. */
  77292. getClassName(): string;
  77293. /**
  77294. * Gets the parent skeleton
  77295. * @returns a skeleton
  77296. */
  77297. getSkeleton(): Skeleton;
  77298. /**
  77299. * Gets parent bone
  77300. * @returns a bone or null if the bone is the root of the bone hierarchy
  77301. */
  77302. getParent(): Nullable<Bone>;
  77303. /**
  77304. * Returns an array containing the root bones
  77305. * @returns an array containing the root bones
  77306. */
  77307. getChildren(): Array<Bone>;
  77308. /**
  77309. * Sets the parent bone
  77310. * @param parent defines the parent (can be null if the bone is the root)
  77311. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77312. */
  77313. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77314. /**
  77315. * Gets the local matrix
  77316. * @returns a matrix
  77317. */
  77318. getLocalMatrix(): Matrix;
  77319. /**
  77320. * Gets the base matrix (initial matrix which remains unchanged)
  77321. * @returns a matrix
  77322. */
  77323. getBaseMatrix(): Matrix;
  77324. /**
  77325. * Gets the rest pose matrix
  77326. * @returns a matrix
  77327. */
  77328. getRestPose(): Matrix;
  77329. /**
  77330. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77331. */
  77332. getWorldMatrix(): Matrix;
  77333. /**
  77334. * Sets the local matrix to rest pose matrix
  77335. */
  77336. returnToRest(): void;
  77337. /**
  77338. * Gets the inverse of the absolute transform matrix.
  77339. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77340. * @returns a matrix
  77341. */
  77342. getInvertedAbsoluteTransform(): Matrix;
  77343. /**
  77344. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77345. * @returns a matrix
  77346. */
  77347. getAbsoluteTransform(): Matrix;
  77348. /**
  77349. * Links with the given transform node.
  77350. * The local matrix of this bone is copied from the transform node every frame.
  77351. * @param transformNode defines the transform node to link to
  77352. */
  77353. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77354. /**
  77355. * Gets the node used to drive the bone's transformation
  77356. * @returns a transform node or null
  77357. */
  77358. getTransformNode(): Nullable<TransformNode>;
  77359. /** Gets or sets current position (in local space) */
  77360. position: Vector3;
  77361. /** Gets or sets current rotation (in local space) */
  77362. rotation: Vector3;
  77363. /** Gets or sets current rotation quaternion (in local space) */
  77364. rotationQuaternion: Quaternion;
  77365. /** Gets or sets current scaling (in local space) */
  77366. scaling: Vector3;
  77367. /**
  77368. * Gets the animation properties override
  77369. */
  77370. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77371. private _decompose;
  77372. private _compose;
  77373. /**
  77374. * Update the base and local matrices
  77375. * @param matrix defines the new base or local matrix
  77376. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77377. * @param updateLocalMatrix defines if the local matrix should be updated
  77378. */
  77379. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77380. /** @hidden */
  77381. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77382. /**
  77383. * Flag the bone as dirty (Forcing it to update everything)
  77384. */
  77385. markAsDirty(): void;
  77386. /** @hidden */
  77387. _markAsDirtyAndCompose(): void;
  77388. private _markAsDirtyAndDecompose;
  77389. /**
  77390. * Translate the bone in local or world space
  77391. * @param vec The amount to translate the bone
  77392. * @param space The space that the translation is in
  77393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77394. */
  77395. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77396. /**
  77397. * Set the postion of the bone in local or world space
  77398. * @param position The position to set the bone
  77399. * @param space The space that the position is in
  77400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77401. */
  77402. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77403. /**
  77404. * Set the absolute position of the bone (world space)
  77405. * @param position The position to set the bone
  77406. * @param mesh The mesh that this bone is attached to
  77407. */
  77408. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77409. /**
  77410. * Scale the bone on the x, y and z axes (in local space)
  77411. * @param x The amount to scale the bone on the x axis
  77412. * @param y The amount to scale the bone on the y axis
  77413. * @param z The amount to scale the bone on the z axis
  77414. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77415. */
  77416. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77417. /**
  77418. * Set the bone scaling in local space
  77419. * @param scale defines the scaling vector
  77420. */
  77421. setScale(scale: Vector3): void;
  77422. /**
  77423. * Gets the current scaling in local space
  77424. * @returns the current scaling vector
  77425. */
  77426. getScale(): Vector3;
  77427. /**
  77428. * Gets the current scaling in local space and stores it in a target vector
  77429. * @param result defines the target vector
  77430. */
  77431. getScaleToRef(result: Vector3): void;
  77432. /**
  77433. * Set the yaw, pitch, and roll of the bone in local or world space
  77434. * @param yaw The rotation of the bone on the y axis
  77435. * @param pitch The rotation of the bone on the x axis
  77436. * @param roll The rotation of the bone on the z axis
  77437. * @param space The space that the axes of rotation are in
  77438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77439. */
  77440. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77441. /**
  77442. * Add a rotation to the bone on an axis in local or world space
  77443. * @param axis The axis to rotate the bone on
  77444. * @param amount The amount to rotate the bone
  77445. * @param space The space that the axis is in
  77446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77447. */
  77448. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77449. /**
  77450. * Set the rotation of the bone to a particular axis angle in local or world space
  77451. * @param axis The axis to rotate the bone on
  77452. * @param angle The angle that the bone should be rotated to
  77453. * @param space The space that the axis is in
  77454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77455. */
  77456. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77457. /**
  77458. * Set the euler rotation of the bone in local of world space
  77459. * @param rotation The euler rotation that the bone should be set to
  77460. * @param space The space that the rotation is in
  77461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77462. */
  77463. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77464. /**
  77465. * Set the quaternion rotation of the bone in local of world space
  77466. * @param quat The quaternion rotation that the bone should be set to
  77467. * @param space The space that the rotation is in
  77468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77469. */
  77470. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77471. /**
  77472. * Set the rotation matrix of the bone in local of world space
  77473. * @param rotMat The rotation matrix that the bone should be set to
  77474. * @param space The space that the rotation is in
  77475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77476. */
  77477. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77478. private _rotateWithMatrix;
  77479. private _getNegativeRotationToRef;
  77480. /**
  77481. * Get the position of the bone in local or world space
  77482. * @param space The space that the returned position is in
  77483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77484. * @returns The position of the bone
  77485. */
  77486. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77487. /**
  77488. * Copy the position of the bone to a vector3 in local or world space
  77489. * @param space The space that the returned position is in
  77490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77491. * @param result The vector3 to copy the position to
  77492. */
  77493. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77494. /**
  77495. * Get the absolute position of the bone (world space)
  77496. * @param mesh The mesh that this bone is attached to
  77497. * @returns The absolute position of the bone
  77498. */
  77499. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77500. /**
  77501. * Copy the absolute position of the bone (world space) to the result param
  77502. * @param mesh The mesh that this bone is attached to
  77503. * @param result The vector3 to copy the absolute position to
  77504. */
  77505. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77506. /**
  77507. * Compute the absolute transforms of this bone and its children
  77508. */
  77509. computeAbsoluteTransforms(): void;
  77510. /**
  77511. * Get the world direction from an axis that is in the local space of the bone
  77512. * @param localAxis The local direction that is used to compute the world direction
  77513. * @param mesh The mesh that this bone is attached to
  77514. * @returns The world direction
  77515. */
  77516. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77517. /**
  77518. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77519. * @param localAxis The local direction that is used to compute the world direction
  77520. * @param mesh The mesh that this bone is attached to
  77521. * @param result The vector3 that the world direction will be copied to
  77522. */
  77523. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77524. /**
  77525. * Get the euler rotation of the bone in local or world space
  77526. * @param space The space that the rotation should be in
  77527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77528. * @returns The euler rotation
  77529. */
  77530. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77531. /**
  77532. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77533. * @param space The space that the rotation should be in
  77534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77535. * @param result The vector3 that the rotation should be copied to
  77536. */
  77537. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77538. /**
  77539. * Get the quaternion rotation of the bone in either local or world space
  77540. * @param space The space that the rotation should be in
  77541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77542. * @returns The quaternion rotation
  77543. */
  77544. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77545. /**
  77546. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77547. * @param space The space that the rotation should be in
  77548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77549. * @param result The quaternion that the rotation should be copied to
  77550. */
  77551. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77552. /**
  77553. * Get the rotation matrix of the bone in local or world space
  77554. * @param space The space that the rotation should be in
  77555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77556. * @returns The rotation matrix
  77557. */
  77558. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77559. /**
  77560. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77561. * @param space The space that the rotation should be in
  77562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77563. * @param result The quaternion that the rotation should be copied to
  77564. */
  77565. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77566. /**
  77567. * Get the world position of a point that is in the local space of the bone
  77568. * @param position The local position
  77569. * @param mesh The mesh that this bone is attached to
  77570. * @returns The world position
  77571. */
  77572. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77573. /**
  77574. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77575. * @param position The local position
  77576. * @param mesh The mesh that this bone is attached to
  77577. * @param result The vector3 that the world position should be copied to
  77578. */
  77579. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77580. /**
  77581. * Get the local position of a point that is in world space
  77582. * @param position The world position
  77583. * @param mesh The mesh that this bone is attached to
  77584. * @returns The local position
  77585. */
  77586. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77587. /**
  77588. * Get the local position of a point that is in world space and copy it to the result param
  77589. * @param position The world position
  77590. * @param mesh The mesh that this bone is attached to
  77591. * @param result The vector3 that the local position should be copied to
  77592. */
  77593. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77594. }
  77595. }
  77596. declare module BABYLON {
  77597. /**
  77598. * 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.
  77599. * @see https://doc.babylonjs.com/how_to/transformnode
  77600. */
  77601. export class TransformNode extends Node {
  77602. /**
  77603. * Object will not rotate to face the camera
  77604. */
  77605. static BILLBOARDMODE_NONE: number;
  77606. /**
  77607. * Object will rotate to face the camera but only on the x axis
  77608. */
  77609. static BILLBOARDMODE_X: number;
  77610. /**
  77611. * Object will rotate to face the camera but only on the y axis
  77612. */
  77613. static BILLBOARDMODE_Y: number;
  77614. /**
  77615. * Object will rotate to face the camera but only on the z axis
  77616. */
  77617. static BILLBOARDMODE_Z: number;
  77618. /**
  77619. * Object will rotate to face the camera
  77620. */
  77621. static BILLBOARDMODE_ALL: number;
  77622. private _forward;
  77623. private _forwardInverted;
  77624. private _up;
  77625. private _right;
  77626. private _rightInverted;
  77627. private _position;
  77628. private _rotation;
  77629. private _rotationQuaternion;
  77630. protected _scaling: Vector3;
  77631. protected _isDirty: boolean;
  77632. private _transformToBoneReferal;
  77633. private _isAbsoluteSynced;
  77634. private _billboardMode;
  77635. /**
  77636. * Gets or sets the billboard mode. Default is 0.
  77637. *
  77638. * | Value | Type | Description |
  77639. * | --- | --- | --- |
  77640. * | 0 | BILLBOARDMODE_NONE | |
  77641. * | 1 | BILLBOARDMODE_X | |
  77642. * | 2 | BILLBOARDMODE_Y | |
  77643. * | 4 | BILLBOARDMODE_Z | |
  77644. * | 7 | BILLBOARDMODE_ALL | |
  77645. *
  77646. */
  77647. billboardMode: number;
  77648. private _preserveParentRotationForBillboard;
  77649. /**
  77650. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77651. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77652. */
  77653. preserveParentRotationForBillboard: boolean;
  77654. /**
  77655. * 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
  77656. */
  77657. scalingDeterminant: number;
  77658. private _infiniteDistance;
  77659. /**
  77660. * Gets or sets the distance of the object to max, often used by skybox
  77661. */
  77662. infiniteDistance: boolean;
  77663. /**
  77664. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77665. * By default the system will update normals to compensate
  77666. */
  77667. ignoreNonUniformScaling: boolean;
  77668. /**
  77669. * 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
  77670. */
  77671. reIntegrateRotationIntoRotationQuaternion: boolean;
  77672. /** @hidden */
  77673. _poseMatrix: Nullable<Matrix>;
  77674. /** @hidden */
  77675. _localMatrix: Matrix;
  77676. private _usePivotMatrix;
  77677. private _absolutePosition;
  77678. private _absoluteScaling;
  77679. private _absoluteRotationQuaternion;
  77680. private _pivotMatrix;
  77681. private _pivotMatrixInverse;
  77682. protected _postMultiplyPivotMatrix: boolean;
  77683. protected _isWorldMatrixFrozen: boolean;
  77684. /** @hidden */
  77685. _indexInSceneTransformNodesArray: number;
  77686. /**
  77687. * An event triggered after the world matrix is updated
  77688. */
  77689. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77690. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77691. /**
  77692. * Gets a string identifying the name of the class
  77693. * @returns "TransformNode" string
  77694. */
  77695. getClassName(): string;
  77696. /**
  77697. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77698. */
  77699. position: Vector3;
  77700. /**
  77701. * 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)).
  77702. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77703. */
  77704. rotation: Vector3;
  77705. /**
  77706. * 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)).
  77707. */
  77708. scaling: Vector3;
  77709. /**
  77710. * 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).
  77711. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77712. */
  77713. rotationQuaternion: Nullable<Quaternion>;
  77714. /**
  77715. * The forward direction of that transform in world space.
  77716. */
  77717. readonly forward: Vector3;
  77718. /**
  77719. * The up direction of that transform in world space.
  77720. */
  77721. readonly up: Vector3;
  77722. /**
  77723. * The right direction of that transform in world space.
  77724. */
  77725. readonly right: Vector3;
  77726. /**
  77727. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77728. * @param matrix the matrix to copy the pose from
  77729. * @returns this TransformNode.
  77730. */
  77731. updatePoseMatrix(matrix: Matrix): TransformNode;
  77732. /**
  77733. * Returns the mesh Pose matrix.
  77734. * @returns the pose matrix
  77735. */
  77736. getPoseMatrix(): Matrix;
  77737. /** @hidden */
  77738. _isSynchronized(): boolean;
  77739. /** @hidden */
  77740. _initCache(): void;
  77741. /**
  77742. * Flag the transform node as dirty (Forcing it to update everything)
  77743. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77744. * @returns this transform node
  77745. */
  77746. markAsDirty(property: string): TransformNode;
  77747. /**
  77748. * Returns the current mesh absolute position.
  77749. * Returns a Vector3.
  77750. */
  77751. readonly absolutePosition: Vector3;
  77752. /**
  77753. * Returns the current mesh absolute scaling.
  77754. * Returns a Vector3.
  77755. */
  77756. readonly absoluteScaling: Vector3;
  77757. /**
  77758. * Returns the current mesh absolute rotation.
  77759. * Returns a Quaternion.
  77760. */
  77761. readonly absoluteRotationQuaternion: Quaternion;
  77762. /**
  77763. * Sets a new matrix to apply before all other transformation
  77764. * @param matrix defines the transform matrix
  77765. * @returns the current TransformNode
  77766. */
  77767. setPreTransformMatrix(matrix: Matrix): TransformNode;
  77768. /**
  77769. * Sets a new pivot matrix to the current node
  77770. * @param matrix defines the new pivot matrix to use
  77771. * @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
  77772. * @returns the current TransformNode
  77773. */
  77774. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  77775. /**
  77776. * Returns the mesh pivot matrix.
  77777. * Default : Identity.
  77778. * @returns the matrix
  77779. */
  77780. getPivotMatrix(): Matrix;
  77781. /**
  77782. * Prevents the World matrix to be computed any longer.
  77783. * @returns the TransformNode.
  77784. */
  77785. freezeWorldMatrix(): TransformNode;
  77786. /**
  77787. * Allows back the World matrix computation.
  77788. * @returns the TransformNode.
  77789. */
  77790. unfreezeWorldMatrix(): this;
  77791. /**
  77792. * True if the World matrix has been frozen.
  77793. */
  77794. readonly isWorldMatrixFrozen: boolean;
  77795. /**
  77796. * Retuns the mesh absolute position in the World.
  77797. * @returns a Vector3.
  77798. */
  77799. getAbsolutePosition(): Vector3;
  77800. /**
  77801. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  77802. * @param absolutePosition the absolute position to set
  77803. * @returns the TransformNode.
  77804. */
  77805. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77806. /**
  77807. * Sets the mesh position in its local space.
  77808. * @param vector3 the position to set in localspace
  77809. * @returns the TransformNode.
  77810. */
  77811. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77812. /**
  77813. * Returns the mesh position in the local space from the current World matrix values.
  77814. * @returns a new Vector3.
  77815. */
  77816. getPositionExpressedInLocalSpace(): Vector3;
  77817. /**
  77818. * Translates the mesh along the passed Vector3 in its local space.
  77819. * @param vector3 the distance to translate in localspace
  77820. * @returns the TransformNode.
  77821. */
  77822. locallyTranslate(vector3: Vector3): TransformNode;
  77823. private static _lookAtVectorCache;
  77824. /**
  77825. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77826. * @param targetPoint the position (must be in same space as current mesh) to look at
  77827. * @param yawCor optional yaw (y-axis) correction in radians
  77828. * @param pitchCor optional pitch (x-axis) correction in radians
  77829. * @param rollCor optional roll (z-axis) correction in radians
  77830. * @param space the choosen space of the target
  77831. * @returns the TransformNode.
  77832. */
  77833. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77834. /**
  77835. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77836. * This Vector3 is expressed in the World space.
  77837. * @param localAxis axis to rotate
  77838. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77839. */
  77840. getDirection(localAxis: Vector3): Vector3;
  77841. /**
  77842. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77843. * localAxis is expressed in the mesh local space.
  77844. * result is computed in the Wordl space from the mesh World matrix.
  77845. * @param localAxis axis to rotate
  77846. * @param result the resulting transformnode
  77847. * @returns this TransformNode.
  77848. */
  77849. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77850. /**
  77851. * Sets this transform node rotation to the given local axis.
  77852. * @param localAxis the axis in local space
  77853. * @param yawCor optional yaw (y-axis) correction in radians
  77854. * @param pitchCor optional pitch (x-axis) correction in radians
  77855. * @param rollCor optional roll (z-axis) correction in radians
  77856. * @returns this TransformNode
  77857. */
  77858. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77859. /**
  77860. * Sets a new pivot point to the current node
  77861. * @param point defines the new pivot point to use
  77862. * @param space defines if the point is in world or local space (local by default)
  77863. * @returns the current TransformNode
  77864. */
  77865. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77866. /**
  77867. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77868. * @returns the pivot point
  77869. */
  77870. getPivotPoint(): Vector3;
  77871. /**
  77872. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77873. * @param result the vector3 to store the result
  77874. * @returns this TransformNode.
  77875. */
  77876. getPivotPointToRef(result: Vector3): TransformNode;
  77877. /**
  77878. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77879. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77880. */
  77881. getAbsolutePivotPoint(): Vector3;
  77882. /**
  77883. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77884. * @param result vector3 to store the result
  77885. * @returns this TransformNode.
  77886. */
  77887. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77888. /**
  77889. * Defines the passed node as the parent of the current node.
  77890. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77891. * @see https://doc.babylonjs.com/how_to/parenting
  77892. * @param node the node ot set as the parent
  77893. * @returns this TransformNode.
  77894. */
  77895. setParent(node: Nullable<Node>): TransformNode;
  77896. private _nonUniformScaling;
  77897. /**
  77898. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77899. */
  77900. readonly nonUniformScaling: boolean;
  77901. /** @hidden */
  77902. _updateNonUniformScalingState(value: boolean): boolean;
  77903. /**
  77904. * Attach the current TransformNode to another TransformNode associated with a bone
  77905. * @param bone Bone affecting the TransformNode
  77906. * @param affectedTransformNode TransformNode associated with the bone
  77907. * @returns this object
  77908. */
  77909. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77910. /**
  77911. * Detach the transform node if its associated with a bone
  77912. * @returns this object
  77913. */
  77914. detachFromBone(): TransformNode;
  77915. private static _rotationAxisCache;
  77916. /**
  77917. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77918. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77919. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77920. * The passed axis is also normalized.
  77921. * @param axis the axis to rotate around
  77922. * @param amount the amount to rotate in radians
  77923. * @param space Space to rotate in (Default: local)
  77924. * @returns the TransformNode.
  77925. */
  77926. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77927. /**
  77928. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77929. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77930. * The passed axis is also normalized. .
  77931. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77932. * @param point the point to rotate around
  77933. * @param axis the axis to rotate around
  77934. * @param amount the amount to rotate in radians
  77935. * @returns the TransformNode
  77936. */
  77937. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77938. /**
  77939. * Translates the mesh along the axis vector for the passed distance in the given space.
  77940. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77941. * @param axis the axis to translate in
  77942. * @param distance the distance to translate
  77943. * @param space Space to rotate in (Default: local)
  77944. * @returns the TransformNode.
  77945. */
  77946. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77947. /**
  77948. * Adds a rotation step to the mesh current rotation.
  77949. * x, y, z are Euler angles expressed in radians.
  77950. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77951. * This means this rotation is made in the mesh local space only.
  77952. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77953. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77954. * ```javascript
  77955. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77956. * ```
  77957. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77958. * 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.
  77959. * @param x Rotation to add
  77960. * @param y Rotation to add
  77961. * @param z Rotation to add
  77962. * @returns the TransformNode.
  77963. */
  77964. addRotation(x: number, y: number, z: number): TransformNode;
  77965. /**
  77966. * @hidden
  77967. */
  77968. protected _getEffectiveParent(): Nullable<Node>;
  77969. /**
  77970. * Computes the world matrix of the node
  77971. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77972. * @returns the world matrix
  77973. */
  77974. computeWorldMatrix(force?: boolean): Matrix;
  77975. protected _afterComputeWorldMatrix(): void;
  77976. /**
  77977. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77978. * @param func callback function to add
  77979. *
  77980. * @returns the TransformNode.
  77981. */
  77982. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77983. /**
  77984. * Removes a registered callback function.
  77985. * @param func callback function to remove
  77986. * @returns the TransformNode.
  77987. */
  77988. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77989. /**
  77990. * Gets the position of the current mesh in camera space
  77991. * @param camera defines the camera to use
  77992. * @returns a position
  77993. */
  77994. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77995. /**
  77996. * Returns the distance from the mesh to the active camera
  77997. * @param camera defines the camera to use
  77998. * @returns the distance
  77999. */
  78000. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78001. /**
  78002. * Clone the current transform node
  78003. * @param name Name of the new clone
  78004. * @param newParent New parent for the clone
  78005. * @param doNotCloneChildren Do not clone children hierarchy
  78006. * @returns the new transform node
  78007. */
  78008. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78009. /**
  78010. * Serializes the objects information.
  78011. * @param currentSerializationObject defines the object to serialize in
  78012. * @returns the serialized object
  78013. */
  78014. serialize(currentSerializationObject?: any): any;
  78015. /**
  78016. * Returns a new TransformNode object parsed from the source provided.
  78017. * @param parsedTransformNode is the source.
  78018. * @param scene the scne the object belongs to
  78019. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78020. * @returns a new TransformNode object parsed from the source provided.
  78021. */
  78022. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78023. /**
  78024. * Get all child-transformNodes of this node
  78025. * @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
  78026. * @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
  78027. * @returns an array of TransformNode
  78028. */
  78029. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78030. /**
  78031. * Releases resources associated with this transform node.
  78032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78034. */
  78035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78036. /**
  78037. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78038. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78039. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78040. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78041. * @returns the current mesh
  78042. */
  78043. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78044. private _syncAbsoluteScalingAndRotation;
  78045. }
  78046. }
  78047. declare module BABYLON {
  78048. /**
  78049. * Defines the types of pose enabled controllers that are supported
  78050. */
  78051. export enum PoseEnabledControllerType {
  78052. /**
  78053. * HTC Vive
  78054. */
  78055. VIVE = 0,
  78056. /**
  78057. * Oculus Rift
  78058. */
  78059. OCULUS = 1,
  78060. /**
  78061. * Windows mixed reality
  78062. */
  78063. WINDOWS = 2,
  78064. /**
  78065. * Samsung gear VR
  78066. */
  78067. GEAR_VR = 3,
  78068. /**
  78069. * Google Daydream
  78070. */
  78071. DAYDREAM = 4,
  78072. /**
  78073. * Generic
  78074. */
  78075. GENERIC = 5
  78076. }
  78077. /**
  78078. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78079. */
  78080. export interface MutableGamepadButton {
  78081. /**
  78082. * Value of the button/trigger
  78083. */
  78084. value: number;
  78085. /**
  78086. * If the button/trigger is currently touched
  78087. */
  78088. touched: boolean;
  78089. /**
  78090. * If the button/trigger is currently pressed
  78091. */
  78092. pressed: boolean;
  78093. }
  78094. /**
  78095. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78096. * @hidden
  78097. */
  78098. export interface ExtendedGamepadButton extends GamepadButton {
  78099. /**
  78100. * If the button/trigger is currently pressed
  78101. */
  78102. readonly pressed: boolean;
  78103. /**
  78104. * If the button/trigger is currently touched
  78105. */
  78106. readonly touched: boolean;
  78107. /**
  78108. * Value of the button/trigger
  78109. */
  78110. readonly value: number;
  78111. }
  78112. /** @hidden */
  78113. export interface _GamePadFactory {
  78114. /**
  78115. * Returns wether or not the current gamepad can be created for this type of controller.
  78116. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78117. * @returns true if it can be created, otherwise false
  78118. */
  78119. canCreate(gamepadInfo: any): boolean;
  78120. /**
  78121. * Creates a new instance of the Gamepad.
  78122. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78123. * @returns the new gamepad instance
  78124. */
  78125. create(gamepadInfo: any): Gamepad;
  78126. }
  78127. /**
  78128. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78129. */
  78130. export class PoseEnabledControllerHelper {
  78131. /** @hidden */
  78132. static _ControllerFactories: _GamePadFactory[];
  78133. /** @hidden */
  78134. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78135. /**
  78136. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78137. * @param vrGamepad the gamepad to initialized
  78138. * @returns a vr controller of the type the gamepad identified as
  78139. */
  78140. static InitiateController(vrGamepad: any): Gamepad;
  78141. }
  78142. /**
  78143. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78144. */
  78145. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78146. /**
  78147. * If the controller is used in a webXR session
  78148. */
  78149. isXR: boolean;
  78150. private _deviceRoomPosition;
  78151. private _deviceRoomRotationQuaternion;
  78152. /**
  78153. * The device position in babylon space
  78154. */
  78155. devicePosition: Vector3;
  78156. /**
  78157. * The device rotation in babylon space
  78158. */
  78159. deviceRotationQuaternion: Quaternion;
  78160. /**
  78161. * The scale factor of the device in babylon space
  78162. */
  78163. deviceScaleFactor: number;
  78164. /**
  78165. * (Likely devicePosition should be used instead) The device position in its room space
  78166. */
  78167. position: Vector3;
  78168. /**
  78169. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78170. */
  78171. rotationQuaternion: Quaternion;
  78172. /**
  78173. * The type of controller (Eg. Windows mixed reality)
  78174. */
  78175. controllerType: PoseEnabledControllerType;
  78176. protected _calculatedPosition: Vector3;
  78177. private _calculatedRotation;
  78178. /**
  78179. * The raw pose from the device
  78180. */
  78181. rawPose: DevicePose;
  78182. private _trackPosition;
  78183. private _maxRotationDistFromHeadset;
  78184. private _draggedRoomRotation;
  78185. /**
  78186. * @hidden
  78187. */
  78188. _disableTrackPosition(fixedPosition: Vector3): void;
  78189. /**
  78190. * Internal, the mesh attached to the controller
  78191. * @hidden
  78192. */
  78193. _mesh: Nullable<AbstractMesh>;
  78194. private _poseControlledCamera;
  78195. private _leftHandSystemQuaternion;
  78196. /**
  78197. * Internal, matrix used to convert room space to babylon space
  78198. * @hidden
  78199. */
  78200. _deviceToWorld: Matrix;
  78201. /**
  78202. * Node to be used when casting a ray from the controller
  78203. * @hidden
  78204. */
  78205. _pointingPoseNode: Nullable<TransformNode>;
  78206. /**
  78207. * Name of the child mesh that can be used to cast a ray from the controller
  78208. */
  78209. static readonly POINTING_POSE: string;
  78210. /**
  78211. * Creates a new PoseEnabledController from a gamepad
  78212. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78213. */
  78214. constructor(browserGamepad: any);
  78215. private _workingMatrix;
  78216. /**
  78217. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78218. */
  78219. update(): void;
  78220. /**
  78221. * Updates only the pose device and mesh without doing any button event checking
  78222. */
  78223. protected _updatePoseAndMesh(): void;
  78224. /**
  78225. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78226. * @param poseData raw pose fromthe device
  78227. */
  78228. updateFromDevice(poseData: DevicePose): void;
  78229. /**
  78230. * @hidden
  78231. */
  78232. _meshAttachedObservable: Observable<AbstractMesh>;
  78233. /**
  78234. * Attaches a mesh to the controller
  78235. * @param mesh the mesh to be attached
  78236. */
  78237. attachToMesh(mesh: AbstractMesh): void;
  78238. /**
  78239. * Attaches the controllers mesh to a camera
  78240. * @param camera the camera the mesh should be attached to
  78241. */
  78242. attachToPoseControlledCamera(camera: TargetCamera): void;
  78243. /**
  78244. * Disposes of the controller
  78245. */
  78246. dispose(): void;
  78247. /**
  78248. * The mesh that is attached to the controller
  78249. */
  78250. readonly mesh: Nullable<AbstractMesh>;
  78251. /**
  78252. * Gets the ray of the controller in the direction the controller is pointing
  78253. * @param length the length the resulting ray should be
  78254. * @returns a ray in the direction the controller is pointing
  78255. */
  78256. getForwardRay(length?: number): Ray;
  78257. }
  78258. }
  78259. declare module BABYLON {
  78260. /**
  78261. * Defines the WebVRController object that represents controllers tracked in 3D space
  78262. */
  78263. export abstract class WebVRController extends PoseEnabledController {
  78264. /**
  78265. * Internal, the default controller model for the controller
  78266. */
  78267. protected _defaultModel: AbstractMesh;
  78268. /**
  78269. * Fired when the trigger state has changed
  78270. */
  78271. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78272. /**
  78273. * Fired when the main button state has changed
  78274. */
  78275. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78276. /**
  78277. * Fired when the secondary button state has changed
  78278. */
  78279. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78280. /**
  78281. * Fired when the pad state has changed
  78282. */
  78283. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78284. /**
  78285. * Fired when controllers stick values have changed
  78286. */
  78287. onPadValuesChangedObservable: Observable<StickValues>;
  78288. /**
  78289. * Array of button availible on the controller
  78290. */
  78291. protected _buttons: Array<MutableGamepadButton>;
  78292. private _onButtonStateChange;
  78293. /**
  78294. * Fired when a controller button's state has changed
  78295. * @param callback the callback containing the button that was modified
  78296. */
  78297. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78298. /**
  78299. * X and Y axis corresponding to the controllers joystick
  78300. */
  78301. pad: StickValues;
  78302. /**
  78303. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78304. */
  78305. hand: string;
  78306. /**
  78307. * The default controller model for the controller
  78308. */
  78309. readonly defaultModel: AbstractMesh;
  78310. /**
  78311. * Creates a new WebVRController from a gamepad
  78312. * @param vrGamepad the gamepad that the WebVRController should be created from
  78313. */
  78314. constructor(vrGamepad: any);
  78315. /**
  78316. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78317. */
  78318. update(): void;
  78319. /**
  78320. * Function to be called when a button is modified
  78321. */
  78322. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78323. /**
  78324. * Loads a mesh and attaches it to the controller
  78325. * @param scene the scene the mesh should be added to
  78326. * @param meshLoaded callback for when the mesh has been loaded
  78327. */
  78328. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78329. private _setButtonValue;
  78330. private _changes;
  78331. private _checkChanges;
  78332. /**
  78333. * Disposes of th webVRCOntroller
  78334. */
  78335. dispose(): void;
  78336. }
  78337. }
  78338. declare module BABYLON {
  78339. /**
  78340. * The HemisphericLight simulates the ambient environment light,
  78341. * so the passed direction is the light reflection direction, not the incoming direction.
  78342. */
  78343. export class HemisphericLight extends Light {
  78344. /**
  78345. * The groundColor is the light in the opposite direction to the one specified during creation.
  78346. * 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.
  78347. */
  78348. groundColor: Color3;
  78349. /**
  78350. * The light reflection direction, not the incoming direction.
  78351. */
  78352. direction: Vector3;
  78353. /**
  78354. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78355. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78356. * The HemisphericLight can't cast shadows.
  78357. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78358. * @param name The friendly name of the light
  78359. * @param direction The direction of the light reflection
  78360. * @param scene The scene the light belongs to
  78361. */
  78362. constructor(name: string, direction: Vector3, scene: Scene);
  78363. protected _buildUniformLayout(): void;
  78364. /**
  78365. * Returns the string "HemisphericLight".
  78366. * @return The class name
  78367. */
  78368. getClassName(): string;
  78369. /**
  78370. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78371. * Returns the updated direction.
  78372. * @param target The target the direction should point to
  78373. * @return The computed direction
  78374. */
  78375. setDirectionToTarget(target: Vector3): Vector3;
  78376. /**
  78377. * Returns the shadow generator associated to the light.
  78378. * @returns Always null for hemispheric lights because it does not support shadows.
  78379. */
  78380. getShadowGenerator(): Nullable<IShadowGenerator>;
  78381. /**
  78382. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78383. * @param effect The effect to update
  78384. * @param lightIndex The index of the light in the effect to update
  78385. * @returns The hemispheric light
  78386. */
  78387. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78388. /**
  78389. * Computes the world matrix of the node
  78390. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78391. * @param useWasUpdatedFlag defines a reserved property
  78392. * @returns the world matrix
  78393. */
  78394. computeWorldMatrix(): Matrix;
  78395. /**
  78396. * Returns the integer 3.
  78397. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78398. */
  78399. getTypeID(): number;
  78400. /**
  78401. * Prepares the list of defines specific to the light type.
  78402. * @param defines the list of defines
  78403. * @param lightIndex defines the index of the light for the effect
  78404. */
  78405. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78406. }
  78407. }
  78408. declare module BABYLON {
  78409. /** @hidden */
  78410. export var vrMultiviewToSingleviewPixelShader: {
  78411. name: string;
  78412. shader: string;
  78413. };
  78414. }
  78415. declare module BABYLON {
  78416. /**
  78417. * Renders to multiple views with a single draw call
  78418. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78419. */
  78420. export class MultiviewRenderTarget extends RenderTargetTexture {
  78421. /**
  78422. * Creates a multiview render target
  78423. * @param scene scene used with the render target
  78424. * @param size the size of the render target (used for each view)
  78425. */
  78426. constructor(scene: Scene, size?: number | {
  78427. width: number;
  78428. height: number;
  78429. } | {
  78430. ratio: number;
  78431. });
  78432. /**
  78433. * @hidden
  78434. * @param faceIndex the face index, if its a cube texture
  78435. */
  78436. _bindFrameBuffer(faceIndex?: number): void;
  78437. /**
  78438. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78439. * @returns the view count
  78440. */
  78441. getViewCount(): number;
  78442. }
  78443. }
  78444. declare module BABYLON {
  78445. /**
  78446. * Reprasents a camera frustum
  78447. */
  78448. export class Frustum {
  78449. /**
  78450. * Gets the planes representing the frustum
  78451. * @param transform matrix to be applied to the returned planes
  78452. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78453. */
  78454. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78455. /**
  78456. * Gets the near frustum plane transformed by the transform matrix
  78457. * @param transform transformation matrix to be applied to the resulting frustum plane
  78458. * @param frustumPlane the resuling frustum plane
  78459. */
  78460. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78461. /**
  78462. * Gets the far frustum plane transformed by the transform matrix
  78463. * @param transform transformation matrix to be applied to the resulting frustum plane
  78464. * @param frustumPlane the resuling frustum plane
  78465. */
  78466. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78467. /**
  78468. * Gets the left frustum plane transformed by the transform matrix
  78469. * @param transform transformation matrix to be applied to the resulting frustum plane
  78470. * @param frustumPlane the resuling frustum plane
  78471. */
  78472. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78473. /**
  78474. * Gets the right frustum plane transformed by the transform matrix
  78475. * @param transform transformation matrix to be applied to the resulting frustum plane
  78476. * @param frustumPlane the resuling frustum plane
  78477. */
  78478. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78479. /**
  78480. * Gets the top frustum plane transformed by the transform matrix
  78481. * @param transform transformation matrix to be applied to the resulting frustum plane
  78482. * @param frustumPlane the resuling frustum plane
  78483. */
  78484. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78485. /**
  78486. * Gets the bottom frustum plane transformed by the transform matrix
  78487. * @param transform transformation matrix to be applied to the resulting frustum plane
  78488. * @param frustumPlane the resuling frustum plane
  78489. */
  78490. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78491. /**
  78492. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78493. * @param transform transformation matrix to be applied to the resulting frustum planes
  78494. * @param frustumPlanes the resuling frustum planes
  78495. */
  78496. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78497. }
  78498. }
  78499. declare module BABYLON {
  78500. interface Engine {
  78501. /**
  78502. * Creates a new multiview render target
  78503. * @param width defines the width of the texture
  78504. * @param height defines the height of the texture
  78505. * @returns the created multiview texture
  78506. */
  78507. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78508. /**
  78509. * Binds a multiview framebuffer to be drawn to
  78510. * @param multiviewTexture texture to bind
  78511. */
  78512. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78513. }
  78514. interface Camera {
  78515. /**
  78516. * @hidden
  78517. * 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)
  78518. */
  78519. _useMultiviewToSingleView: boolean;
  78520. /**
  78521. * @hidden
  78522. * 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)
  78523. */
  78524. _multiviewTexture: Nullable<RenderTargetTexture>;
  78525. /**
  78526. * @hidden
  78527. * ensures the multiview texture of the camera exists and has the specified width/height
  78528. * @param width height to set on the multiview texture
  78529. * @param height width to set on the multiview texture
  78530. */
  78531. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78532. }
  78533. interface Scene {
  78534. /** @hidden */
  78535. _transformMatrixR: Matrix;
  78536. /** @hidden */
  78537. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78538. /** @hidden */
  78539. _createMultiviewUbo(): void;
  78540. /** @hidden */
  78541. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78542. /** @hidden */
  78543. _renderMultiviewToSingleView(camera: Camera): void;
  78544. }
  78545. }
  78546. declare module BABYLON {
  78547. /**
  78548. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78549. * This will not be used for webXR as it supports displaying texture arrays directly
  78550. */
  78551. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78552. /**
  78553. * Initializes a VRMultiviewToSingleview
  78554. * @param name name of the post process
  78555. * @param camera camera to be applied to
  78556. * @param scaleFactor scaling factor to the size of the output texture
  78557. */
  78558. constructor(name: string, camera: Camera, scaleFactor: number);
  78559. }
  78560. }
  78561. declare module BABYLON {
  78562. interface Engine {
  78563. /** @hidden */
  78564. _vrDisplay: any;
  78565. /** @hidden */
  78566. _vrSupported: boolean;
  78567. /** @hidden */
  78568. _oldSize: Size;
  78569. /** @hidden */
  78570. _oldHardwareScaleFactor: number;
  78571. /** @hidden */
  78572. _vrExclusivePointerMode: boolean;
  78573. /** @hidden */
  78574. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78575. /** @hidden */
  78576. _onVRDisplayPointerRestricted: () => void;
  78577. /** @hidden */
  78578. _onVRDisplayPointerUnrestricted: () => void;
  78579. /** @hidden */
  78580. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78581. /** @hidden */
  78582. _onVrDisplayDisconnect: Nullable<() => void>;
  78583. /** @hidden */
  78584. _onVrDisplayPresentChange: Nullable<() => void>;
  78585. /**
  78586. * Observable signaled when VR display mode changes
  78587. */
  78588. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78589. /**
  78590. * Observable signaled when VR request present is complete
  78591. */
  78592. onVRRequestPresentComplete: Observable<boolean>;
  78593. /**
  78594. * Observable signaled when VR request present starts
  78595. */
  78596. onVRRequestPresentStart: Observable<Engine>;
  78597. /**
  78598. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78599. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78600. */
  78601. isInVRExclusivePointerMode: boolean;
  78602. /**
  78603. * Gets a boolean indicating if a webVR device was detected
  78604. * @returns true if a webVR device was detected
  78605. */
  78606. isVRDevicePresent(): boolean;
  78607. /**
  78608. * Gets the current webVR device
  78609. * @returns the current webVR device (or null)
  78610. */
  78611. getVRDevice(): any;
  78612. /**
  78613. * Initializes a webVR display and starts listening to display change events
  78614. * The onVRDisplayChangedObservable will be notified upon these changes
  78615. * @returns A promise containing a VRDisplay and if vr is supported
  78616. */
  78617. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78618. /** @hidden */
  78619. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78620. /**
  78621. * Call this function to switch to webVR mode
  78622. * Will do nothing if webVR is not supported or if there is no webVR device
  78623. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78624. */
  78625. enableVR(): void;
  78626. /** @hidden */
  78627. _onVRFullScreenTriggered(): void;
  78628. }
  78629. }
  78630. declare module BABYLON {
  78631. /**
  78632. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78633. * IMPORTANT!! The data is right-hand data.
  78634. * @export
  78635. * @interface DevicePose
  78636. */
  78637. export interface DevicePose {
  78638. /**
  78639. * The position of the device, values in array are [x,y,z].
  78640. */
  78641. readonly position: Nullable<Float32Array>;
  78642. /**
  78643. * The linearVelocity of the device, values in array are [x,y,z].
  78644. */
  78645. readonly linearVelocity: Nullable<Float32Array>;
  78646. /**
  78647. * The linearAcceleration of the device, values in array are [x,y,z].
  78648. */
  78649. readonly linearAcceleration: Nullable<Float32Array>;
  78650. /**
  78651. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78652. */
  78653. readonly orientation: Nullable<Float32Array>;
  78654. /**
  78655. * The angularVelocity of the device, values in array are [x,y,z].
  78656. */
  78657. readonly angularVelocity: Nullable<Float32Array>;
  78658. /**
  78659. * The angularAcceleration of the device, values in array are [x,y,z].
  78660. */
  78661. readonly angularAcceleration: Nullable<Float32Array>;
  78662. }
  78663. /**
  78664. * Interface representing a pose controlled object in Babylon.
  78665. * A pose controlled object has both regular pose values as well as pose values
  78666. * from an external device such as a VR head mounted display
  78667. */
  78668. export interface PoseControlled {
  78669. /**
  78670. * The position of the object in babylon space.
  78671. */
  78672. position: Vector3;
  78673. /**
  78674. * The rotation quaternion of the object in babylon space.
  78675. */
  78676. rotationQuaternion: Quaternion;
  78677. /**
  78678. * The position of the device in babylon space.
  78679. */
  78680. devicePosition?: Vector3;
  78681. /**
  78682. * The rotation quaternion of the device in babylon space.
  78683. */
  78684. deviceRotationQuaternion: Quaternion;
  78685. /**
  78686. * The raw pose coming from the device.
  78687. */
  78688. rawPose: Nullable<DevicePose>;
  78689. /**
  78690. * The scale of the device to be used when translating from device space to babylon space.
  78691. */
  78692. deviceScaleFactor: number;
  78693. /**
  78694. * Updates the poseControlled values based on the input device pose.
  78695. * @param poseData the pose data to update the object with
  78696. */
  78697. updateFromDevice(poseData: DevicePose): void;
  78698. }
  78699. /**
  78700. * Set of options to customize the webVRCamera
  78701. */
  78702. export interface WebVROptions {
  78703. /**
  78704. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78705. */
  78706. trackPosition?: boolean;
  78707. /**
  78708. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78709. */
  78710. positionScale?: number;
  78711. /**
  78712. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78713. */
  78714. displayName?: string;
  78715. /**
  78716. * Should the native controller meshes be initialized. (default: true)
  78717. */
  78718. controllerMeshes?: boolean;
  78719. /**
  78720. * Creating a default HemiLight only on controllers. (default: true)
  78721. */
  78722. defaultLightingOnControllers?: boolean;
  78723. /**
  78724. * If you don't want to use the default VR button of the helper. (default: false)
  78725. */
  78726. useCustomVRButton?: boolean;
  78727. /**
  78728. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78729. */
  78730. customVRButton?: HTMLButtonElement;
  78731. /**
  78732. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78733. */
  78734. rayLength?: number;
  78735. /**
  78736. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78737. */
  78738. defaultHeight?: number;
  78739. /**
  78740. * If multiview should be used if availible (default: false)
  78741. */
  78742. useMultiview?: boolean;
  78743. }
  78744. /**
  78745. * This represents a WebVR camera.
  78746. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78747. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78748. */
  78749. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78750. private webVROptions;
  78751. /**
  78752. * @hidden
  78753. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78754. */
  78755. _vrDevice: any;
  78756. /**
  78757. * The rawPose of the vrDevice.
  78758. */
  78759. rawPose: Nullable<DevicePose>;
  78760. private _onVREnabled;
  78761. private _specsVersion;
  78762. private _attached;
  78763. private _frameData;
  78764. protected _descendants: Array<Node>;
  78765. private _deviceRoomPosition;
  78766. /** @hidden */
  78767. _deviceRoomRotationQuaternion: Quaternion;
  78768. private _standingMatrix;
  78769. /**
  78770. * Represents device position in babylon space.
  78771. */
  78772. devicePosition: Vector3;
  78773. /**
  78774. * Represents device rotation in babylon space.
  78775. */
  78776. deviceRotationQuaternion: Quaternion;
  78777. /**
  78778. * The scale of the device to be used when translating from device space to babylon space.
  78779. */
  78780. deviceScaleFactor: number;
  78781. private _deviceToWorld;
  78782. private _worldToDevice;
  78783. /**
  78784. * References to the webVR controllers for the vrDevice.
  78785. */
  78786. controllers: Array<WebVRController>;
  78787. /**
  78788. * Emits an event when a controller is attached.
  78789. */
  78790. onControllersAttachedObservable: Observable<WebVRController[]>;
  78791. /**
  78792. * Emits an event when a controller's mesh has been loaded;
  78793. */
  78794. onControllerMeshLoadedObservable: Observable<WebVRController>;
  78795. /**
  78796. * Emits an event when the HMD's pose has been updated.
  78797. */
  78798. onPoseUpdatedFromDeviceObservable: Observable<any>;
  78799. private _poseSet;
  78800. /**
  78801. * If the rig cameras be used as parent instead of this camera.
  78802. */
  78803. rigParenting: boolean;
  78804. private _lightOnControllers;
  78805. private _defaultHeight?;
  78806. /**
  78807. * Instantiates a WebVRFreeCamera.
  78808. * @param name The name of the WebVRFreeCamera
  78809. * @param position The starting anchor position for the camera
  78810. * @param scene The scene the camera belongs to
  78811. * @param webVROptions a set of customizable options for the webVRCamera
  78812. */
  78813. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78814. /**
  78815. * Gets the device distance from the ground in meters.
  78816. * @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.
  78817. */
  78818. deviceDistanceToRoomGround(): number;
  78819. /**
  78820. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78821. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78822. */
  78823. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78824. /**
  78825. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78826. * @returns A promise with a boolean set to if the standing matrix is supported.
  78827. */
  78828. useStandingMatrixAsync(): Promise<boolean>;
  78829. /**
  78830. * Disposes the camera
  78831. */
  78832. dispose(): void;
  78833. /**
  78834. * Gets a vrController by name.
  78835. * @param name The name of the controller to retreive
  78836. * @returns the controller matching the name specified or null if not found
  78837. */
  78838. getControllerByName(name: string): Nullable<WebVRController>;
  78839. private _leftController;
  78840. /**
  78841. * The controller corresponding to the users left hand.
  78842. */
  78843. readonly leftController: Nullable<WebVRController>;
  78844. private _rightController;
  78845. /**
  78846. * The controller corresponding to the users right hand.
  78847. */
  78848. readonly rightController: Nullable<WebVRController>;
  78849. /**
  78850. * Casts a ray forward from the vrCamera's gaze.
  78851. * @param length Length of the ray (default: 100)
  78852. * @returns the ray corresponding to the gaze
  78853. */
  78854. getForwardRay(length?: number): Ray;
  78855. /**
  78856. * @hidden
  78857. * Updates the camera based on device's frame data
  78858. */
  78859. _checkInputs(): void;
  78860. /**
  78861. * Updates the poseControlled values based on the input device pose.
  78862. * @param poseData Pose coming from the device
  78863. */
  78864. updateFromDevice(poseData: DevicePose): void;
  78865. private _htmlElementAttached;
  78866. private _detachIfAttached;
  78867. /**
  78868. * WebVR's attach control will start broadcasting frames to the device.
  78869. * Note that in certain browsers (chrome for example) this function must be called
  78870. * within a user-interaction callback. Example:
  78871. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78872. *
  78873. * @param element html element to attach the vrDevice to
  78874. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78875. */
  78876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78877. /**
  78878. * Detaches the camera from the html element and disables VR
  78879. *
  78880. * @param element html element to detach from
  78881. */
  78882. detachControl(element: HTMLElement): void;
  78883. /**
  78884. * @returns the name of this class
  78885. */
  78886. getClassName(): string;
  78887. /**
  78888. * Calls resetPose on the vrDisplay
  78889. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78890. */
  78891. resetToCurrentRotation(): void;
  78892. /**
  78893. * @hidden
  78894. * Updates the rig cameras (left and right eye)
  78895. */
  78896. _updateRigCameras(): void;
  78897. private _workingVector;
  78898. private _oneVector;
  78899. private _workingMatrix;
  78900. private updateCacheCalled;
  78901. private _correctPositionIfNotTrackPosition;
  78902. /**
  78903. * @hidden
  78904. * Updates the cached values of the camera
  78905. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78906. */
  78907. _updateCache(ignoreParentClass?: boolean): void;
  78908. /**
  78909. * @hidden
  78910. * Get current device position in babylon world
  78911. */
  78912. _computeDevicePosition(): void;
  78913. /**
  78914. * Updates the current device position and rotation in the babylon world
  78915. */
  78916. update(): void;
  78917. /**
  78918. * @hidden
  78919. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78920. * @returns an identity matrix
  78921. */
  78922. _getViewMatrix(): Matrix;
  78923. private _tmpMatrix;
  78924. /**
  78925. * This function is called by the two RIG cameras.
  78926. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78927. * @hidden
  78928. */
  78929. _getWebVRViewMatrix(): Matrix;
  78930. /** @hidden */
  78931. _getWebVRProjectionMatrix(): Matrix;
  78932. private _onGamepadConnectedObserver;
  78933. private _onGamepadDisconnectedObserver;
  78934. private _updateCacheWhenTrackingDisabledObserver;
  78935. /**
  78936. * Initializes the controllers and their meshes
  78937. */
  78938. initControllers(): void;
  78939. }
  78940. }
  78941. declare module BABYLON {
  78942. /**
  78943. * Size options for a post process
  78944. */
  78945. export type PostProcessOptions = {
  78946. width: number;
  78947. height: number;
  78948. };
  78949. /**
  78950. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78951. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78952. */
  78953. export class PostProcess {
  78954. /** Name of the PostProcess. */
  78955. name: string;
  78956. /**
  78957. * Gets or sets the unique id of the post process
  78958. */
  78959. uniqueId: number;
  78960. /**
  78961. * Width of the texture to apply the post process on
  78962. */
  78963. width: number;
  78964. /**
  78965. * Height of the texture to apply the post process on
  78966. */
  78967. height: number;
  78968. /**
  78969. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78970. * @hidden
  78971. */
  78972. _outputTexture: Nullable<InternalTexture>;
  78973. /**
  78974. * Sampling mode used by the shader
  78975. * See https://doc.babylonjs.com/classes/3.1/texture
  78976. */
  78977. renderTargetSamplingMode: number;
  78978. /**
  78979. * Clear color to use when screen clearing
  78980. */
  78981. clearColor: Color4;
  78982. /**
  78983. * If the buffer needs to be cleared before applying the post process. (default: true)
  78984. * Should be set to false if shader will overwrite all previous pixels.
  78985. */
  78986. autoClear: boolean;
  78987. /**
  78988. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78989. */
  78990. alphaMode: number;
  78991. /**
  78992. * Sets the setAlphaBlendConstants of the babylon engine
  78993. */
  78994. alphaConstants: Color4;
  78995. /**
  78996. * Animations to be used for the post processing
  78997. */
  78998. animations: Animation[];
  78999. /**
  79000. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79001. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79002. */
  79003. enablePixelPerfectMode: boolean;
  79004. /**
  79005. * Force the postprocess to be applied without taking in account viewport
  79006. */
  79007. forceFullscreenViewport: boolean;
  79008. /**
  79009. * List of inspectable custom properties (used by the Inspector)
  79010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79011. */
  79012. inspectableCustomProperties: IInspectable[];
  79013. /**
  79014. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79015. *
  79016. * | Value | Type | Description |
  79017. * | ----- | ----------------------------------- | ----------- |
  79018. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79019. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79020. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79021. *
  79022. */
  79023. scaleMode: number;
  79024. /**
  79025. * Force textures to be a power of two (default: false)
  79026. */
  79027. alwaysForcePOT: boolean;
  79028. private _samples;
  79029. /**
  79030. * Number of sample textures (default: 1)
  79031. */
  79032. samples: number;
  79033. /**
  79034. * Modify the scale of the post process to be the same as the viewport (default: false)
  79035. */
  79036. adaptScaleToCurrentViewport: boolean;
  79037. private _camera;
  79038. private _scene;
  79039. private _engine;
  79040. private _options;
  79041. private _reusable;
  79042. private _textureType;
  79043. /**
  79044. * Smart array of input and output textures for the post process.
  79045. * @hidden
  79046. */
  79047. _textures: SmartArray<InternalTexture>;
  79048. /**
  79049. * The index in _textures that corresponds to the output texture.
  79050. * @hidden
  79051. */
  79052. _currentRenderTextureInd: number;
  79053. private _effect;
  79054. private _samplers;
  79055. private _fragmentUrl;
  79056. private _vertexUrl;
  79057. private _parameters;
  79058. private _scaleRatio;
  79059. protected _indexParameters: any;
  79060. private _shareOutputWithPostProcess;
  79061. private _texelSize;
  79062. private _forcedOutputTexture;
  79063. /**
  79064. * Returns the fragment url or shader name used in the post process.
  79065. * @returns the fragment url or name in the shader store.
  79066. */
  79067. getEffectName(): string;
  79068. /**
  79069. * An event triggered when the postprocess is activated.
  79070. */
  79071. onActivateObservable: Observable<Camera>;
  79072. private _onActivateObserver;
  79073. /**
  79074. * A function that is added to the onActivateObservable
  79075. */
  79076. onActivate: Nullable<(camera: Camera) => void>;
  79077. /**
  79078. * An event triggered when the postprocess changes its size.
  79079. */
  79080. onSizeChangedObservable: Observable<PostProcess>;
  79081. private _onSizeChangedObserver;
  79082. /**
  79083. * A function that is added to the onSizeChangedObservable
  79084. */
  79085. onSizeChanged: (postProcess: PostProcess) => void;
  79086. /**
  79087. * An event triggered when the postprocess applies its effect.
  79088. */
  79089. onApplyObservable: Observable<Effect>;
  79090. private _onApplyObserver;
  79091. /**
  79092. * A function that is added to the onApplyObservable
  79093. */
  79094. onApply: (effect: Effect) => void;
  79095. /**
  79096. * An event triggered before rendering the postprocess
  79097. */
  79098. onBeforeRenderObservable: Observable<Effect>;
  79099. private _onBeforeRenderObserver;
  79100. /**
  79101. * A function that is added to the onBeforeRenderObservable
  79102. */
  79103. onBeforeRender: (effect: Effect) => void;
  79104. /**
  79105. * An event triggered after rendering the postprocess
  79106. */
  79107. onAfterRenderObservable: Observable<Effect>;
  79108. private _onAfterRenderObserver;
  79109. /**
  79110. * A function that is added to the onAfterRenderObservable
  79111. */
  79112. onAfterRender: (efect: Effect) => void;
  79113. /**
  79114. * 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
  79115. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79116. */
  79117. inputTexture: InternalTexture;
  79118. /**
  79119. * Gets the camera which post process is applied to.
  79120. * @returns The camera the post process is applied to.
  79121. */
  79122. getCamera(): Camera;
  79123. /**
  79124. * Gets the texel size of the postprocess.
  79125. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79126. */
  79127. readonly texelSize: Vector2;
  79128. /**
  79129. * Creates a new instance PostProcess
  79130. * @param name The name of the PostProcess.
  79131. * @param fragmentUrl The url of the fragment shader to be used.
  79132. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79133. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79134. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79135. * @param camera The camera to apply the render pass to.
  79136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79137. * @param engine The engine which the post process will be applied. (default: current engine)
  79138. * @param reusable If the post process can be reused on the same frame. (default: false)
  79139. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79140. * @param textureType Type of textures used when performing the post process. (default: 0)
  79141. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79142. * @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
  79143. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79144. */
  79145. constructor(
  79146. /** Name of the PostProcess. */
  79147. 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);
  79148. /**
  79149. * Gets a string idenfifying the name of the class
  79150. * @returns "PostProcess" string
  79151. */
  79152. getClassName(): string;
  79153. /**
  79154. * Gets the engine which this post process belongs to.
  79155. * @returns The engine the post process was enabled with.
  79156. */
  79157. getEngine(): Engine;
  79158. /**
  79159. * The effect that is created when initializing the post process.
  79160. * @returns The created effect corresponding the the postprocess.
  79161. */
  79162. getEffect(): Effect;
  79163. /**
  79164. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79165. * @param postProcess The post process to share the output with.
  79166. * @returns This post process.
  79167. */
  79168. shareOutputWith(postProcess: PostProcess): PostProcess;
  79169. /**
  79170. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79171. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79172. */
  79173. useOwnOutput(): void;
  79174. /**
  79175. * Updates the effect with the current post process compile time values and recompiles the shader.
  79176. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79177. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79178. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79179. * @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
  79180. * @param onCompiled Called when the shader has been compiled.
  79181. * @param onError Called if there is an error when compiling a shader.
  79182. */
  79183. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79184. /**
  79185. * The post process is reusable if it can be used multiple times within one frame.
  79186. * @returns If the post process is reusable
  79187. */
  79188. isReusable(): boolean;
  79189. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79190. markTextureDirty(): void;
  79191. /**
  79192. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79193. * 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.
  79194. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79195. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79196. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79197. * @returns The target texture that was bound to be written to.
  79198. */
  79199. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79200. /**
  79201. * If the post process is supported.
  79202. */
  79203. readonly isSupported: boolean;
  79204. /**
  79205. * The aspect ratio of the output texture.
  79206. */
  79207. readonly aspectRatio: number;
  79208. /**
  79209. * Get a value indicating if the post-process is ready to be used
  79210. * @returns true if the post-process is ready (shader is compiled)
  79211. */
  79212. isReady(): boolean;
  79213. /**
  79214. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79215. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79216. */
  79217. apply(): Nullable<Effect>;
  79218. private _disposeTextures;
  79219. /**
  79220. * Disposes the post process.
  79221. * @param camera The camera to dispose the post process on.
  79222. */
  79223. dispose(camera?: Camera): void;
  79224. }
  79225. }
  79226. declare module BABYLON {
  79227. /** @hidden */
  79228. export var kernelBlurVaryingDeclaration: {
  79229. name: string;
  79230. shader: string;
  79231. };
  79232. }
  79233. declare module BABYLON {
  79234. /** @hidden */
  79235. export var kernelBlurFragment: {
  79236. name: string;
  79237. shader: string;
  79238. };
  79239. }
  79240. declare module BABYLON {
  79241. /** @hidden */
  79242. export var kernelBlurFragment2: {
  79243. name: string;
  79244. shader: string;
  79245. };
  79246. }
  79247. declare module BABYLON {
  79248. /** @hidden */
  79249. export var kernelBlurPixelShader: {
  79250. name: string;
  79251. shader: string;
  79252. };
  79253. }
  79254. declare module BABYLON {
  79255. /** @hidden */
  79256. export var kernelBlurVertex: {
  79257. name: string;
  79258. shader: string;
  79259. };
  79260. }
  79261. declare module BABYLON {
  79262. /** @hidden */
  79263. export var kernelBlurVertexShader: {
  79264. name: string;
  79265. shader: string;
  79266. };
  79267. }
  79268. declare module BABYLON {
  79269. /**
  79270. * The Blur Post Process which blurs an image based on a kernel and direction.
  79271. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79272. */
  79273. export class BlurPostProcess extends PostProcess {
  79274. /** The direction in which to blur the image. */
  79275. direction: Vector2;
  79276. private blockCompilation;
  79277. protected _kernel: number;
  79278. protected _idealKernel: number;
  79279. protected _packedFloat: boolean;
  79280. private _staticDefines;
  79281. /**
  79282. * Sets the length in pixels of the blur sample region
  79283. */
  79284. /**
  79285. * Gets the length in pixels of the blur sample region
  79286. */
  79287. kernel: number;
  79288. /**
  79289. * Sets wether or not the blur needs to unpack/repack floats
  79290. */
  79291. /**
  79292. * Gets wether or not the blur is unpacking/repacking floats
  79293. */
  79294. packedFloat: boolean;
  79295. /**
  79296. * Creates a new instance BlurPostProcess
  79297. * @param name The name of the effect.
  79298. * @param direction The direction in which to blur the image.
  79299. * @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.
  79300. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79301. * @param camera The camera to apply the render pass to.
  79302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79303. * @param engine The engine which the post process will be applied. (default: current engine)
  79304. * @param reusable If the post process can be reused on the same frame. (default: false)
  79305. * @param textureType Type of textures used when performing the post process. (default: 0)
  79306. * @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)
  79307. */
  79308. constructor(name: string,
  79309. /** The direction in which to blur the image. */
  79310. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79311. /**
  79312. * Updates the effect with the current post process compile time values and recompiles the shader.
  79313. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79314. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79315. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79316. * @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
  79317. * @param onCompiled Called when the shader has been compiled.
  79318. * @param onError Called if there is an error when compiling a shader.
  79319. */
  79320. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79321. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79322. /**
  79323. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79324. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79325. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79326. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79327. * The gaps between physical kernels are compensated for in the weighting of the samples
  79328. * @param idealKernel Ideal blur kernel.
  79329. * @return Nearest best kernel.
  79330. */
  79331. protected _nearestBestKernel(idealKernel: number): number;
  79332. /**
  79333. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79334. * @param x The point on the Gaussian distribution to sample.
  79335. * @return the value of the Gaussian function at x.
  79336. */
  79337. protected _gaussianWeight(x: number): number;
  79338. /**
  79339. * Generates a string that can be used as a floating point number in GLSL.
  79340. * @param x Value to print.
  79341. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79342. * @return GLSL float string.
  79343. */
  79344. protected _glslFloat(x: number, decimalFigures?: number): string;
  79345. }
  79346. }
  79347. declare module BABYLON {
  79348. /**
  79349. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79350. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79351. * You can then easily use it as a reflectionTexture on a flat surface.
  79352. * In case the surface is not a plane, please consider relying on reflection probes.
  79353. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79354. */
  79355. export class MirrorTexture extends RenderTargetTexture {
  79356. private scene;
  79357. /**
  79358. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79359. * 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.
  79360. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79361. */
  79362. mirrorPlane: Plane;
  79363. /**
  79364. * Define the blur ratio used to blur the reflection if needed.
  79365. */
  79366. blurRatio: number;
  79367. /**
  79368. * Define the adaptive blur kernel used to blur the reflection if needed.
  79369. * This will autocompute the closest best match for the `blurKernel`
  79370. */
  79371. adaptiveBlurKernel: number;
  79372. /**
  79373. * Define the blur kernel used to blur the reflection if needed.
  79374. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79375. */
  79376. blurKernel: number;
  79377. /**
  79378. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79379. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79380. */
  79381. blurKernelX: number;
  79382. /**
  79383. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79384. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79385. */
  79386. blurKernelY: number;
  79387. private _autoComputeBlurKernel;
  79388. protected _onRatioRescale(): void;
  79389. private _updateGammaSpace;
  79390. private _imageProcessingConfigChangeObserver;
  79391. private _transformMatrix;
  79392. private _mirrorMatrix;
  79393. private _savedViewMatrix;
  79394. private _blurX;
  79395. private _blurY;
  79396. private _adaptiveBlurKernel;
  79397. private _blurKernelX;
  79398. private _blurKernelY;
  79399. private _blurRatio;
  79400. /**
  79401. * Instantiates a Mirror Texture.
  79402. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79403. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79404. * You can then easily use it as a reflectionTexture on a flat surface.
  79405. * In case the surface is not a plane, please consider relying on reflection probes.
  79406. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79407. * @param name
  79408. * @param size
  79409. * @param scene
  79410. * @param generateMipMaps
  79411. * @param type
  79412. * @param samplingMode
  79413. * @param generateDepthBuffer
  79414. */
  79415. constructor(name: string, size: number | {
  79416. width: number;
  79417. height: number;
  79418. } | {
  79419. ratio: number;
  79420. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79421. private _preparePostProcesses;
  79422. /**
  79423. * Clone the mirror texture.
  79424. * @returns the cloned texture
  79425. */
  79426. clone(): MirrorTexture;
  79427. /**
  79428. * Serialize the texture to a JSON representation you could use in Parse later on
  79429. * @returns the serialized JSON representation
  79430. */
  79431. serialize(): any;
  79432. /**
  79433. * Dispose the texture and release its associated resources.
  79434. */
  79435. dispose(): void;
  79436. }
  79437. }
  79438. declare module BABYLON {
  79439. /**
  79440. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79441. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79442. */
  79443. export class Texture extends BaseTexture {
  79444. /** @hidden */
  79445. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79446. /** @hidden */
  79447. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79448. /** @hidden */
  79449. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79450. /** nearest is mag = nearest and min = nearest and mip = linear */
  79451. static readonly NEAREST_SAMPLINGMODE: number;
  79452. /** nearest is mag = nearest and min = nearest and mip = linear */
  79453. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79454. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79455. static readonly BILINEAR_SAMPLINGMODE: number;
  79456. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79457. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79458. /** Trilinear is mag = linear and min = linear and mip = linear */
  79459. static readonly TRILINEAR_SAMPLINGMODE: number;
  79460. /** Trilinear is mag = linear and min = linear and mip = linear */
  79461. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79462. /** mag = nearest and min = nearest and mip = nearest */
  79463. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79464. /** mag = nearest and min = linear and mip = nearest */
  79465. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79466. /** mag = nearest and min = linear and mip = linear */
  79467. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79468. /** mag = nearest and min = linear and mip = none */
  79469. static readonly NEAREST_LINEAR: number;
  79470. /** mag = nearest and min = nearest and mip = none */
  79471. static readonly NEAREST_NEAREST: number;
  79472. /** mag = linear and min = nearest and mip = nearest */
  79473. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79474. /** mag = linear and min = nearest and mip = linear */
  79475. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79476. /** mag = linear and min = linear and mip = none */
  79477. static readonly LINEAR_LINEAR: number;
  79478. /** mag = linear and min = nearest and mip = none */
  79479. static readonly LINEAR_NEAREST: number;
  79480. /** Explicit coordinates mode */
  79481. static readonly EXPLICIT_MODE: number;
  79482. /** Spherical coordinates mode */
  79483. static readonly SPHERICAL_MODE: number;
  79484. /** Planar coordinates mode */
  79485. static readonly PLANAR_MODE: number;
  79486. /** Cubic coordinates mode */
  79487. static readonly CUBIC_MODE: number;
  79488. /** Projection coordinates mode */
  79489. static readonly PROJECTION_MODE: number;
  79490. /** Inverse Cubic coordinates mode */
  79491. static readonly SKYBOX_MODE: number;
  79492. /** Inverse Cubic coordinates mode */
  79493. static readonly INVCUBIC_MODE: number;
  79494. /** Equirectangular coordinates mode */
  79495. static readonly EQUIRECTANGULAR_MODE: number;
  79496. /** Equirectangular Fixed coordinates mode */
  79497. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79498. /** Equirectangular Fixed Mirrored coordinates mode */
  79499. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79500. /** Texture is not repeating outside of 0..1 UVs */
  79501. static readonly CLAMP_ADDRESSMODE: number;
  79502. /** Texture is repeating outside of 0..1 UVs */
  79503. static readonly WRAP_ADDRESSMODE: number;
  79504. /** Texture is repeating and mirrored */
  79505. static readonly MIRROR_ADDRESSMODE: number;
  79506. /**
  79507. * 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
  79508. */
  79509. static UseSerializedUrlIfAny: boolean;
  79510. /**
  79511. * Define the url of the texture.
  79512. */
  79513. url: Nullable<string>;
  79514. /**
  79515. * Define an offset on the texture to offset the u coordinates of the UVs
  79516. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79517. */
  79518. uOffset: number;
  79519. /**
  79520. * Define an offset on the texture to offset the v coordinates of the UVs
  79521. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79522. */
  79523. vOffset: number;
  79524. /**
  79525. * Define an offset on the texture to scale the u coordinates of the UVs
  79526. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79527. */
  79528. uScale: number;
  79529. /**
  79530. * Define an offset on the texture to scale the v coordinates of the UVs
  79531. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79532. */
  79533. vScale: number;
  79534. /**
  79535. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79536. * @see http://doc.babylonjs.com/how_to/more_materials
  79537. */
  79538. uAng: number;
  79539. /**
  79540. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79541. * @see http://doc.babylonjs.com/how_to/more_materials
  79542. */
  79543. vAng: number;
  79544. /**
  79545. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79546. * @see http://doc.babylonjs.com/how_to/more_materials
  79547. */
  79548. wAng: number;
  79549. /**
  79550. * Defines the center of rotation (U)
  79551. */
  79552. uRotationCenter: number;
  79553. /**
  79554. * Defines the center of rotation (V)
  79555. */
  79556. vRotationCenter: number;
  79557. /**
  79558. * Defines the center of rotation (W)
  79559. */
  79560. wRotationCenter: number;
  79561. /**
  79562. * Are mip maps generated for this texture or not.
  79563. */
  79564. readonly noMipmap: boolean;
  79565. /**
  79566. * List of inspectable custom properties (used by the Inspector)
  79567. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79568. */
  79569. inspectableCustomProperties: Nullable<IInspectable[]>;
  79570. private _noMipmap;
  79571. /** @hidden */
  79572. _invertY: boolean;
  79573. private _rowGenerationMatrix;
  79574. private _cachedTextureMatrix;
  79575. private _projectionModeMatrix;
  79576. private _t0;
  79577. private _t1;
  79578. private _t2;
  79579. private _cachedUOffset;
  79580. private _cachedVOffset;
  79581. private _cachedUScale;
  79582. private _cachedVScale;
  79583. private _cachedUAng;
  79584. private _cachedVAng;
  79585. private _cachedWAng;
  79586. private _cachedProjectionMatrixId;
  79587. private _cachedCoordinatesMode;
  79588. /** @hidden */
  79589. protected _initialSamplingMode: number;
  79590. /** @hidden */
  79591. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79592. private _deleteBuffer;
  79593. protected _format: Nullable<number>;
  79594. private _delayedOnLoad;
  79595. private _delayedOnError;
  79596. /**
  79597. * Observable triggered once the texture has been loaded.
  79598. */
  79599. onLoadObservable: Observable<Texture>;
  79600. protected _isBlocking: boolean;
  79601. /**
  79602. * Is the texture preventing material to render while loading.
  79603. * If false, a default texture will be used instead of the loading one during the preparation step.
  79604. */
  79605. isBlocking: boolean;
  79606. /**
  79607. * Get the current sampling mode associated with the texture.
  79608. */
  79609. readonly samplingMode: number;
  79610. /**
  79611. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79612. */
  79613. readonly invertY: boolean;
  79614. /**
  79615. * Instantiates a new texture.
  79616. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79617. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79618. * @param url define the url of the picture to load as a texture
  79619. * @param scene define the scene or engine the texture will belong to
  79620. * @param noMipmap define if the texture will require mip maps or not
  79621. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79622. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79623. * @param onLoad define a callback triggered when the texture has been loaded
  79624. * @param onError define a callback triggered when an error occurred during the loading session
  79625. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79626. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79627. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79628. */
  79629. 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);
  79630. /**
  79631. * Update the url (and optional buffer) of this texture if url was null during construction.
  79632. * @param url the url of the texture
  79633. * @param buffer the buffer of the texture (defaults to null)
  79634. * @param onLoad callback called when the texture is loaded (defaults to null)
  79635. */
  79636. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79637. /**
  79638. * Finish the loading sequence of a texture flagged as delayed load.
  79639. * @hidden
  79640. */
  79641. delayLoad(): void;
  79642. private _prepareRowForTextureGeneration;
  79643. /**
  79644. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79645. * @returns the transform matrix of the texture.
  79646. */
  79647. getTextureMatrix(): Matrix;
  79648. /**
  79649. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79650. * @returns The reflection texture transform
  79651. */
  79652. getReflectionTextureMatrix(): Matrix;
  79653. /**
  79654. * Clones the texture.
  79655. * @returns the cloned texture
  79656. */
  79657. clone(): Texture;
  79658. /**
  79659. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79660. * @returns The JSON representation of the texture
  79661. */
  79662. serialize(): any;
  79663. /**
  79664. * Get the current class name of the texture useful for serialization or dynamic coding.
  79665. * @returns "Texture"
  79666. */
  79667. getClassName(): string;
  79668. /**
  79669. * Dispose the texture and release its associated resources.
  79670. */
  79671. dispose(): void;
  79672. /**
  79673. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79674. * @param parsedTexture Define the JSON representation of the texture
  79675. * @param scene Define the scene the parsed texture should be instantiated in
  79676. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79677. * @returns The parsed texture if successful
  79678. */
  79679. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79680. /**
  79681. * Creates a texture from its base 64 representation.
  79682. * @param data Define the base64 payload without the data: prefix
  79683. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79684. * @param scene Define the scene the texture should belong to
  79685. * @param noMipmap Forces the texture to not create mip map information if true
  79686. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79687. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79688. * @param onLoad define a callback triggered when the texture has been loaded
  79689. * @param onError define a callback triggered when an error occurred during the loading session
  79690. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79691. * @returns the created texture
  79692. */
  79693. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79694. /**
  79695. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79696. * @param data Define the base64 payload without the data: prefix
  79697. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79698. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79699. * @param scene Define the scene the texture should belong to
  79700. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79701. * @param noMipmap Forces the texture to not create mip map information if true
  79702. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79703. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79704. * @param onLoad define a callback triggered when the texture has been loaded
  79705. * @param onError define a callback triggered when an error occurred during the loading session
  79706. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79707. * @returns the created texture
  79708. */
  79709. 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;
  79710. }
  79711. }
  79712. declare module BABYLON {
  79713. /**
  79714. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79715. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79716. */
  79717. export class PostProcessManager {
  79718. private _scene;
  79719. private _indexBuffer;
  79720. private _vertexBuffers;
  79721. /**
  79722. * Creates a new instance PostProcess
  79723. * @param scene The scene that the post process is associated with.
  79724. */
  79725. constructor(scene: Scene);
  79726. private _prepareBuffers;
  79727. private _buildIndexBuffer;
  79728. /**
  79729. * Rebuilds the vertex buffers of the manager.
  79730. * @hidden
  79731. */
  79732. _rebuild(): void;
  79733. /**
  79734. * Prepares a frame to be run through a post process.
  79735. * @param sourceTexture The input texture to the post procesess. (default: null)
  79736. * @param postProcesses An array of post processes to be run. (default: null)
  79737. * @returns True if the post processes were able to be run.
  79738. * @hidden
  79739. */
  79740. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79741. /**
  79742. * Manually render a set of post processes to a texture.
  79743. * @param postProcesses An array of post processes to be run.
  79744. * @param targetTexture The target texture to render to.
  79745. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79746. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79747. * @param lodLevel defines which lod of the texture to render to
  79748. */
  79749. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79750. /**
  79751. * Finalize the result of the output of the postprocesses.
  79752. * @param doNotPresent If true the result will not be displayed to the screen.
  79753. * @param targetTexture The target texture to render to.
  79754. * @param faceIndex The index of the face to bind the target texture to.
  79755. * @param postProcesses The array of post processes to render.
  79756. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  79757. * @hidden
  79758. */
  79759. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  79760. /**
  79761. * Disposes of the post process manager.
  79762. */
  79763. dispose(): void;
  79764. }
  79765. }
  79766. declare module BABYLON {
  79767. /** Interface used by value gradients (color, factor, ...) */
  79768. export interface IValueGradient {
  79769. /**
  79770. * Gets or sets the gradient value (between 0 and 1)
  79771. */
  79772. gradient: number;
  79773. }
  79774. /** Class used to store color4 gradient */
  79775. export class ColorGradient implements IValueGradient {
  79776. /**
  79777. * Gets or sets the gradient value (between 0 and 1)
  79778. */
  79779. gradient: number;
  79780. /**
  79781. * Gets or sets first associated color
  79782. */
  79783. color1: Color4;
  79784. /**
  79785. * Gets or sets second associated color
  79786. */
  79787. color2?: Color4;
  79788. /**
  79789. * Will get a color picked randomly between color1 and color2.
  79790. * If color2 is undefined then color1 will be used
  79791. * @param result defines the target Color4 to store the result in
  79792. */
  79793. getColorToRef(result: Color4): void;
  79794. }
  79795. /** Class used to store color 3 gradient */
  79796. export class Color3Gradient implements IValueGradient {
  79797. /**
  79798. * Gets or sets the gradient value (between 0 and 1)
  79799. */
  79800. gradient: number;
  79801. /**
  79802. * Gets or sets the associated color
  79803. */
  79804. color: Color3;
  79805. }
  79806. /** Class used to store factor gradient */
  79807. export class FactorGradient implements IValueGradient {
  79808. /**
  79809. * Gets or sets the gradient value (between 0 and 1)
  79810. */
  79811. gradient: number;
  79812. /**
  79813. * Gets or sets first associated factor
  79814. */
  79815. factor1: number;
  79816. /**
  79817. * Gets or sets second associated factor
  79818. */
  79819. factor2?: number;
  79820. /**
  79821. * Will get a number picked randomly between factor1 and factor2.
  79822. * If factor2 is undefined then factor1 will be used
  79823. * @returns the picked number
  79824. */
  79825. getFactor(): number;
  79826. }
  79827. /**
  79828. * Helper used to simplify some generic gradient tasks
  79829. */
  79830. export class GradientHelper {
  79831. /**
  79832. * Gets the current gradient from an array of IValueGradient
  79833. * @param ratio defines the current ratio to get
  79834. * @param gradients defines the array of IValueGradient
  79835. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79836. */
  79837. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79838. }
  79839. }
  79840. declare module BABYLON {
  79841. interface AbstractScene {
  79842. /**
  79843. * The list of procedural textures added to the scene
  79844. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79845. */
  79846. proceduralTextures: Array<ProceduralTexture>;
  79847. }
  79848. /**
  79849. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79850. * in a given scene.
  79851. */
  79852. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79853. /**
  79854. * The component name helpfull to identify the component in the list of scene components.
  79855. */
  79856. readonly name: string;
  79857. /**
  79858. * The scene the component belongs to.
  79859. */
  79860. scene: Scene;
  79861. /**
  79862. * Creates a new instance of the component for the given scene
  79863. * @param scene Defines the scene to register the component in
  79864. */
  79865. constructor(scene: Scene);
  79866. /**
  79867. * Registers the component in a given scene
  79868. */
  79869. register(): void;
  79870. /**
  79871. * Rebuilds the elements related to this component in case of
  79872. * context lost for instance.
  79873. */
  79874. rebuild(): void;
  79875. /**
  79876. * Disposes the component and the associated ressources.
  79877. */
  79878. dispose(): void;
  79879. private _beforeClear;
  79880. }
  79881. }
  79882. declare module BABYLON {
  79883. interface Engine {
  79884. /**
  79885. * Creates a new render target cube texture
  79886. * @param size defines the size of the texture
  79887. * @param options defines the options used to create the texture
  79888. * @returns a new render target cube texture stored in an InternalTexture
  79889. */
  79890. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79891. }
  79892. }
  79893. declare module BABYLON {
  79894. /** @hidden */
  79895. export var proceduralVertexShader: {
  79896. name: string;
  79897. shader: string;
  79898. };
  79899. }
  79900. declare module BABYLON {
  79901. /**
  79902. * 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.
  79903. * This is the base class of any Procedural texture and contains most of the shareable code.
  79904. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79905. */
  79906. export class ProceduralTexture extends Texture {
  79907. isCube: boolean;
  79908. /**
  79909. * Define if the texture is enabled or not (disabled texture will not render)
  79910. */
  79911. isEnabled: boolean;
  79912. /**
  79913. * Define if the texture must be cleared before rendering (default is true)
  79914. */
  79915. autoClear: boolean;
  79916. /**
  79917. * Callback called when the texture is generated
  79918. */
  79919. onGenerated: () => void;
  79920. /**
  79921. * Event raised when the texture is generated
  79922. */
  79923. onGeneratedObservable: Observable<ProceduralTexture>;
  79924. /** @hidden */
  79925. _generateMipMaps: boolean;
  79926. /** @hidden **/
  79927. _effect: Effect;
  79928. /** @hidden */
  79929. _textures: {
  79930. [key: string]: Texture;
  79931. };
  79932. private _size;
  79933. private _currentRefreshId;
  79934. private _refreshRate;
  79935. private _vertexBuffers;
  79936. private _indexBuffer;
  79937. private _uniforms;
  79938. private _samplers;
  79939. private _fragment;
  79940. private _floats;
  79941. private _ints;
  79942. private _floatsArrays;
  79943. private _colors3;
  79944. private _colors4;
  79945. private _vectors2;
  79946. private _vectors3;
  79947. private _matrices;
  79948. private _fallbackTexture;
  79949. private _fallbackTextureUsed;
  79950. private _engine;
  79951. private _cachedDefines;
  79952. private _contentUpdateId;
  79953. private _contentData;
  79954. /**
  79955. * Instantiates a new procedural texture.
  79956. * 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.
  79957. * This is the base class of any Procedural texture and contains most of the shareable code.
  79958. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79959. * @param name Define the name of the texture
  79960. * @param size Define the size of the texture to create
  79961. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79962. * @param scene Define the scene the texture belongs to
  79963. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79964. * @param generateMipMaps Define if the texture should creates mip maps or not
  79965. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79966. */
  79967. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79968. /**
  79969. * The effect that is created when initializing the post process.
  79970. * @returns The created effect corresponding the the postprocess.
  79971. */
  79972. getEffect(): Effect;
  79973. /**
  79974. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79975. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79976. */
  79977. getContent(): Nullable<ArrayBufferView>;
  79978. private _createIndexBuffer;
  79979. /** @hidden */
  79980. _rebuild(): void;
  79981. /**
  79982. * Resets the texture in order to recreate its associated resources.
  79983. * This can be called in case of context loss
  79984. */
  79985. reset(): void;
  79986. protected _getDefines(): string;
  79987. /**
  79988. * Is the texture ready to be used ? (rendered at least once)
  79989. * @returns true if ready, otherwise, false.
  79990. */
  79991. isReady(): boolean;
  79992. /**
  79993. * Resets the refresh counter of the texture and start bak from scratch.
  79994. * Could be useful to regenerate the texture if it is setup to render only once.
  79995. */
  79996. resetRefreshCounter(): void;
  79997. /**
  79998. * Set the fragment shader to use in order to render the texture.
  79999. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80000. */
  80001. setFragment(fragment: any): void;
  80002. /**
  80003. * Define the refresh rate of the texture or the rendering frequency.
  80004. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80005. */
  80006. refreshRate: number;
  80007. /** @hidden */
  80008. _shouldRender(): boolean;
  80009. /**
  80010. * Get the size the texture is rendering at.
  80011. * @returns the size (texture is always squared)
  80012. */
  80013. getRenderSize(): number;
  80014. /**
  80015. * Resize the texture to new value.
  80016. * @param size Define the new size the texture should have
  80017. * @param generateMipMaps Define whether the new texture should create mip maps
  80018. */
  80019. resize(size: number, generateMipMaps: boolean): void;
  80020. private _checkUniform;
  80021. /**
  80022. * Set a texture in the shader program used to render.
  80023. * @param name Define the name of the uniform samplers as defined in the shader
  80024. * @param texture Define the texture to bind to this sampler
  80025. * @return the texture itself allowing "fluent" like uniform updates
  80026. */
  80027. setTexture(name: string, texture: Texture): ProceduralTexture;
  80028. /**
  80029. * Set a float in the shader.
  80030. * @param name Define the name of the uniform as defined in the shader
  80031. * @param value Define the value to give to the uniform
  80032. * @return the texture itself allowing "fluent" like uniform updates
  80033. */
  80034. setFloat(name: string, value: number): ProceduralTexture;
  80035. /**
  80036. * Set a int in the shader.
  80037. * @param name Define the name of the uniform as defined in the shader
  80038. * @param value Define the value to give to the uniform
  80039. * @return the texture itself allowing "fluent" like uniform updates
  80040. */
  80041. setInt(name: string, value: number): ProceduralTexture;
  80042. /**
  80043. * Set an array of floats in the shader.
  80044. * @param name Define the name of the uniform as defined in the shader
  80045. * @param value Define the value to give to the uniform
  80046. * @return the texture itself allowing "fluent" like uniform updates
  80047. */
  80048. setFloats(name: string, value: number[]): ProceduralTexture;
  80049. /**
  80050. * Set a vec3 in the shader from a Color3.
  80051. * @param name Define the name of the uniform as defined in the shader
  80052. * @param value Define the value to give to the uniform
  80053. * @return the texture itself allowing "fluent" like uniform updates
  80054. */
  80055. setColor3(name: string, value: Color3): ProceduralTexture;
  80056. /**
  80057. * Set a vec4 in the shader from a Color4.
  80058. * @param name Define the name of the uniform as defined in the shader
  80059. * @param value Define the value to give to the uniform
  80060. * @return the texture itself allowing "fluent" like uniform updates
  80061. */
  80062. setColor4(name: string, value: Color4): ProceduralTexture;
  80063. /**
  80064. * Set a vec2 in the shader from a Vector2.
  80065. * @param name Define the name of the uniform as defined in the shader
  80066. * @param value Define the value to give to the uniform
  80067. * @return the texture itself allowing "fluent" like uniform updates
  80068. */
  80069. setVector2(name: string, value: Vector2): ProceduralTexture;
  80070. /**
  80071. * Set a vec3 in the shader from a Vector3.
  80072. * @param name Define the name of the uniform as defined in the shader
  80073. * @param value Define the value to give to the uniform
  80074. * @return the texture itself allowing "fluent" like uniform updates
  80075. */
  80076. setVector3(name: string, value: Vector3): ProceduralTexture;
  80077. /**
  80078. * Set a mat4 in the shader from a MAtrix.
  80079. * @param name Define the name of the uniform as defined in the shader
  80080. * @param value Define the value to give to the uniform
  80081. * @return the texture itself allowing "fluent" like uniform updates
  80082. */
  80083. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80084. /**
  80085. * Render the texture to its associated render target.
  80086. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80087. */
  80088. render(useCameraPostProcess?: boolean): void;
  80089. /**
  80090. * Clone the texture.
  80091. * @returns the cloned texture
  80092. */
  80093. clone(): ProceduralTexture;
  80094. /**
  80095. * Dispose the texture and release its asoociated resources.
  80096. */
  80097. dispose(): void;
  80098. }
  80099. }
  80100. declare module BABYLON {
  80101. /**
  80102. * This represents the base class for particle system in Babylon.
  80103. * 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.
  80104. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80105. * @example https://doc.babylonjs.com/babylon101/particles
  80106. */
  80107. export class BaseParticleSystem {
  80108. /**
  80109. * Source color is added to the destination color without alpha affecting the result
  80110. */
  80111. static BLENDMODE_ONEONE: number;
  80112. /**
  80113. * Blend current color and particle color using particle’s alpha
  80114. */
  80115. static BLENDMODE_STANDARD: number;
  80116. /**
  80117. * Add current color and particle color multiplied by particle’s alpha
  80118. */
  80119. static BLENDMODE_ADD: number;
  80120. /**
  80121. * Multiply current color with particle color
  80122. */
  80123. static BLENDMODE_MULTIPLY: number;
  80124. /**
  80125. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80126. */
  80127. static BLENDMODE_MULTIPLYADD: number;
  80128. /**
  80129. * List of animations used by the particle system.
  80130. */
  80131. animations: Animation[];
  80132. /**
  80133. * The id of the Particle system.
  80134. */
  80135. id: string;
  80136. /**
  80137. * The friendly name of the Particle system.
  80138. */
  80139. name: string;
  80140. /**
  80141. * The rendering group used by the Particle system to chose when to render.
  80142. */
  80143. renderingGroupId: number;
  80144. /**
  80145. * The emitter represents the Mesh or position we are attaching the particle system to.
  80146. */
  80147. emitter: Nullable<AbstractMesh | Vector3>;
  80148. /**
  80149. * The maximum number of particles to emit per frame
  80150. */
  80151. emitRate: number;
  80152. /**
  80153. * If you want to launch only a few particles at once, that can be done, as well.
  80154. */
  80155. manualEmitCount: number;
  80156. /**
  80157. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80158. */
  80159. updateSpeed: number;
  80160. /**
  80161. * The amount of time the particle system is running (depends of the overall update speed).
  80162. */
  80163. targetStopDuration: number;
  80164. /**
  80165. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80166. */
  80167. disposeOnStop: boolean;
  80168. /**
  80169. * Minimum power of emitting particles.
  80170. */
  80171. minEmitPower: number;
  80172. /**
  80173. * Maximum power of emitting particles.
  80174. */
  80175. maxEmitPower: number;
  80176. /**
  80177. * Minimum life time of emitting particles.
  80178. */
  80179. minLifeTime: number;
  80180. /**
  80181. * Maximum life time of emitting particles.
  80182. */
  80183. maxLifeTime: number;
  80184. /**
  80185. * Minimum Size of emitting particles.
  80186. */
  80187. minSize: number;
  80188. /**
  80189. * Maximum Size of emitting particles.
  80190. */
  80191. maxSize: number;
  80192. /**
  80193. * Minimum scale of emitting particles on X axis.
  80194. */
  80195. minScaleX: number;
  80196. /**
  80197. * Maximum scale of emitting particles on X axis.
  80198. */
  80199. maxScaleX: number;
  80200. /**
  80201. * Minimum scale of emitting particles on Y axis.
  80202. */
  80203. minScaleY: number;
  80204. /**
  80205. * Maximum scale of emitting particles on Y axis.
  80206. */
  80207. maxScaleY: number;
  80208. /**
  80209. * Gets or sets the minimal initial rotation in radians.
  80210. */
  80211. minInitialRotation: number;
  80212. /**
  80213. * Gets or sets the maximal initial rotation in radians.
  80214. */
  80215. maxInitialRotation: number;
  80216. /**
  80217. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80218. */
  80219. minAngularSpeed: number;
  80220. /**
  80221. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80222. */
  80223. maxAngularSpeed: number;
  80224. /**
  80225. * The texture used to render each particle. (this can be a spritesheet)
  80226. */
  80227. particleTexture: Nullable<Texture>;
  80228. /**
  80229. * The layer mask we are rendering the particles through.
  80230. */
  80231. layerMask: number;
  80232. /**
  80233. * This can help using your own shader to render the particle system.
  80234. * The according effect will be created
  80235. */
  80236. customShader: any;
  80237. /**
  80238. * By default particle system starts as soon as they are created. This prevents the
  80239. * automatic start to happen and let you decide when to start emitting particles.
  80240. */
  80241. preventAutoStart: boolean;
  80242. private _noiseTexture;
  80243. /**
  80244. * Gets or sets a texture used to add random noise to particle positions
  80245. */
  80246. noiseTexture: Nullable<ProceduralTexture>;
  80247. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80248. noiseStrength: Vector3;
  80249. /**
  80250. * Callback triggered when the particle animation is ending.
  80251. */
  80252. onAnimationEnd: Nullable<() => void>;
  80253. /**
  80254. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80255. */
  80256. blendMode: number;
  80257. /**
  80258. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80259. * to override the particles.
  80260. */
  80261. forceDepthWrite: boolean;
  80262. /** 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 */
  80263. preWarmCycles: number;
  80264. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80265. preWarmStepOffset: number;
  80266. /**
  80267. * 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)
  80268. */
  80269. spriteCellChangeSpeed: number;
  80270. /**
  80271. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80272. */
  80273. startSpriteCellID: number;
  80274. /**
  80275. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80276. */
  80277. endSpriteCellID: number;
  80278. /**
  80279. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80280. */
  80281. spriteCellWidth: number;
  80282. /**
  80283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80284. */
  80285. spriteCellHeight: number;
  80286. /**
  80287. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80288. */
  80289. spriteRandomStartCell: boolean;
  80290. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80291. translationPivot: Vector2;
  80292. /** @hidden */
  80293. protected _isAnimationSheetEnabled: boolean;
  80294. /**
  80295. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80296. */
  80297. beginAnimationOnStart: boolean;
  80298. /**
  80299. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80300. */
  80301. beginAnimationFrom: number;
  80302. /**
  80303. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80304. */
  80305. beginAnimationTo: number;
  80306. /**
  80307. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80308. */
  80309. beginAnimationLoop: boolean;
  80310. /**
  80311. * Gets or sets a world offset applied to all particles
  80312. */
  80313. worldOffset: Vector3;
  80314. /**
  80315. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80316. */
  80317. isAnimationSheetEnabled: boolean;
  80318. /**
  80319. * Get hosting scene
  80320. * @returns the scene
  80321. */
  80322. getScene(): Scene;
  80323. /**
  80324. * You can use gravity if you want to give an orientation to your particles.
  80325. */
  80326. gravity: Vector3;
  80327. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80328. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80329. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80330. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80331. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80332. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80333. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80334. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80335. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80336. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80337. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80338. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80339. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80340. /**
  80341. * Defines the delay in milliseconds before starting the system (0 by default)
  80342. */
  80343. startDelay: number;
  80344. /**
  80345. * Gets the current list of drag gradients.
  80346. * You must use addDragGradient and removeDragGradient to udpate this list
  80347. * @returns the list of drag gradients
  80348. */
  80349. getDragGradients(): Nullable<Array<FactorGradient>>;
  80350. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80351. limitVelocityDamping: number;
  80352. /**
  80353. * Gets the current list of limit velocity gradients.
  80354. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80355. * @returns the list of limit velocity gradients
  80356. */
  80357. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80358. /**
  80359. * Gets the current list of color gradients.
  80360. * You must use addColorGradient and removeColorGradient to udpate this list
  80361. * @returns the list of color gradients
  80362. */
  80363. getColorGradients(): Nullable<Array<ColorGradient>>;
  80364. /**
  80365. * Gets the current list of size gradients.
  80366. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80367. * @returns the list of size gradients
  80368. */
  80369. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80370. /**
  80371. * Gets the current list of color remap gradients.
  80372. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80373. * @returns the list of color remap gradients
  80374. */
  80375. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80376. /**
  80377. * Gets the current list of alpha remap gradients.
  80378. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80379. * @returns the list of alpha remap gradients
  80380. */
  80381. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80382. /**
  80383. * Gets the current list of life time gradients.
  80384. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80385. * @returns the list of life time gradients
  80386. */
  80387. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80388. /**
  80389. * Gets the current list of angular speed gradients.
  80390. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80391. * @returns the list of angular speed gradients
  80392. */
  80393. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80394. /**
  80395. * Gets the current list of velocity gradients.
  80396. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80397. * @returns the list of velocity gradients
  80398. */
  80399. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80400. /**
  80401. * Gets the current list of start size gradients.
  80402. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80403. * @returns the list of start size gradients
  80404. */
  80405. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80406. /**
  80407. * Gets the current list of emit rate gradients.
  80408. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80409. * @returns the list of emit rate gradients
  80410. */
  80411. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80412. /**
  80413. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80414. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80415. */
  80416. direction1: Vector3;
  80417. /**
  80418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80419. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80420. */
  80421. direction2: Vector3;
  80422. /**
  80423. * 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.
  80424. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80425. */
  80426. minEmitBox: Vector3;
  80427. /**
  80428. * 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.
  80429. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80430. */
  80431. maxEmitBox: Vector3;
  80432. /**
  80433. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80434. */
  80435. color1: Color4;
  80436. /**
  80437. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80438. */
  80439. color2: Color4;
  80440. /**
  80441. * Color the particle will have at the end of its lifetime
  80442. */
  80443. colorDead: Color4;
  80444. /**
  80445. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80446. */
  80447. textureMask: Color4;
  80448. /**
  80449. * The particle emitter type defines the emitter used by the particle system.
  80450. * It can be for example box, sphere, or cone...
  80451. */
  80452. particleEmitterType: IParticleEmitterType;
  80453. /** @hidden */
  80454. _isSubEmitter: boolean;
  80455. /**
  80456. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80457. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80458. */
  80459. billboardMode: number;
  80460. protected _isBillboardBased: boolean;
  80461. /**
  80462. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80463. */
  80464. isBillboardBased: boolean;
  80465. /**
  80466. * The scene the particle system belongs to.
  80467. */
  80468. protected _scene: Scene;
  80469. /**
  80470. * Local cache of defines for image processing.
  80471. */
  80472. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80473. /**
  80474. * Default configuration related to image processing available in the standard Material.
  80475. */
  80476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80477. /**
  80478. * Gets the image processing configuration used either in this material.
  80479. */
  80480. /**
  80481. * Sets the Default image processing configuration used either in the this material.
  80482. *
  80483. * If sets to null, the scene one is in use.
  80484. */
  80485. imageProcessingConfiguration: ImageProcessingConfiguration;
  80486. /**
  80487. * Attaches a new image processing configuration to the Standard Material.
  80488. * @param configuration
  80489. */
  80490. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80491. /** @hidden */
  80492. protected _reset(): void;
  80493. /** @hidden */
  80494. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80495. /**
  80496. * Instantiates a particle system.
  80497. * 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.
  80498. * @param name The name of the particle system
  80499. */
  80500. constructor(name: string);
  80501. /**
  80502. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80503. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80504. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80505. * @returns the emitter
  80506. */
  80507. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80508. /**
  80509. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80510. * @param radius The radius of the hemisphere to emit from
  80511. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80512. * @returns the emitter
  80513. */
  80514. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80515. /**
  80516. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80517. * @param radius The radius of the sphere to emit from
  80518. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80519. * @returns the emitter
  80520. */
  80521. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80522. /**
  80523. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80524. * @param radius The radius of the sphere to emit from
  80525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80527. * @returns the emitter
  80528. */
  80529. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80530. /**
  80531. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80532. * @param radius The radius of the emission cylinder
  80533. * @param height The height of the emission cylinder
  80534. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80535. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80536. * @returns the emitter
  80537. */
  80538. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80539. /**
  80540. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80541. * @param radius The radius of the cylinder to emit from
  80542. * @param height The height of the emission cylinder
  80543. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80544. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80545. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80546. * @returns the emitter
  80547. */
  80548. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80549. /**
  80550. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80551. * @param radius The radius of the cone to emit from
  80552. * @param angle The base angle of the cone
  80553. * @returns the emitter
  80554. */
  80555. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80556. /**
  80557. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80560. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80561. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80562. * @returns the emitter
  80563. */
  80564. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80565. }
  80566. }
  80567. declare module BABYLON {
  80568. /**
  80569. * Type of sub emitter
  80570. */
  80571. export enum SubEmitterType {
  80572. /**
  80573. * Attached to the particle over it's lifetime
  80574. */
  80575. ATTACHED = 0,
  80576. /**
  80577. * Created when the particle dies
  80578. */
  80579. END = 1
  80580. }
  80581. /**
  80582. * Sub emitter class used to emit particles from an existing particle
  80583. */
  80584. export class SubEmitter {
  80585. /**
  80586. * the particle system to be used by the sub emitter
  80587. */
  80588. particleSystem: ParticleSystem;
  80589. /**
  80590. * Type of the submitter (Default: END)
  80591. */
  80592. type: SubEmitterType;
  80593. /**
  80594. * 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)
  80595. * Note: This only is supported when using an emitter of type Mesh
  80596. */
  80597. inheritDirection: boolean;
  80598. /**
  80599. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80600. */
  80601. inheritedVelocityAmount: number;
  80602. /**
  80603. * Creates a sub emitter
  80604. * @param particleSystem the particle system to be used by the sub emitter
  80605. */
  80606. constructor(
  80607. /**
  80608. * the particle system to be used by the sub emitter
  80609. */
  80610. particleSystem: ParticleSystem);
  80611. /**
  80612. * Clones the sub emitter
  80613. * @returns the cloned sub emitter
  80614. */
  80615. clone(): SubEmitter;
  80616. /**
  80617. * Serialize current object to a JSON object
  80618. * @returns the serialized object
  80619. */
  80620. serialize(): any;
  80621. /** @hidden */
  80622. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80623. /**
  80624. * Creates a new SubEmitter from a serialized JSON version
  80625. * @param serializationObject defines the JSON object to read from
  80626. * @param scene defines the hosting scene
  80627. * @param rootUrl defines the rootUrl for data loading
  80628. * @returns a new SubEmitter
  80629. */
  80630. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80631. /** Release associated resources */
  80632. dispose(): void;
  80633. }
  80634. }
  80635. declare module BABYLON {
  80636. /** @hidden */
  80637. export var clipPlaneFragmentDeclaration: {
  80638. name: string;
  80639. shader: string;
  80640. };
  80641. }
  80642. declare module BABYLON {
  80643. /** @hidden */
  80644. export var imageProcessingDeclaration: {
  80645. name: string;
  80646. shader: string;
  80647. };
  80648. }
  80649. declare module BABYLON {
  80650. /** @hidden */
  80651. export var imageProcessingFunctions: {
  80652. name: string;
  80653. shader: string;
  80654. };
  80655. }
  80656. declare module BABYLON {
  80657. /** @hidden */
  80658. export var clipPlaneFragment: {
  80659. name: string;
  80660. shader: string;
  80661. };
  80662. }
  80663. declare module BABYLON {
  80664. /** @hidden */
  80665. export var particlesPixelShader: {
  80666. name: string;
  80667. shader: string;
  80668. };
  80669. }
  80670. declare module BABYLON {
  80671. /** @hidden */
  80672. export var clipPlaneVertexDeclaration: {
  80673. name: string;
  80674. shader: string;
  80675. };
  80676. }
  80677. declare module BABYLON {
  80678. /** @hidden */
  80679. export var clipPlaneVertex: {
  80680. name: string;
  80681. shader: string;
  80682. };
  80683. }
  80684. declare module BABYLON {
  80685. /** @hidden */
  80686. export var particlesVertexShader: {
  80687. name: string;
  80688. shader: string;
  80689. };
  80690. }
  80691. declare module BABYLON {
  80692. /**
  80693. * This represents a particle system in Babylon.
  80694. * 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.
  80695. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80696. * @example https://doc.babylonjs.com/babylon101/particles
  80697. */
  80698. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80699. /**
  80700. * Billboard mode will only apply to Y axis
  80701. */
  80702. static readonly BILLBOARDMODE_Y: number;
  80703. /**
  80704. * Billboard mode will apply to all axes
  80705. */
  80706. static readonly BILLBOARDMODE_ALL: number;
  80707. /**
  80708. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80709. */
  80710. static readonly BILLBOARDMODE_STRETCHED: number;
  80711. /**
  80712. * This function can be defined to provide custom update for active particles.
  80713. * This function will be called instead of regular update (age, position, color, etc.).
  80714. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80715. */
  80716. updateFunction: (particles: Particle[]) => void;
  80717. private _emitterWorldMatrix;
  80718. /**
  80719. * This function can be defined to specify initial direction for every new particle.
  80720. * It by default use the emitterType defined function
  80721. */
  80722. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80723. /**
  80724. * This function can be defined to specify initial position for every new particle.
  80725. * It by default use the emitterType defined function
  80726. */
  80727. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80728. /**
  80729. * @hidden
  80730. */
  80731. _inheritedVelocityOffset: Vector3;
  80732. /**
  80733. * An event triggered when the system is disposed
  80734. */
  80735. onDisposeObservable: Observable<ParticleSystem>;
  80736. private _onDisposeObserver;
  80737. /**
  80738. * Sets a callback that will be triggered when the system is disposed
  80739. */
  80740. onDispose: () => void;
  80741. private _particles;
  80742. private _epsilon;
  80743. private _capacity;
  80744. private _stockParticles;
  80745. private _newPartsExcess;
  80746. private _vertexData;
  80747. private _vertexBuffer;
  80748. private _vertexBuffers;
  80749. private _spriteBuffer;
  80750. private _indexBuffer;
  80751. private _effect;
  80752. private _customEffect;
  80753. private _cachedDefines;
  80754. private _scaledColorStep;
  80755. private _colorDiff;
  80756. private _scaledDirection;
  80757. private _scaledGravity;
  80758. private _currentRenderId;
  80759. private _alive;
  80760. private _useInstancing;
  80761. private _started;
  80762. private _stopped;
  80763. private _actualFrame;
  80764. private _scaledUpdateSpeed;
  80765. private _vertexBufferSize;
  80766. /** @hidden */
  80767. _currentEmitRateGradient: Nullable<FactorGradient>;
  80768. /** @hidden */
  80769. _currentEmitRate1: number;
  80770. /** @hidden */
  80771. _currentEmitRate2: number;
  80772. /** @hidden */
  80773. _currentStartSizeGradient: Nullable<FactorGradient>;
  80774. /** @hidden */
  80775. _currentStartSize1: number;
  80776. /** @hidden */
  80777. _currentStartSize2: number;
  80778. private readonly _rawTextureWidth;
  80779. private _rampGradientsTexture;
  80780. private _useRampGradients;
  80781. /** Gets or sets a boolean indicating that ramp gradients must be used
  80782. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  80783. */
  80784. useRampGradients: boolean;
  80785. /**
  80786. * 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.
  80787. * 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: [])
  80788. */
  80789. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  80790. private _subEmitters;
  80791. /**
  80792. * @hidden
  80793. * If the particle systems emitter should be disposed when the particle system is disposed
  80794. */
  80795. _disposeEmitterOnDispose: boolean;
  80796. /**
  80797. * The current active Sub-systems, this property is used by the root particle system only.
  80798. */
  80799. activeSubSystems: Array<ParticleSystem>;
  80800. private _rootParticleSystem;
  80801. /**
  80802. * Gets the current list of active particles
  80803. */
  80804. readonly particles: Particle[];
  80805. /**
  80806. * Returns the string "ParticleSystem"
  80807. * @returns a string containing the class name
  80808. */
  80809. getClassName(): string;
  80810. /**
  80811. * Instantiates a particle system.
  80812. * 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.
  80813. * @param name The name of the particle system
  80814. * @param capacity The max number of particles alive at the same time
  80815. * @param scene The scene the particle system belongs to
  80816. * @param customEffect a custom effect used to change the way particles are rendered by default
  80817. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80818. * @param epsilon Offset used to render the particles
  80819. */
  80820. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80821. private _addFactorGradient;
  80822. private _removeFactorGradient;
  80823. /**
  80824. * Adds a new life time gradient
  80825. * @param gradient defines the gradient to use (between 0 and 1)
  80826. * @param factor defines the life time factor to affect to the specified gradient
  80827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80828. * @returns the current particle system
  80829. */
  80830. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80831. /**
  80832. * Remove a specific life time gradient
  80833. * @param gradient defines the gradient to remove
  80834. * @returns the current particle system
  80835. */
  80836. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80837. /**
  80838. * Adds a new size gradient
  80839. * @param gradient defines the gradient to use (between 0 and 1)
  80840. * @param factor defines the size factor to affect to the specified gradient
  80841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80842. * @returns the current particle system
  80843. */
  80844. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80845. /**
  80846. * Remove a specific size gradient
  80847. * @param gradient defines the gradient to remove
  80848. * @returns the current particle system
  80849. */
  80850. removeSizeGradient(gradient: number): IParticleSystem;
  80851. /**
  80852. * Adds a new color remap gradient
  80853. * @param gradient defines the gradient to use (between 0 and 1)
  80854. * @param min defines the color remap minimal range
  80855. * @param max defines the color remap maximal range
  80856. * @returns the current particle system
  80857. */
  80858. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80859. /**
  80860. * Remove a specific color remap gradient
  80861. * @param gradient defines the gradient to remove
  80862. * @returns the current particle system
  80863. */
  80864. removeColorRemapGradient(gradient: number): IParticleSystem;
  80865. /**
  80866. * Adds a new alpha remap gradient
  80867. * @param gradient defines the gradient to use (between 0 and 1)
  80868. * @param min defines the alpha remap minimal range
  80869. * @param max defines the alpha remap maximal range
  80870. * @returns the current particle system
  80871. */
  80872. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80873. /**
  80874. * Remove a specific alpha remap gradient
  80875. * @param gradient defines the gradient to remove
  80876. * @returns the current particle system
  80877. */
  80878. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80879. /**
  80880. * Adds a new angular speed gradient
  80881. * @param gradient defines the gradient to use (between 0 and 1)
  80882. * @param factor defines the angular speed to affect to the specified gradient
  80883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80884. * @returns the current particle system
  80885. */
  80886. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80887. /**
  80888. * Remove a specific angular speed gradient
  80889. * @param gradient defines the gradient to remove
  80890. * @returns the current particle system
  80891. */
  80892. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80893. /**
  80894. * Adds a new velocity gradient
  80895. * @param gradient defines the gradient to use (between 0 and 1)
  80896. * @param factor defines the velocity to affect to the specified gradient
  80897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80898. * @returns the current particle system
  80899. */
  80900. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80901. /**
  80902. * Remove a specific velocity gradient
  80903. * @param gradient defines the gradient to remove
  80904. * @returns the current particle system
  80905. */
  80906. removeVelocityGradient(gradient: number): IParticleSystem;
  80907. /**
  80908. * Adds a new limit velocity gradient
  80909. * @param gradient defines the gradient to use (between 0 and 1)
  80910. * @param factor defines the limit velocity value to affect to the specified gradient
  80911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80912. * @returns the current particle system
  80913. */
  80914. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80915. /**
  80916. * Remove a specific limit velocity gradient
  80917. * @param gradient defines the gradient to remove
  80918. * @returns the current particle system
  80919. */
  80920. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80921. /**
  80922. * Adds a new drag gradient
  80923. * @param gradient defines the gradient to use (between 0 and 1)
  80924. * @param factor defines the drag value to affect to the specified gradient
  80925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80926. * @returns the current particle system
  80927. */
  80928. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80929. /**
  80930. * Remove a specific drag gradient
  80931. * @param gradient defines the gradient to remove
  80932. * @returns the current particle system
  80933. */
  80934. removeDragGradient(gradient: number): IParticleSystem;
  80935. /**
  80936. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80937. * @param gradient defines the gradient to use (between 0 and 1)
  80938. * @param factor defines the emit rate value to affect to the specified gradient
  80939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80940. * @returns the current particle system
  80941. */
  80942. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80943. /**
  80944. * Remove a specific emit rate gradient
  80945. * @param gradient defines the gradient to remove
  80946. * @returns the current particle system
  80947. */
  80948. removeEmitRateGradient(gradient: number): IParticleSystem;
  80949. /**
  80950. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80951. * @param gradient defines the gradient to use (between 0 and 1)
  80952. * @param factor defines the start size value to affect to the specified gradient
  80953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80954. * @returns the current particle system
  80955. */
  80956. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80957. /**
  80958. * Remove a specific start size gradient
  80959. * @param gradient defines the gradient to remove
  80960. * @returns the current particle system
  80961. */
  80962. removeStartSizeGradient(gradient: number): IParticleSystem;
  80963. private _createRampGradientTexture;
  80964. /**
  80965. * Gets the current list of ramp gradients.
  80966. * You must use addRampGradient and removeRampGradient to udpate this list
  80967. * @returns the list of ramp gradients
  80968. */
  80969. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80970. /**
  80971. * Adds a new ramp gradient used to remap particle colors
  80972. * @param gradient defines the gradient to use (between 0 and 1)
  80973. * @param color defines the color to affect to the specified gradient
  80974. * @returns the current particle system
  80975. */
  80976. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80977. /**
  80978. * Remove a specific ramp gradient
  80979. * @param gradient defines the gradient to remove
  80980. * @returns the current particle system
  80981. */
  80982. removeRampGradient(gradient: number): ParticleSystem;
  80983. /**
  80984. * Adds a new color gradient
  80985. * @param gradient defines the gradient to use (between 0 and 1)
  80986. * @param color1 defines the color to affect to the specified gradient
  80987. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80988. * @returns this particle system
  80989. */
  80990. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80991. /**
  80992. * Remove a specific color gradient
  80993. * @param gradient defines the gradient to remove
  80994. * @returns this particle system
  80995. */
  80996. removeColorGradient(gradient: number): IParticleSystem;
  80997. private _fetchR;
  80998. protected _reset(): void;
  80999. private _resetEffect;
  81000. private _createVertexBuffers;
  81001. private _createIndexBuffer;
  81002. /**
  81003. * Gets the maximum number of particles active at the same time.
  81004. * @returns The max number of active particles.
  81005. */
  81006. getCapacity(): number;
  81007. /**
  81008. * Gets whether there are still active particles in the system.
  81009. * @returns True if it is alive, otherwise false.
  81010. */
  81011. isAlive(): boolean;
  81012. /**
  81013. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81014. * @returns True if it has been started, otherwise false.
  81015. */
  81016. isStarted(): boolean;
  81017. private _prepareSubEmitterInternalArray;
  81018. /**
  81019. * Starts the particle system and begins to emit
  81020. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81021. */
  81022. start(delay?: number): void;
  81023. /**
  81024. * Stops the particle system.
  81025. * @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.
  81026. */
  81027. stop(stopSubEmitters?: boolean): void;
  81028. /**
  81029. * Remove all active particles
  81030. */
  81031. reset(): void;
  81032. /**
  81033. * @hidden (for internal use only)
  81034. */
  81035. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81036. /**
  81037. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81038. * Its lifetime will start back at 0.
  81039. */
  81040. recycleParticle: (particle: Particle) => void;
  81041. private _stopSubEmitters;
  81042. private _createParticle;
  81043. private _removeFromRoot;
  81044. private _emitFromParticle;
  81045. private _update;
  81046. /** @hidden */
  81047. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81048. /** @hidden */
  81049. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81050. /** @hidden */
  81051. private _getEffect;
  81052. /**
  81053. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81054. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81055. */
  81056. animate(preWarmOnly?: boolean): void;
  81057. private _appendParticleVertices;
  81058. /**
  81059. * Rebuilds the particle system.
  81060. */
  81061. rebuild(): void;
  81062. /**
  81063. * Is this system ready to be used/rendered
  81064. * @return true if the system is ready
  81065. */
  81066. isReady(): boolean;
  81067. private _render;
  81068. /**
  81069. * Renders the particle system in its current state.
  81070. * @returns the current number of particles
  81071. */
  81072. render(): number;
  81073. /**
  81074. * Disposes the particle system and free the associated resources
  81075. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81076. */
  81077. dispose(disposeTexture?: boolean): void;
  81078. /**
  81079. * Clones the particle system.
  81080. * @param name The name of the cloned object
  81081. * @param newEmitter The new emitter to use
  81082. * @returns the cloned particle system
  81083. */
  81084. clone(name: string, newEmitter: any): ParticleSystem;
  81085. /**
  81086. * Serializes the particle system to a JSON object.
  81087. * @returns the JSON object
  81088. */
  81089. serialize(): any;
  81090. /** @hidden */
  81091. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81092. /** @hidden */
  81093. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81094. /**
  81095. * Parses a JSON object to create a particle system.
  81096. * @param parsedParticleSystem The JSON object to parse
  81097. * @param scene The scene to create the particle system in
  81098. * @param rootUrl The root url to use to load external dependencies like texture
  81099. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81100. * @returns the Parsed particle system
  81101. */
  81102. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81103. }
  81104. }
  81105. declare module BABYLON {
  81106. /**
  81107. * A particle represents one of the element emitted by a particle system.
  81108. * This is mainly define by its coordinates, direction, velocity and age.
  81109. */
  81110. export class Particle {
  81111. /**
  81112. * The particle system the particle belongs to.
  81113. */
  81114. particleSystem: ParticleSystem;
  81115. private static _Count;
  81116. /**
  81117. * Unique ID of the particle
  81118. */
  81119. id: number;
  81120. /**
  81121. * The world position of the particle in the scene.
  81122. */
  81123. position: Vector3;
  81124. /**
  81125. * The world direction of the particle in the scene.
  81126. */
  81127. direction: Vector3;
  81128. /**
  81129. * The color of the particle.
  81130. */
  81131. color: Color4;
  81132. /**
  81133. * The color change of the particle per step.
  81134. */
  81135. colorStep: Color4;
  81136. /**
  81137. * Defines how long will the life of the particle be.
  81138. */
  81139. lifeTime: number;
  81140. /**
  81141. * The current age of the particle.
  81142. */
  81143. age: number;
  81144. /**
  81145. * The current size of the particle.
  81146. */
  81147. size: number;
  81148. /**
  81149. * The current scale of the particle.
  81150. */
  81151. scale: Vector2;
  81152. /**
  81153. * The current angle of the particle.
  81154. */
  81155. angle: number;
  81156. /**
  81157. * Defines how fast is the angle changing.
  81158. */
  81159. angularSpeed: number;
  81160. /**
  81161. * Defines the cell index used by the particle to be rendered from a sprite.
  81162. */
  81163. cellIndex: number;
  81164. /**
  81165. * The information required to support color remapping
  81166. */
  81167. remapData: Vector4;
  81168. /** @hidden */
  81169. _randomCellOffset?: number;
  81170. /** @hidden */
  81171. _initialDirection: Nullable<Vector3>;
  81172. /** @hidden */
  81173. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81174. /** @hidden */
  81175. _initialStartSpriteCellID: number;
  81176. /** @hidden */
  81177. _initialEndSpriteCellID: number;
  81178. /** @hidden */
  81179. _currentColorGradient: Nullable<ColorGradient>;
  81180. /** @hidden */
  81181. _currentColor1: Color4;
  81182. /** @hidden */
  81183. _currentColor2: Color4;
  81184. /** @hidden */
  81185. _currentSizeGradient: Nullable<FactorGradient>;
  81186. /** @hidden */
  81187. _currentSize1: number;
  81188. /** @hidden */
  81189. _currentSize2: number;
  81190. /** @hidden */
  81191. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81192. /** @hidden */
  81193. _currentAngularSpeed1: number;
  81194. /** @hidden */
  81195. _currentAngularSpeed2: number;
  81196. /** @hidden */
  81197. _currentVelocityGradient: Nullable<FactorGradient>;
  81198. /** @hidden */
  81199. _currentVelocity1: number;
  81200. /** @hidden */
  81201. _currentVelocity2: number;
  81202. /** @hidden */
  81203. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81204. /** @hidden */
  81205. _currentLimitVelocity1: number;
  81206. /** @hidden */
  81207. _currentLimitVelocity2: number;
  81208. /** @hidden */
  81209. _currentDragGradient: Nullable<FactorGradient>;
  81210. /** @hidden */
  81211. _currentDrag1: number;
  81212. /** @hidden */
  81213. _currentDrag2: number;
  81214. /** @hidden */
  81215. _randomNoiseCoordinates1: Vector3;
  81216. /** @hidden */
  81217. _randomNoiseCoordinates2: Vector3;
  81218. /**
  81219. * Creates a new instance Particle
  81220. * @param particleSystem the particle system the particle belongs to
  81221. */
  81222. constructor(
  81223. /**
  81224. * The particle system the particle belongs to.
  81225. */
  81226. particleSystem: ParticleSystem);
  81227. private updateCellInfoFromSystem;
  81228. /**
  81229. * Defines how the sprite cell index is updated for the particle
  81230. */
  81231. updateCellIndex(): void;
  81232. /** @hidden */
  81233. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81234. /** @hidden */
  81235. _inheritParticleInfoToSubEmitters(): void;
  81236. /** @hidden */
  81237. _reset(): void;
  81238. /**
  81239. * Copy the properties of particle to another one.
  81240. * @param other the particle to copy the information to.
  81241. */
  81242. copyTo(other: Particle): void;
  81243. }
  81244. }
  81245. declare module BABYLON {
  81246. /**
  81247. * Particle emitter represents a volume emitting particles.
  81248. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81249. */
  81250. export interface IParticleEmitterType {
  81251. /**
  81252. * Called by the particle System when the direction is computed for the created particle.
  81253. * @param worldMatrix is the world matrix of the particle system
  81254. * @param directionToUpdate is the direction vector to update with the result
  81255. * @param particle is the particle we are computed the direction for
  81256. */
  81257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81258. /**
  81259. * Called by the particle System when the position is computed for the created particle.
  81260. * @param worldMatrix is the world matrix of the particle system
  81261. * @param positionToUpdate is the position vector to update with the result
  81262. * @param particle is the particle we are computed the position for
  81263. */
  81264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81265. /**
  81266. * Clones the current emitter and returns a copy of it
  81267. * @returns the new emitter
  81268. */
  81269. clone(): IParticleEmitterType;
  81270. /**
  81271. * Called by the GPUParticleSystem to setup the update shader
  81272. * @param effect defines the update shader
  81273. */
  81274. applyToShader(effect: Effect): void;
  81275. /**
  81276. * Returns a string to use to update the GPU particles update shader
  81277. * @returns the effect defines string
  81278. */
  81279. getEffectDefines(): string;
  81280. /**
  81281. * Returns a string representing the class name
  81282. * @returns a string containing the class name
  81283. */
  81284. getClassName(): string;
  81285. /**
  81286. * Serializes the particle system to a JSON object.
  81287. * @returns the JSON object
  81288. */
  81289. serialize(): any;
  81290. /**
  81291. * Parse properties from a JSON object
  81292. * @param serializationObject defines the JSON object
  81293. */
  81294. parse(serializationObject: any): void;
  81295. }
  81296. }
  81297. declare module BABYLON {
  81298. /**
  81299. * Particle emitter emitting particles from the inside of a box.
  81300. * It emits the particles randomly between 2 given directions.
  81301. */
  81302. export class BoxParticleEmitter implements IParticleEmitterType {
  81303. /**
  81304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81305. */
  81306. direction1: Vector3;
  81307. /**
  81308. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81309. */
  81310. direction2: Vector3;
  81311. /**
  81312. * 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.
  81313. */
  81314. minEmitBox: Vector3;
  81315. /**
  81316. * 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.
  81317. */
  81318. maxEmitBox: Vector3;
  81319. /**
  81320. * Creates a new instance BoxParticleEmitter
  81321. */
  81322. constructor();
  81323. /**
  81324. * Called by the particle System when the direction is computed for the created particle.
  81325. * @param worldMatrix is the world matrix of the particle system
  81326. * @param directionToUpdate is the direction vector to update with the result
  81327. * @param particle is the particle we are computed the direction for
  81328. */
  81329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81330. /**
  81331. * Called by the particle System when the position is computed for the created particle.
  81332. * @param worldMatrix is the world matrix of the particle system
  81333. * @param positionToUpdate is the position vector to update with the result
  81334. * @param particle is the particle we are computed the position for
  81335. */
  81336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81337. /**
  81338. * Clones the current emitter and returns a copy of it
  81339. * @returns the new emitter
  81340. */
  81341. clone(): BoxParticleEmitter;
  81342. /**
  81343. * Called by the GPUParticleSystem to setup the update shader
  81344. * @param effect defines the update shader
  81345. */
  81346. applyToShader(effect: Effect): void;
  81347. /**
  81348. * Returns a string to use to update the GPU particles update shader
  81349. * @returns a string containng the defines string
  81350. */
  81351. getEffectDefines(): string;
  81352. /**
  81353. * Returns the string "BoxParticleEmitter"
  81354. * @returns a string containing the class name
  81355. */
  81356. getClassName(): string;
  81357. /**
  81358. * Serializes the particle system to a JSON object.
  81359. * @returns the JSON object
  81360. */
  81361. serialize(): any;
  81362. /**
  81363. * Parse properties from a JSON object
  81364. * @param serializationObject defines the JSON object
  81365. */
  81366. parse(serializationObject: any): void;
  81367. }
  81368. }
  81369. declare module BABYLON {
  81370. /**
  81371. * Particle emitter emitting particles from the inside of a cone.
  81372. * It emits the particles alongside the cone volume from the base to the particle.
  81373. * The emission direction might be randomized.
  81374. */
  81375. export class ConeParticleEmitter implements IParticleEmitterType {
  81376. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81377. directionRandomizer: number;
  81378. private _radius;
  81379. private _angle;
  81380. private _height;
  81381. /**
  81382. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81383. */
  81384. radiusRange: number;
  81385. /**
  81386. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81387. */
  81388. heightRange: number;
  81389. /**
  81390. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81391. */
  81392. emitFromSpawnPointOnly: boolean;
  81393. /**
  81394. * Gets or sets the radius of the emission cone
  81395. */
  81396. radius: number;
  81397. /**
  81398. * Gets or sets the angle of the emission cone
  81399. */
  81400. angle: number;
  81401. private _buildHeight;
  81402. /**
  81403. * Creates a new instance ConeParticleEmitter
  81404. * @param radius the radius of the emission cone (1 by default)
  81405. * @param angle the cone base angle (PI by default)
  81406. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81407. */
  81408. constructor(radius?: number, angle?: number,
  81409. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81410. directionRandomizer?: number);
  81411. /**
  81412. * Called by the particle System when the direction is computed for the created particle.
  81413. * @param worldMatrix is the world matrix of the particle system
  81414. * @param directionToUpdate is the direction vector to update with the result
  81415. * @param particle is the particle we are computed the direction for
  81416. */
  81417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81418. /**
  81419. * Called by the particle System when the position is computed for the created particle.
  81420. * @param worldMatrix is the world matrix of the particle system
  81421. * @param positionToUpdate is the position vector to update with the result
  81422. * @param particle is the particle we are computed the position for
  81423. */
  81424. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81425. /**
  81426. * Clones the current emitter and returns a copy of it
  81427. * @returns the new emitter
  81428. */
  81429. clone(): ConeParticleEmitter;
  81430. /**
  81431. * Called by the GPUParticleSystem to setup the update shader
  81432. * @param effect defines the update shader
  81433. */
  81434. applyToShader(effect: Effect): void;
  81435. /**
  81436. * Returns a string to use to update the GPU particles update shader
  81437. * @returns a string containng the defines string
  81438. */
  81439. getEffectDefines(): string;
  81440. /**
  81441. * Returns the string "ConeParticleEmitter"
  81442. * @returns a string containing the class name
  81443. */
  81444. getClassName(): string;
  81445. /**
  81446. * Serializes the particle system to a JSON object.
  81447. * @returns the JSON object
  81448. */
  81449. serialize(): any;
  81450. /**
  81451. * Parse properties from a JSON object
  81452. * @param serializationObject defines the JSON object
  81453. */
  81454. parse(serializationObject: any): void;
  81455. }
  81456. }
  81457. declare module BABYLON {
  81458. /**
  81459. * Particle emitter emitting particles from the inside of a cylinder.
  81460. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81461. */
  81462. export class CylinderParticleEmitter implements IParticleEmitterType {
  81463. /**
  81464. * The radius of the emission cylinder.
  81465. */
  81466. radius: number;
  81467. /**
  81468. * The height of the emission cylinder.
  81469. */
  81470. height: number;
  81471. /**
  81472. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81473. */
  81474. radiusRange: number;
  81475. /**
  81476. * How much to randomize the particle direction [0-1].
  81477. */
  81478. directionRandomizer: number;
  81479. /**
  81480. * Creates a new instance CylinderParticleEmitter
  81481. * @param radius the radius of the emission cylinder (1 by default)
  81482. * @param height the height of the emission cylinder (1 by default)
  81483. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81484. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81485. */
  81486. constructor(
  81487. /**
  81488. * The radius of the emission cylinder.
  81489. */
  81490. radius?: number,
  81491. /**
  81492. * The height of the emission cylinder.
  81493. */
  81494. height?: number,
  81495. /**
  81496. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81497. */
  81498. radiusRange?: number,
  81499. /**
  81500. * How much to randomize the particle direction [0-1].
  81501. */
  81502. directionRandomizer?: number);
  81503. /**
  81504. * Called by the particle System when the direction is computed for the created particle.
  81505. * @param worldMatrix is the world matrix of the particle system
  81506. * @param directionToUpdate is the direction vector to update with the result
  81507. * @param particle is the particle we are computed the direction for
  81508. */
  81509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81510. /**
  81511. * Called by the particle System when the position is computed for the created particle.
  81512. * @param worldMatrix is the world matrix of the particle system
  81513. * @param positionToUpdate is the position vector to update with the result
  81514. * @param particle is the particle we are computed the position for
  81515. */
  81516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81517. /**
  81518. * Clones the current emitter and returns a copy of it
  81519. * @returns the new emitter
  81520. */
  81521. clone(): CylinderParticleEmitter;
  81522. /**
  81523. * Called by the GPUParticleSystem to setup the update shader
  81524. * @param effect defines the update shader
  81525. */
  81526. applyToShader(effect: Effect): void;
  81527. /**
  81528. * Returns a string to use to update the GPU particles update shader
  81529. * @returns a string containng the defines string
  81530. */
  81531. getEffectDefines(): string;
  81532. /**
  81533. * Returns the string "CylinderParticleEmitter"
  81534. * @returns a string containing the class name
  81535. */
  81536. getClassName(): string;
  81537. /**
  81538. * Serializes the particle system to a JSON object.
  81539. * @returns the JSON object
  81540. */
  81541. serialize(): any;
  81542. /**
  81543. * Parse properties from a JSON object
  81544. * @param serializationObject defines the JSON object
  81545. */
  81546. parse(serializationObject: any): void;
  81547. }
  81548. /**
  81549. * Particle emitter emitting particles from the inside of a cylinder.
  81550. * It emits the particles randomly between two vectors.
  81551. */
  81552. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81553. /**
  81554. * The min limit of the emission direction.
  81555. */
  81556. direction1: Vector3;
  81557. /**
  81558. * The max limit of the emission direction.
  81559. */
  81560. direction2: Vector3;
  81561. /**
  81562. * Creates a new instance CylinderDirectedParticleEmitter
  81563. * @param radius the radius of the emission cylinder (1 by default)
  81564. * @param height the height of the emission cylinder (1 by default)
  81565. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81566. * @param direction1 the min limit of the emission direction (up vector by default)
  81567. * @param direction2 the max limit of the emission direction (up vector by default)
  81568. */
  81569. constructor(radius?: number, height?: number, radiusRange?: number,
  81570. /**
  81571. * The min limit of the emission direction.
  81572. */
  81573. direction1?: Vector3,
  81574. /**
  81575. * The max limit of the emission direction.
  81576. */
  81577. direction2?: Vector3);
  81578. /**
  81579. * Called by the particle System when the direction is computed for the created particle.
  81580. * @param worldMatrix is the world matrix of the particle system
  81581. * @param directionToUpdate is the direction vector to update with the result
  81582. * @param particle is the particle we are computed the direction for
  81583. */
  81584. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81585. /**
  81586. * Clones the current emitter and returns a copy of it
  81587. * @returns the new emitter
  81588. */
  81589. clone(): CylinderDirectedParticleEmitter;
  81590. /**
  81591. * Called by the GPUParticleSystem to setup the update shader
  81592. * @param effect defines the update shader
  81593. */
  81594. applyToShader(effect: Effect): void;
  81595. /**
  81596. * Returns a string to use to update the GPU particles update shader
  81597. * @returns a string containng the defines string
  81598. */
  81599. getEffectDefines(): string;
  81600. /**
  81601. * Returns the string "CylinderDirectedParticleEmitter"
  81602. * @returns a string containing the class name
  81603. */
  81604. getClassName(): string;
  81605. /**
  81606. * Serializes the particle system to a JSON object.
  81607. * @returns the JSON object
  81608. */
  81609. serialize(): any;
  81610. /**
  81611. * Parse properties from a JSON object
  81612. * @param serializationObject defines the JSON object
  81613. */
  81614. parse(serializationObject: any): void;
  81615. }
  81616. }
  81617. declare module BABYLON {
  81618. /**
  81619. * Particle emitter emitting particles from the inside of a hemisphere.
  81620. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81621. */
  81622. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81623. /**
  81624. * The radius of the emission hemisphere.
  81625. */
  81626. radius: number;
  81627. /**
  81628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81629. */
  81630. radiusRange: number;
  81631. /**
  81632. * How much to randomize the particle direction [0-1].
  81633. */
  81634. directionRandomizer: number;
  81635. /**
  81636. * Creates a new instance HemisphericParticleEmitter
  81637. * @param radius the radius of the emission hemisphere (1 by default)
  81638. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81639. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81640. */
  81641. constructor(
  81642. /**
  81643. * The radius of the emission hemisphere.
  81644. */
  81645. radius?: number,
  81646. /**
  81647. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81648. */
  81649. radiusRange?: number,
  81650. /**
  81651. * How much to randomize the particle direction [0-1].
  81652. */
  81653. directionRandomizer?: number);
  81654. /**
  81655. * Called by the particle System when the direction is computed for the created particle.
  81656. * @param worldMatrix is the world matrix of the particle system
  81657. * @param directionToUpdate is the direction vector to update with the result
  81658. * @param particle is the particle we are computed the direction for
  81659. */
  81660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81661. /**
  81662. * Called by the particle System when the position is computed for the created particle.
  81663. * @param worldMatrix is the world matrix of the particle system
  81664. * @param positionToUpdate is the position vector to update with the result
  81665. * @param particle is the particle we are computed the position for
  81666. */
  81667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81668. /**
  81669. * Clones the current emitter and returns a copy of it
  81670. * @returns the new emitter
  81671. */
  81672. clone(): HemisphericParticleEmitter;
  81673. /**
  81674. * Called by the GPUParticleSystem to setup the update shader
  81675. * @param effect defines the update shader
  81676. */
  81677. applyToShader(effect: Effect): void;
  81678. /**
  81679. * Returns a string to use to update the GPU particles update shader
  81680. * @returns a string containng the defines string
  81681. */
  81682. getEffectDefines(): string;
  81683. /**
  81684. * Returns the string "HemisphericParticleEmitter"
  81685. * @returns a string containing the class name
  81686. */
  81687. getClassName(): string;
  81688. /**
  81689. * Serializes the particle system to a JSON object.
  81690. * @returns the JSON object
  81691. */
  81692. serialize(): any;
  81693. /**
  81694. * Parse properties from a JSON object
  81695. * @param serializationObject defines the JSON object
  81696. */
  81697. parse(serializationObject: any): void;
  81698. }
  81699. }
  81700. declare module BABYLON {
  81701. /**
  81702. * Particle emitter emitting particles from a point.
  81703. * It emits the particles randomly between 2 given directions.
  81704. */
  81705. export class PointParticleEmitter implements IParticleEmitterType {
  81706. /**
  81707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81708. */
  81709. direction1: Vector3;
  81710. /**
  81711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81712. */
  81713. direction2: Vector3;
  81714. /**
  81715. * Creates a new instance PointParticleEmitter
  81716. */
  81717. constructor();
  81718. /**
  81719. * Called by the particle System when the direction is computed for the created particle.
  81720. * @param worldMatrix is the world matrix of the particle system
  81721. * @param directionToUpdate is the direction vector to update with the result
  81722. * @param particle is the particle we are computed the direction for
  81723. */
  81724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81725. /**
  81726. * Called by the particle System when the position is computed for the created particle.
  81727. * @param worldMatrix is the world matrix of the particle system
  81728. * @param positionToUpdate is the position vector to update with the result
  81729. * @param particle is the particle we are computed the position for
  81730. */
  81731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81732. /**
  81733. * Clones the current emitter and returns a copy of it
  81734. * @returns the new emitter
  81735. */
  81736. clone(): PointParticleEmitter;
  81737. /**
  81738. * Called by the GPUParticleSystem to setup the update shader
  81739. * @param effect defines the update shader
  81740. */
  81741. applyToShader(effect: Effect): void;
  81742. /**
  81743. * Returns a string to use to update the GPU particles update shader
  81744. * @returns a string containng the defines string
  81745. */
  81746. getEffectDefines(): string;
  81747. /**
  81748. * Returns the string "PointParticleEmitter"
  81749. * @returns a string containing the class name
  81750. */
  81751. getClassName(): string;
  81752. /**
  81753. * Serializes the particle system to a JSON object.
  81754. * @returns the JSON object
  81755. */
  81756. serialize(): any;
  81757. /**
  81758. * Parse properties from a JSON object
  81759. * @param serializationObject defines the JSON object
  81760. */
  81761. parse(serializationObject: any): void;
  81762. }
  81763. }
  81764. declare module BABYLON {
  81765. /**
  81766. * Particle emitter emitting particles from the inside of a sphere.
  81767. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  81768. */
  81769. export class SphereParticleEmitter implements IParticleEmitterType {
  81770. /**
  81771. * The radius of the emission sphere.
  81772. */
  81773. radius: number;
  81774. /**
  81775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81776. */
  81777. radiusRange: number;
  81778. /**
  81779. * How much to randomize the particle direction [0-1].
  81780. */
  81781. directionRandomizer: number;
  81782. /**
  81783. * Creates a new instance SphereParticleEmitter
  81784. * @param radius the radius of the emission sphere (1 by default)
  81785. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81786. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81787. */
  81788. constructor(
  81789. /**
  81790. * The radius of the emission sphere.
  81791. */
  81792. radius?: number,
  81793. /**
  81794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81795. */
  81796. radiusRange?: number,
  81797. /**
  81798. * How much to randomize the particle direction [0-1].
  81799. */
  81800. directionRandomizer?: number);
  81801. /**
  81802. * Called by the particle System when the direction is computed for the created particle.
  81803. * @param worldMatrix is the world matrix of the particle system
  81804. * @param directionToUpdate is the direction vector to update with the result
  81805. * @param particle is the particle we are computed the direction for
  81806. */
  81807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81808. /**
  81809. * Called by the particle System when the position is computed for the created particle.
  81810. * @param worldMatrix is the world matrix of the particle system
  81811. * @param positionToUpdate is the position vector to update with the result
  81812. * @param particle is the particle we are computed the position for
  81813. */
  81814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81815. /**
  81816. * Clones the current emitter and returns a copy of it
  81817. * @returns the new emitter
  81818. */
  81819. clone(): SphereParticleEmitter;
  81820. /**
  81821. * Called by the GPUParticleSystem to setup the update shader
  81822. * @param effect defines the update shader
  81823. */
  81824. applyToShader(effect: Effect): void;
  81825. /**
  81826. * Returns a string to use to update the GPU particles update shader
  81827. * @returns a string containng the defines string
  81828. */
  81829. getEffectDefines(): string;
  81830. /**
  81831. * Returns the string "SphereParticleEmitter"
  81832. * @returns a string containing the class name
  81833. */
  81834. getClassName(): string;
  81835. /**
  81836. * Serializes the particle system to a JSON object.
  81837. * @returns the JSON object
  81838. */
  81839. serialize(): any;
  81840. /**
  81841. * Parse properties from a JSON object
  81842. * @param serializationObject defines the JSON object
  81843. */
  81844. parse(serializationObject: any): void;
  81845. }
  81846. /**
  81847. * Particle emitter emitting particles from the inside of a sphere.
  81848. * It emits the particles randomly between two vectors.
  81849. */
  81850. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81851. /**
  81852. * The min limit of the emission direction.
  81853. */
  81854. direction1: Vector3;
  81855. /**
  81856. * The max limit of the emission direction.
  81857. */
  81858. direction2: Vector3;
  81859. /**
  81860. * Creates a new instance SphereDirectedParticleEmitter
  81861. * @param radius the radius of the emission sphere (1 by default)
  81862. * @param direction1 the min limit of the emission direction (up vector by default)
  81863. * @param direction2 the max limit of the emission direction (up vector by default)
  81864. */
  81865. constructor(radius?: number,
  81866. /**
  81867. * The min limit of the emission direction.
  81868. */
  81869. direction1?: Vector3,
  81870. /**
  81871. * The max limit of the emission direction.
  81872. */
  81873. direction2?: Vector3);
  81874. /**
  81875. * Called by the particle System when the direction is computed for the created particle.
  81876. * @param worldMatrix is the world matrix of the particle system
  81877. * @param directionToUpdate is the direction vector to update with the result
  81878. * @param particle is the particle we are computed the direction for
  81879. */
  81880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81881. /**
  81882. * Clones the current emitter and returns a copy of it
  81883. * @returns the new emitter
  81884. */
  81885. clone(): SphereDirectedParticleEmitter;
  81886. /**
  81887. * Called by the GPUParticleSystem to setup the update shader
  81888. * @param effect defines the update shader
  81889. */
  81890. applyToShader(effect: Effect): void;
  81891. /**
  81892. * Returns a string to use to update the GPU particles update shader
  81893. * @returns a string containng the defines string
  81894. */
  81895. getEffectDefines(): string;
  81896. /**
  81897. * Returns the string "SphereDirectedParticleEmitter"
  81898. * @returns a string containing the class name
  81899. */
  81900. getClassName(): string;
  81901. /**
  81902. * Serializes the particle system to a JSON object.
  81903. * @returns the JSON object
  81904. */
  81905. serialize(): any;
  81906. /**
  81907. * Parse properties from a JSON object
  81908. * @param serializationObject defines the JSON object
  81909. */
  81910. parse(serializationObject: any): void;
  81911. }
  81912. }
  81913. declare module BABYLON {
  81914. /**
  81915. * Interface representing a particle system in Babylon.js.
  81916. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81917. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81918. */
  81919. export interface IParticleSystem {
  81920. /**
  81921. * List of animations used by the particle system.
  81922. */
  81923. animations: Animation[];
  81924. /**
  81925. * The id of the Particle system.
  81926. */
  81927. id: string;
  81928. /**
  81929. * The name of the Particle system.
  81930. */
  81931. name: string;
  81932. /**
  81933. * The emitter represents the Mesh or position we are attaching the particle system to.
  81934. */
  81935. emitter: Nullable<AbstractMesh | Vector3>;
  81936. /**
  81937. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81938. */
  81939. isBillboardBased: boolean;
  81940. /**
  81941. * The rendering group used by the Particle system to chose when to render.
  81942. */
  81943. renderingGroupId: number;
  81944. /**
  81945. * The layer mask we are rendering the particles through.
  81946. */
  81947. layerMask: number;
  81948. /**
  81949. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81950. */
  81951. updateSpeed: number;
  81952. /**
  81953. * The amount of time the particle system is running (depends of the overall update speed).
  81954. */
  81955. targetStopDuration: number;
  81956. /**
  81957. * The texture used to render each particle. (this can be a spritesheet)
  81958. */
  81959. particleTexture: Nullable<Texture>;
  81960. /**
  81961. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81962. */
  81963. blendMode: number;
  81964. /**
  81965. * Minimum life time of emitting particles.
  81966. */
  81967. minLifeTime: number;
  81968. /**
  81969. * Maximum life time of emitting particles.
  81970. */
  81971. maxLifeTime: number;
  81972. /**
  81973. * Minimum Size of emitting particles.
  81974. */
  81975. minSize: number;
  81976. /**
  81977. * Maximum Size of emitting particles.
  81978. */
  81979. maxSize: number;
  81980. /**
  81981. * Minimum scale of emitting particles on X axis.
  81982. */
  81983. minScaleX: number;
  81984. /**
  81985. * Maximum scale of emitting particles on X axis.
  81986. */
  81987. maxScaleX: number;
  81988. /**
  81989. * Minimum scale of emitting particles on Y axis.
  81990. */
  81991. minScaleY: number;
  81992. /**
  81993. * Maximum scale of emitting particles on Y axis.
  81994. */
  81995. maxScaleY: number;
  81996. /**
  81997. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81998. */
  81999. color1: Color4;
  82000. /**
  82001. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82002. */
  82003. color2: Color4;
  82004. /**
  82005. * Color the particle will have at the end of its lifetime.
  82006. */
  82007. colorDead: Color4;
  82008. /**
  82009. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82010. */
  82011. emitRate: number;
  82012. /**
  82013. * You can use gravity if you want to give an orientation to your particles.
  82014. */
  82015. gravity: Vector3;
  82016. /**
  82017. * Minimum power of emitting particles.
  82018. */
  82019. minEmitPower: number;
  82020. /**
  82021. * Maximum power of emitting particles.
  82022. */
  82023. maxEmitPower: number;
  82024. /**
  82025. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82026. */
  82027. minAngularSpeed: number;
  82028. /**
  82029. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82030. */
  82031. maxAngularSpeed: number;
  82032. /**
  82033. * Gets or sets the minimal initial rotation in radians.
  82034. */
  82035. minInitialRotation: number;
  82036. /**
  82037. * Gets or sets the maximal initial rotation in radians.
  82038. */
  82039. maxInitialRotation: number;
  82040. /**
  82041. * The particle emitter type defines the emitter used by the particle system.
  82042. * It can be for example box, sphere, or cone...
  82043. */
  82044. particleEmitterType: Nullable<IParticleEmitterType>;
  82045. /**
  82046. * Defines the delay in milliseconds before starting the system (0 by default)
  82047. */
  82048. startDelay: number;
  82049. /**
  82050. * 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
  82051. */
  82052. preWarmCycles: number;
  82053. /**
  82054. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82055. */
  82056. preWarmStepOffset: number;
  82057. /**
  82058. * 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)
  82059. */
  82060. spriteCellChangeSpeed: number;
  82061. /**
  82062. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82063. */
  82064. startSpriteCellID: number;
  82065. /**
  82066. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82067. */
  82068. endSpriteCellID: number;
  82069. /**
  82070. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82071. */
  82072. spriteCellWidth: number;
  82073. /**
  82074. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82075. */
  82076. spriteCellHeight: number;
  82077. /**
  82078. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82079. */
  82080. spriteRandomStartCell: boolean;
  82081. /**
  82082. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82083. */
  82084. isAnimationSheetEnabled: boolean;
  82085. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82086. translationPivot: Vector2;
  82087. /**
  82088. * Gets or sets a texture used to add random noise to particle positions
  82089. */
  82090. noiseTexture: Nullable<BaseTexture>;
  82091. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82092. noiseStrength: Vector3;
  82093. /**
  82094. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82095. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82096. */
  82097. billboardMode: number;
  82098. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82099. limitVelocityDamping: number;
  82100. /**
  82101. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82102. */
  82103. beginAnimationOnStart: boolean;
  82104. /**
  82105. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82106. */
  82107. beginAnimationFrom: number;
  82108. /**
  82109. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82110. */
  82111. beginAnimationTo: number;
  82112. /**
  82113. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82114. */
  82115. beginAnimationLoop: boolean;
  82116. /**
  82117. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82118. */
  82119. disposeOnStop: boolean;
  82120. /**
  82121. * Gets the maximum number of particles active at the same time.
  82122. * @returns The max number of active particles.
  82123. */
  82124. getCapacity(): number;
  82125. /**
  82126. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82127. * @returns True if it has been started, otherwise false.
  82128. */
  82129. isStarted(): boolean;
  82130. /**
  82131. * Animates the particle system for this frame.
  82132. */
  82133. animate(): void;
  82134. /**
  82135. * Renders the particle system in its current state.
  82136. * @returns the current number of particles
  82137. */
  82138. render(): number;
  82139. /**
  82140. * Dispose the particle system and frees its associated resources.
  82141. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82142. */
  82143. dispose(disposeTexture?: boolean): void;
  82144. /**
  82145. * Clones the particle system.
  82146. * @param name The name of the cloned object
  82147. * @param newEmitter The new emitter to use
  82148. * @returns the cloned particle system
  82149. */
  82150. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82151. /**
  82152. * Serializes the particle system to a JSON object.
  82153. * @returns the JSON object
  82154. */
  82155. serialize(): any;
  82156. /**
  82157. * Rebuild the particle system
  82158. */
  82159. rebuild(): void;
  82160. /**
  82161. * Starts the particle system and begins to emit
  82162. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82163. */
  82164. start(delay?: number): void;
  82165. /**
  82166. * Stops the particle system.
  82167. */
  82168. stop(): void;
  82169. /**
  82170. * Remove all active particles
  82171. */
  82172. reset(): void;
  82173. /**
  82174. * Is this system ready to be used/rendered
  82175. * @return true if the system is ready
  82176. */
  82177. isReady(): boolean;
  82178. /**
  82179. * Adds a new color gradient
  82180. * @param gradient defines the gradient to use (between 0 and 1)
  82181. * @param color1 defines the color to affect to the specified gradient
  82182. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82183. * @returns the current particle system
  82184. */
  82185. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82186. /**
  82187. * Remove a specific color gradient
  82188. * @param gradient defines the gradient to remove
  82189. * @returns the current particle system
  82190. */
  82191. removeColorGradient(gradient: number): IParticleSystem;
  82192. /**
  82193. * Adds a new size gradient
  82194. * @param gradient defines the gradient to use (between 0 and 1)
  82195. * @param factor defines the size factor to affect to the specified gradient
  82196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82197. * @returns the current particle system
  82198. */
  82199. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82200. /**
  82201. * Remove a specific size gradient
  82202. * @param gradient defines the gradient to remove
  82203. * @returns the current particle system
  82204. */
  82205. removeSizeGradient(gradient: number): IParticleSystem;
  82206. /**
  82207. * Gets the current list of color gradients.
  82208. * You must use addColorGradient and removeColorGradient to udpate this list
  82209. * @returns the list of color gradients
  82210. */
  82211. getColorGradients(): Nullable<Array<ColorGradient>>;
  82212. /**
  82213. * Gets the current list of size gradients.
  82214. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82215. * @returns the list of size gradients
  82216. */
  82217. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82218. /**
  82219. * Gets the current list of angular speed gradients.
  82220. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82221. * @returns the list of angular speed gradients
  82222. */
  82223. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82224. /**
  82225. * Adds a new angular speed gradient
  82226. * @param gradient defines the gradient to use (between 0 and 1)
  82227. * @param factor defines the angular speed to affect to the specified gradient
  82228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82229. * @returns the current particle system
  82230. */
  82231. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82232. /**
  82233. * Remove a specific angular speed gradient
  82234. * @param gradient defines the gradient to remove
  82235. * @returns the current particle system
  82236. */
  82237. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82238. /**
  82239. * Gets the current list of velocity gradients.
  82240. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82241. * @returns the list of velocity gradients
  82242. */
  82243. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82244. /**
  82245. * Adds a new velocity gradient
  82246. * @param gradient defines the gradient to use (between 0 and 1)
  82247. * @param factor defines the velocity to affect to the specified gradient
  82248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82249. * @returns the current particle system
  82250. */
  82251. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82252. /**
  82253. * Remove a specific velocity gradient
  82254. * @param gradient defines the gradient to remove
  82255. * @returns the current particle system
  82256. */
  82257. removeVelocityGradient(gradient: number): IParticleSystem;
  82258. /**
  82259. * Gets the current list of limit velocity gradients.
  82260. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82261. * @returns the list of limit velocity gradients
  82262. */
  82263. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82264. /**
  82265. * Adds a new limit velocity gradient
  82266. * @param gradient defines the gradient to use (between 0 and 1)
  82267. * @param factor defines the limit velocity to affect to the specified gradient
  82268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82269. * @returns the current particle system
  82270. */
  82271. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82272. /**
  82273. * Remove a specific limit velocity gradient
  82274. * @param gradient defines the gradient to remove
  82275. * @returns the current particle system
  82276. */
  82277. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82278. /**
  82279. * Adds a new drag gradient
  82280. * @param gradient defines the gradient to use (between 0 and 1)
  82281. * @param factor defines the drag to affect to the specified gradient
  82282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82283. * @returns the current particle system
  82284. */
  82285. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82286. /**
  82287. * Remove a specific drag gradient
  82288. * @param gradient defines the gradient to remove
  82289. * @returns the current particle system
  82290. */
  82291. removeDragGradient(gradient: number): IParticleSystem;
  82292. /**
  82293. * Gets the current list of drag gradients.
  82294. * You must use addDragGradient and removeDragGradient to udpate this list
  82295. * @returns the list of drag gradients
  82296. */
  82297. getDragGradients(): Nullable<Array<FactorGradient>>;
  82298. /**
  82299. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82300. * @param gradient defines the gradient to use (between 0 and 1)
  82301. * @param factor defines the emit rate to affect to the specified gradient
  82302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82303. * @returns the current particle system
  82304. */
  82305. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82306. /**
  82307. * Remove a specific emit rate gradient
  82308. * @param gradient defines the gradient to remove
  82309. * @returns the current particle system
  82310. */
  82311. removeEmitRateGradient(gradient: number): IParticleSystem;
  82312. /**
  82313. * Gets the current list of emit rate gradients.
  82314. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82315. * @returns the list of emit rate gradients
  82316. */
  82317. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82318. /**
  82319. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82320. * @param gradient defines the gradient to use (between 0 and 1)
  82321. * @param factor defines the start size to affect to the specified gradient
  82322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82323. * @returns the current particle system
  82324. */
  82325. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82326. /**
  82327. * Remove a specific start size gradient
  82328. * @param gradient defines the gradient to remove
  82329. * @returns the current particle system
  82330. */
  82331. removeStartSizeGradient(gradient: number): IParticleSystem;
  82332. /**
  82333. * Gets the current list of start size gradients.
  82334. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82335. * @returns the list of start size gradients
  82336. */
  82337. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82338. /**
  82339. * Adds a new life time gradient
  82340. * @param gradient defines the gradient to use (between 0 and 1)
  82341. * @param factor defines the life time factor to affect to the specified gradient
  82342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82343. * @returns the current particle system
  82344. */
  82345. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82346. /**
  82347. * Remove a specific life time gradient
  82348. * @param gradient defines the gradient to remove
  82349. * @returns the current particle system
  82350. */
  82351. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82352. /**
  82353. * Gets the current list of life time gradients.
  82354. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82355. * @returns the list of life time gradients
  82356. */
  82357. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82358. /**
  82359. * Gets the current list of color gradients.
  82360. * You must use addColorGradient and removeColorGradient to udpate this list
  82361. * @returns the list of color gradients
  82362. */
  82363. getColorGradients(): Nullable<Array<ColorGradient>>;
  82364. /**
  82365. * Adds a new ramp gradient used to remap particle colors
  82366. * @param gradient defines the gradient to use (between 0 and 1)
  82367. * @param color defines the color to affect to the specified gradient
  82368. * @returns the current particle system
  82369. */
  82370. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82371. /**
  82372. * Gets the current list of ramp gradients.
  82373. * You must use addRampGradient and removeRampGradient to udpate this list
  82374. * @returns the list of ramp gradients
  82375. */
  82376. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82377. /** Gets or sets a boolean indicating that ramp gradients must be used
  82378. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82379. */
  82380. useRampGradients: boolean;
  82381. /**
  82382. * Adds a new color remap gradient
  82383. * @param gradient defines the gradient to use (between 0 and 1)
  82384. * @param min defines the color remap minimal range
  82385. * @param max defines the color remap maximal range
  82386. * @returns the current particle system
  82387. */
  82388. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82389. /**
  82390. * Gets the current list of color remap gradients.
  82391. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82392. * @returns the list of color remap gradients
  82393. */
  82394. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82395. /**
  82396. * Adds a new alpha remap gradient
  82397. * @param gradient defines the gradient to use (between 0 and 1)
  82398. * @param min defines the alpha remap minimal range
  82399. * @param max defines the alpha remap maximal range
  82400. * @returns the current particle system
  82401. */
  82402. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82403. /**
  82404. * Gets the current list of alpha remap gradients.
  82405. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82406. * @returns the list of alpha remap gradients
  82407. */
  82408. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82409. /**
  82410. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82413. * @returns the emitter
  82414. */
  82415. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82416. /**
  82417. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82418. * @param radius The radius of the hemisphere to emit from
  82419. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82420. * @returns the emitter
  82421. */
  82422. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82423. /**
  82424. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82425. * @param radius The radius of the sphere to emit from
  82426. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82427. * @returns the emitter
  82428. */
  82429. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82430. /**
  82431. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82432. * @param radius The radius of the sphere to emit from
  82433. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82434. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82435. * @returns the emitter
  82436. */
  82437. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82438. /**
  82439. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82440. * @param radius The radius of the emission cylinder
  82441. * @param height The height of the emission cylinder
  82442. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82443. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82444. * @returns the emitter
  82445. */
  82446. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82447. /**
  82448. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82449. * @param radius The radius of the cylinder to emit from
  82450. * @param height The height of the emission cylinder
  82451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82454. * @returns the emitter
  82455. */
  82456. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82457. /**
  82458. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82459. * @param radius The radius of the cone to emit from
  82460. * @param angle The base angle of the cone
  82461. * @returns the emitter
  82462. */
  82463. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82464. /**
  82465. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82468. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82469. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82470. * @returns the emitter
  82471. */
  82472. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82473. /**
  82474. * Get hosting scene
  82475. * @returns the scene
  82476. */
  82477. getScene(): Scene;
  82478. }
  82479. }
  82480. declare module BABYLON {
  82481. /**
  82482. * Creates an instance based on a source mesh.
  82483. */
  82484. export class InstancedMesh extends AbstractMesh {
  82485. private _sourceMesh;
  82486. private _currentLOD;
  82487. /** @hidden */
  82488. _indexInSourceMeshInstanceArray: number;
  82489. constructor(name: string, source: Mesh);
  82490. /**
  82491. * Returns the string "InstancedMesh".
  82492. */
  82493. getClassName(): string;
  82494. /** Gets the list of lights affecting that mesh */
  82495. readonly lightSources: Light[];
  82496. _resyncLightSources(): void;
  82497. _resyncLighSource(light: Light): void;
  82498. _removeLightSource(light: Light): void;
  82499. /**
  82500. * If the source mesh receives shadows
  82501. */
  82502. readonly receiveShadows: boolean;
  82503. /**
  82504. * The material of the source mesh
  82505. */
  82506. readonly material: Nullable<Material>;
  82507. /**
  82508. * Visibility of the source mesh
  82509. */
  82510. readonly visibility: number;
  82511. /**
  82512. * Skeleton of the source mesh
  82513. */
  82514. readonly skeleton: Nullable<Skeleton>;
  82515. /**
  82516. * Rendering ground id of the source mesh
  82517. */
  82518. renderingGroupId: number;
  82519. /**
  82520. * Returns the total number of vertices (integer).
  82521. */
  82522. getTotalVertices(): number;
  82523. /**
  82524. * Returns a positive integer : the total number of indices in this mesh geometry.
  82525. * @returns the numner of indices or zero if the mesh has no geometry.
  82526. */
  82527. getTotalIndices(): number;
  82528. /**
  82529. * The source mesh of the instance
  82530. */
  82531. readonly sourceMesh: Mesh;
  82532. /**
  82533. * Is this node ready to be used/rendered
  82534. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82535. * @return {boolean} is it ready
  82536. */
  82537. isReady(completeCheck?: boolean): boolean;
  82538. /**
  82539. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82540. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82541. * @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.
  82542. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82543. */
  82544. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82545. /**
  82546. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82547. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82548. * The `data` are either a numeric array either a Float32Array.
  82549. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82550. * 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).
  82551. * Note that a new underlying VertexBuffer object is created each call.
  82552. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82553. *
  82554. * Possible `kind` values :
  82555. * - VertexBuffer.PositionKind
  82556. * - VertexBuffer.UVKind
  82557. * - VertexBuffer.UV2Kind
  82558. * - VertexBuffer.UV3Kind
  82559. * - VertexBuffer.UV4Kind
  82560. * - VertexBuffer.UV5Kind
  82561. * - VertexBuffer.UV6Kind
  82562. * - VertexBuffer.ColorKind
  82563. * - VertexBuffer.MatricesIndicesKind
  82564. * - VertexBuffer.MatricesIndicesExtraKind
  82565. * - VertexBuffer.MatricesWeightsKind
  82566. * - VertexBuffer.MatricesWeightsExtraKind
  82567. *
  82568. * Returns the Mesh.
  82569. */
  82570. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82571. /**
  82572. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82573. * If the mesh has no geometry, it is simply returned as it is.
  82574. * The `data` are either a numeric array either a Float32Array.
  82575. * No new underlying VertexBuffer object is created.
  82576. * 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.
  82577. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82578. *
  82579. * Possible `kind` values :
  82580. * - VertexBuffer.PositionKind
  82581. * - VertexBuffer.UVKind
  82582. * - VertexBuffer.UV2Kind
  82583. * - VertexBuffer.UV3Kind
  82584. * - VertexBuffer.UV4Kind
  82585. * - VertexBuffer.UV5Kind
  82586. * - VertexBuffer.UV6Kind
  82587. * - VertexBuffer.ColorKind
  82588. * - VertexBuffer.MatricesIndicesKind
  82589. * - VertexBuffer.MatricesIndicesExtraKind
  82590. * - VertexBuffer.MatricesWeightsKind
  82591. * - VertexBuffer.MatricesWeightsExtraKind
  82592. *
  82593. * Returns the Mesh.
  82594. */
  82595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82596. /**
  82597. * Sets the mesh indices.
  82598. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82599. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82600. * This method creates a new index buffer each call.
  82601. * Returns the Mesh.
  82602. */
  82603. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82604. /**
  82605. * Boolean : True if the mesh owns the requested kind of data.
  82606. */
  82607. isVerticesDataPresent(kind: string): boolean;
  82608. /**
  82609. * Returns an array of indices (IndicesArray).
  82610. */
  82611. getIndices(): Nullable<IndicesArray>;
  82612. readonly _positions: Nullable<Vector3[]>;
  82613. /**
  82614. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82615. * This means the mesh underlying bounding box and sphere are recomputed.
  82616. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82617. * @returns the current mesh
  82618. */
  82619. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82620. /** @hidden */
  82621. _preActivate(): InstancedMesh;
  82622. /** @hidden */
  82623. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82624. /** @hidden */
  82625. _postActivate(): void;
  82626. getWorldMatrix(): Matrix;
  82627. readonly isAnInstance: boolean;
  82628. /**
  82629. * Returns the current associated LOD AbstractMesh.
  82630. */
  82631. getLOD(camera: Camera): AbstractMesh;
  82632. /** @hidden */
  82633. _syncSubMeshes(): InstancedMesh;
  82634. /** @hidden */
  82635. _generatePointsArray(): boolean;
  82636. /**
  82637. * Creates a new InstancedMesh from the current mesh.
  82638. * - name (string) : the cloned mesh name
  82639. * - newParent (optional Node) : the optional Node to parent the clone to.
  82640. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82641. *
  82642. * Returns the clone.
  82643. */
  82644. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82645. /**
  82646. * Disposes the InstancedMesh.
  82647. * Returns nothing.
  82648. */
  82649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82650. }
  82651. }
  82652. declare module BABYLON {
  82653. /**
  82654. * Defines the options associated with the creation of a shader material.
  82655. */
  82656. export interface IShaderMaterialOptions {
  82657. /**
  82658. * Does the material work in alpha blend mode
  82659. */
  82660. needAlphaBlending: boolean;
  82661. /**
  82662. * Does the material work in alpha test mode
  82663. */
  82664. needAlphaTesting: boolean;
  82665. /**
  82666. * The list of attribute names used in the shader
  82667. */
  82668. attributes: string[];
  82669. /**
  82670. * The list of unifrom names used in the shader
  82671. */
  82672. uniforms: string[];
  82673. /**
  82674. * The list of UBO names used in the shader
  82675. */
  82676. uniformBuffers: string[];
  82677. /**
  82678. * The list of sampler names used in the shader
  82679. */
  82680. samplers: string[];
  82681. /**
  82682. * The list of defines used in the shader
  82683. */
  82684. defines: string[];
  82685. }
  82686. /**
  82687. * 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.
  82688. *
  82689. * This returned material effects how the mesh will look based on the code in the shaders.
  82690. *
  82691. * @see http://doc.babylonjs.com/how_to/shader_material
  82692. */
  82693. export class ShaderMaterial extends Material {
  82694. private _shaderPath;
  82695. private _options;
  82696. private _textures;
  82697. private _textureArrays;
  82698. private _floats;
  82699. private _ints;
  82700. private _floatsArrays;
  82701. private _colors3;
  82702. private _colors3Arrays;
  82703. private _colors4;
  82704. private _colors4Arrays;
  82705. private _vectors2;
  82706. private _vectors3;
  82707. private _vectors4;
  82708. private _matrices;
  82709. private _matrices3x3;
  82710. private _matrices2x2;
  82711. private _vectors2Arrays;
  82712. private _vectors3Arrays;
  82713. private _vectors4Arrays;
  82714. private _cachedWorldViewMatrix;
  82715. private _cachedWorldViewProjectionMatrix;
  82716. private _renderId;
  82717. /**
  82718. * Instantiate a new shader material.
  82719. * 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.
  82720. * This returned material effects how the mesh will look based on the code in the shaders.
  82721. * @see http://doc.babylonjs.com/how_to/shader_material
  82722. * @param name Define the name of the material in the scene
  82723. * @param scene Define the scene the material belongs to
  82724. * @param shaderPath Defines the route to the shader code in one of three ways:
  82725. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82726. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82727. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82728. * @param options Define the options used to create the shader
  82729. */
  82730. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82731. /**
  82732. * Gets the options used to compile the shader.
  82733. * They can be modified to trigger a new compilation
  82734. */
  82735. readonly options: IShaderMaterialOptions;
  82736. /**
  82737. * Gets the current class name of the material e.g. "ShaderMaterial"
  82738. * Mainly use in serialization.
  82739. * @returns the class name
  82740. */
  82741. getClassName(): string;
  82742. /**
  82743. * Specifies if the material will require alpha blending
  82744. * @returns a boolean specifying if alpha blending is needed
  82745. */
  82746. needAlphaBlending(): boolean;
  82747. /**
  82748. * Specifies if this material should be rendered in alpha test mode
  82749. * @returns a boolean specifying if an alpha test is needed.
  82750. */
  82751. needAlphaTesting(): boolean;
  82752. private _checkUniform;
  82753. /**
  82754. * Set a texture in the shader.
  82755. * @param name Define the name of the uniform samplers as defined in the shader
  82756. * @param texture Define the texture to bind to this sampler
  82757. * @return the material itself allowing "fluent" like uniform updates
  82758. */
  82759. setTexture(name: string, texture: Texture): ShaderMaterial;
  82760. /**
  82761. * Set a texture array in the shader.
  82762. * @param name Define the name of the uniform sampler array as defined in the shader
  82763. * @param textures Define the list of textures to bind to this sampler
  82764. * @return the material itself allowing "fluent" like uniform updates
  82765. */
  82766. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  82767. /**
  82768. * Set a float in the shader.
  82769. * @param name Define the name of the uniform as defined in the shader
  82770. * @param value Define the value to give to the uniform
  82771. * @return the material itself allowing "fluent" like uniform updates
  82772. */
  82773. setFloat(name: string, value: number): ShaderMaterial;
  82774. /**
  82775. * Set a int in the shader.
  82776. * @param name Define the name of the uniform as defined in the shader
  82777. * @param value Define the value to give to the uniform
  82778. * @return the material itself allowing "fluent" like uniform updates
  82779. */
  82780. setInt(name: string, value: number): ShaderMaterial;
  82781. /**
  82782. * Set an array of floats in the shader.
  82783. * @param name Define the name of the uniform as defined in the shader
  82784. * @param value Define the value to give to the uniform
  82785. * @return the material itself allowing "fluent" like uniform updates
  82786. */
  82787. setFloats(name: string, value: number[]): ShaderMaterial;
  82788. /**
  82789. * Set a vec3 in the shader from a Color3.
  82790. * @param name Define the name of the uniform as defined in the shader
  82791. * @param value Define the value to give to the uniform
  82792. * @return the material itself allowing "fluent" like uniform updates
  82793. */
  82794. setColor3(name: string, value: Color3): ShaderMaterial;
  82795. /**
  82796. * Set a vec3 array in the shader from a Color3 array.
  82797. * @param name Define the name of the uniform as defined in the shader
  82798. * @param value Define the value to give to the uniform
  82799. * @return the material itself allowing "fluent" like uniform updates
  82800. */
  82801. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  82802. /**
  82803. * Set a vec4 in the shader from a Color4.
  82804. * @param name Define the name of the uniform as defined in the shader
  82805. * @param value Define the value to give to the uniform
  82806. * @return the material itself allowing "fluent" like uniform updates
  82807. */
  82808. setColor4(name: string, value: Color4): ShaderMaterial;
  82809. /**
  82810. * Set a vec4 array in the shader from a Color4 array.
  82811. * @param name Define the name of the uniform as defined in the shader
  82812. * @param value Define the value to give to the uniform
  82813. * @return the material itself allowing "fluent" like uniform updates
  82814. */
  82815. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82816. /**
  82817. * Set a vec2 in the shader from a Vector2.
  82818. * @param name Define the name of the uniform as defined in the shader
  82819. * @param value Define the value to give to the uniform
  82820. * @return the material itself allowing "fluent" like uniform updates
  82821. */
  82822. setVector2(name: string, value: Vector2): ShaderMaterial;
  82823. /**
  82824. * Set a vec3 in the shader from a Vector3.
  82825. * @param name Define the name of the uniform as defined in the shader
  82826. * @param value Define the value to give to the uniform
  82827. * @return the material itself allowing "fluent" like uniform updates
  82828. */
  82829. setVector3(name: string, value: Vector3): ShaderMaterial;
  82830. /**
  82831. * Set a vec4 in the shader from a Vector4.
  82832. * @param name Define the name of the uniform as defined in the shader
  82833. * @param value Define the value to give to the uniform
  82834. * @return the material itself allowing "fluent" like uniform updates
  82835. */
  82836. setVector4(name: string, value: Vector4): ShaderMaterial;
  82837. /**
  82838. * Set a mat4 in the shader from a Matrix.
  82839. * @param name Define the name of the uniform as defined in the shader
  82840. * @param value Define the value to give to the uniform
  82841. * @return the material itself allowing "fluent" like uniform updates
  82842. */
  82843. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82844. /**
  82845. * Set a mat3 in the shader from a Float32Array.
  82846. * @param name Define the name of the uniform as defined in the shader
  82847. * @param value Define the value to give to the uniform
  82848. * @return the material itself allowing "fluent" like uniform updates
  82849. */
  82850. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82851. /**
  82852. * Set a mat2 in the shader from a Float32Array.
  82853. * @param name Define the name of the uniform as defined in the shader
  82854. * @param value Define the value to give to the uniform
  82855. * @return the material itself allowing "fluent" like uniform updates
  82856. */
  82857. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82858. /**
  82859. * Set a vec2 array in the shader from a number array.
  82860. * @param name Define the name of the uniform as defined in the shader
  82861. * @param value Define the value to give to the uniform
  82862. * @return the material itself allowing "fluent" like uniform updates
  82863. */
  82864. setArray2(name: string, value: number[]): ShaderMaterial;
  82865. /**
  82866. * Set a vec3 array in the shader from a number array.
  82867. * @param name Define the name of the uniform as defined in the shader
  82868. * @param value Define the value to give to the uniform
  82869. * @return the material itself allowing "fluent" like uniform updates
  82870. */
  82871. setArray3(name: string, value: number[]): ShaderMaterial;
  82872. /**
  82873. * Set a vec4 array in the shader from a number array.
  82874. * @param name Define the name of the uniform as defined in the shader
  82875. * @param value Define the value to give to the uniform
  82876. * @return the material itself allowing "fluent" like uniform updates
  82877. */
  82878. setArray4(name: string, value: number[]): ShaderMaterial;
  82879. private _checkCache;
  82880. /**
  82881. * Specifies that the submesh is ready to be used
  82882. * @param mesh defines the mesh to check
  82883. * @param subMesh defines which submesh to check
  82884. * @param useInstances specifies that instances should be used
  82885. * @returns a boolean indicating that the submesh is ready or not
  82886. */
  82887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82888. /**
  82889. * Checks if the material is ready to render the requested mesh
  82890. * @param mesh Define the mesh to render
  82891. * @param useInstances Define whether or not the material is used with instances
  82892. * @returns true if ready, otherwise false
  82893. */
  82894. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82895. /**
  82896. * Binds the world matrix to the material
  82897. * @param world defines the world transformation matrix
  82898. */
  82899. bindOnlyWorldMatrix(world: Matrix): void;
  82900. /**
  82901. * Binds the material to the mesh
  82902. * @param world defines the world transformation matrix
  82903. * @param mesh defines the mesh to bind the material to
  82904. */
  82905. bind(world: Matrix, mesh?: Mesh): void;
  82906. /**
  82907. * Gets the active textures from the material
  82908. * @returns an array of textures
  82909. */
  82910. getActiveTextures(): BaseTexture[];
  82911. /**
  82912. * Specifies if the material uses a texture
  82913. * @param texture defines the texture to check against the material
  82914. * @returns a boolean specifying if the material uses the texture
  82915. */
  82916. hasTexture(texture: BaseTexture): boolean;
  82917. /**
  82918. * Makes a duplicate of the material, and gives it a new name
  82919. * @param name defines the new name for the duplicated material
  82920. * @returns the cloned material
  82921. */
  82922. clone(name: string): ShaderMaterial;
  82923. /**
  82924. * Disposes the material
  82925. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82926. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82927. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82928. */
  82929. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82930. /**
  82931. * Serializes this material in a JSON representation
  82932. * @returns the serialized material object
  82933. */
  82934. serialize(): any;
  82935. /**
  82936. * Creates a shader material from parsed shader material data
  82937. * @param source defines the JSON represnetation of the material
  82938. * @param scene defines the hosting scene
  82939. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82940. * @returns a new material
  82941. */
  82942. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82943. }
  82944. }
  82945. declare module BABYLON {
  82946. /** @hidden */
  82947. export var colorPixelShader: {
  82948. name: string;
  82949. shader: string;
  82950. };
  82951. }
  82952. declare module BABYLON {
  82953. /** @hidden */
  82954. export var colorVertexShader: {
  82955. name: string;
  82956. shader: string;
  82957. };
  82958. }
  82959. declare module BABYLON {
  82960. /**
  82961. * Line mesh
  82962. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82963. */
  82964. export class LinesMesh extends Mesh {
  82965. /**
  82966. * If vertex color should be applied to the mesh
  82967. */
  82968. readonly useVertexColor?: boolean | undefined;
  82969. /**
  82970. * If vertex alpha should be applied to the mesh
  82971. */
  82972. readonly useVertexAlpha?: boolean | undefined;
  82973. /**
  82974. * Color of the line (Default: White)
  82975. */
  82976. color: Color3;
  82977. /**
  82978. * Alpha of the line (Default: 1)
  82979. */
  82980. alpha: number;
  82981. /**
  82982. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82983. * This margin is expressed in world space coordinates, so its value may vary.
  82984. * Default value is 0.1
  82985. */
  82986. intersectionThreshold: number;
  82987. private _colorShader;
  82988. private color4;
  82989. /**
  82990. * Creates a new LinesMesh
  82991. * @param name defines the name
  82992. * @param scene defines the hosting scene
  82993. * @param parent defines the parent mesh if any
  82994. * @param source defines the optional source LinesMesh used to clone data from
  82995. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82996. * When false, achieved by calling a clone(), also passing False.
  82997. * This will make creation of children, recursive.
  82998. * @param useVertexColor defines if this LinesMesh supports vertex color
  82999. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83000. */
  83001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  83002. /**
  83003. * If vertex color should be applied to the mesh
  83004. */
  83005. useVertexColor?: boolean | undefined,
  83006. /**
  83007. * If vertex alpha should be applied to the mesh
  83008. */
  83009. useVertexAlpha?: boolean | undefined);
  83010. private _addClipPlaneDefine;
  83011. private _removeClipPlaneDefine;
  83012. isReady(): boolean;
  83013. /**
  83014. * Returns the string "LineMesh"
  83015. */
  83016. getClassName(): string;
  83017. /**
  83018. * @hidden
  83019. */
  83020. /**
  83021. * @hidden
  83022. */
  83023. material: Material;
  83024. /**
  83025. * @hidden
  83026. */
  83027. readonly checkCollisions: boolean;
  83028. /** @hidden */
  83029. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  83030. /** @hidden */
  83031. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  83032. /**
  83033. * Disposes of the line mesh
  83034. * @param doNotRecurse If children should be disposed
  83035. */
  83036. dispose(doNotRecurse?: boolean): void;
  83037. /**
  83038. * Returns a new LineMesh object cloned from the current one.
  83039. */
  83040. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83041. /**
  83042. * Creates a new InstancedLinesMesh object from the mesh model.
  83043. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83044. * @param name defines the name of the new instance
  83045. * @returns a new InstancedLinesMesh
  83046. */
  83047. createInstance(name: string): InstancedLinesMesh;
  83048. }
  83049. /**
  83050. * Creates an instance based on a source LinesMesh
  83051. */
  83052. export class InstancedLinesMesh extends InstancedMesh {
  83053. /**
  83054. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83055. * This margin is expressed in world space coordinates, so its value may vary.
  83056. * Initilized with the intersectionThreshold value of the source LinesMesh
  83057. */
  83058. intersectionThreshold: number;
  83059. constructor(name: string, source: LinesMesh);
  83060. /**
  83061. * Returns the string "InstancedLinesMesh".
  83062. */
  83063. getClassName(): string;
  83064. }
  83065. }
  83066. declare module BABYLON {
  83067. /** @hidden */
  83068. export var linePixelShader: {
  83069. name: string;
  83070. shader: string;
  83071. };
  83072. }
  83073. declare module BABYLON {
  83074. /** @hidden */
  83075. export var lineVertexShader: {
  83076. name: string;
  83077. shader: string;
  83078. };
  83079. }
  83080. declare module BABYLON {
  83081. interface AbstractMesh {
  83082. /**
  83083. * Gets the edgesRenderer associated with the mesh
  83084. */
  83085. edgesRenderer: Nullable<EdgesRenderer>;
  83086. }
  83087. interface LinesMesh {
  83088. /**
  83089. * Enables the edge rendering mode on the mesh.
  83090. * This mode makes the mesh edges visible
  83091. * @param epsilon defines the maximal distance between two angles to detect a face
  83092. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83093. * @returns the currentAbstractMesh
  83094. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83095. */
  83096. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83097. }
  83098. interface InstancedLinesMesh {
  83099. /**
  83100. * Enables the edge rendering mode on the mesh.
  83101. * This mode makes the mesh edges visible
  83102. * @param epsilon defines the maximal distance between two angles to detect a face
  83103. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83104. * @returns the current InstancedLinesMesh
  83105. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83106. */
  83107. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83108. }
  83109. /**
  83110. * Defines the minimum contract an Edges renderer should follow.
  83111. */
  83112. export interface IEdgesRenderer extends IDisposable {
  83113. /**
  83114. * Gets or sets a boolean indicating if the edgesRenderer is active
  83115. */
  83116. isEnabled: boolean;
  83117. /**
  83118. * Renders the edges of the attached mesh,
  83119. */
  83120. render(): void;
  83121. /**
  83122. * Checks wether or not the edges renderer is ready to render.
  83123. * @return true if ready, otherwise false.
  83124. */
  83125. isReady(): boolean;
  83126. }
  83127. /**
  83128. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83129. */
  83130. export class EdgesRenderer implements IEdgesRenderer {
  83131. /**
  83132. * Define the size of the edges with an orthographic camera
  83133. */
  83134. edgesWidthScalerForOrthographic: number;
  83135. /**
  83136. * Define the size of the edges with a perspective camera
  83137. */
  83138. edgesWidthScalerForPerspective: number;
  83139. protected _source: AbstractMesh;
  83140. protected _linesPositions: number[];
  83141. protected _linesNormals: number[];
  83142. protected _linesIndices: number[];
  83143. protected _epsilon: number;
  83144. protected _indicesCount: number;
  83145. protected _lineShader: ShaderMaterial;
  83146. protected _ib: DataBuffer;
  83147. protected _buffers: {
  83148. [key: string]: Nullable<VertexBuffer>;
  83149. };
  83150. protected _checkVerticesInsteadOfIndices: boolean;
  83151. private _meshRebuildObserver;
  83152. private _meshDisposeObserver;
  83153. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83154. isEnabled: boolean;
  83155. /**
  83156. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83157. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83158. * @param source Mesh used to create edges
  83159. * @param epsilon sum of angles in adjacency to check for edge
  83160. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83161. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83162. */
  83163. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83164. protected _prepareRessources(): void;
  83165. /** @hidden */
  83166. _rebuild(): void;
  83167. /**
  83168. * Releases the required resources for the edges renderer
  83169. */
  83170. dispose(): void;
  83171. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83172. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83173. /**
  83174. * Checks if the pair of p0 and p1 is en edge
  83175. * @param faceIndex
  83176. * @param edge
  83177. * @param faceNormals
  83178. * @param p0
  83179. * @param p1
  83180. * @private
  83181. */
  83182. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83183. /**
  83184. * push line into the position, normal and index buffer
  83185. * @protected
  83186. */
  83187. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83188. /**
  83189. * Generates lines edges from adjacencjes
  83190. * @private
  83191. */
  83192. _generateEdgesLines(): void;
  83193. /**
  83194. * Checks wether or not the edges renderer is ready to render.
  83195. * @return true if ready, otherwise false.
  83196. */
  83197. isReady(): boolean;
  83198. /**
  83199. * Renders the edges of the attached mesh,
  83200. */
  83201. render(): void;
  83202. }
  83203. /**
  83204. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83205. */
  83206. export class LineEdgesRenderer extends EdgesRenderer {
  83207. /**
  83208. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83209. * @param source LineMesh used to generate edges
  83210. * @param epsilon not important (specified angle for edge detection)
  83211. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83212. */
  83213. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83214. /**
  83215. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83216. */
  83217. _generateEdgesLines(): void;
  83218. }
  83219. }
  83220. declare module BABYLON {
  83221. /**
  83222. * This represents the object necessary to create a rendering group.
  83223. * This is exclusively used and created by the rendering manager.
  83224. * To modify the behavior, you use the available helpers in your scene or meshes.
  83225. * @hidden
  83226. */
  83227. export class RenderingGroup {
  83228. index: number;
  83229. private static _zeroVector;
  83230. private _scene;
  83231. private _opaqueSubMeshes;
  83232. private _transparentSubMeshes;
  83233. private _alphaTestSubMeshes;
  83234. private _depthOnlySubMeshes;
  83235. private _particleSystems;
  83236. private _spriteManagers;
  83237. private _opaqueSortCompareFn;
  83238. private _alphaTestSortCompareFn;
  83239. private _transparentSortCompareFn;
  83240. private _renderOpaque;
  83241. private _renderAlphaTest;
  83242. private _renderTransparent;
  83243. /** @hidden */
  83244. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83245. onBeforeTransparentRendering: () => void;
  83246. /**
  83247. * Set the opaque sort comparison function.
  83248. * If null the sub meshes will be render in the order they were created
  83249. */
  83250. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83251. /**
  83252. * Set the alpha test sort comparison function.
  83253. * If null the sub meshes will be render in the order they were created
  83254. */
  83255. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83256. /**
  83257. * Set the transparent sort comparison function.
  83258. * If null the sub meshes will be render in the order they were created
  83259. */
  83260. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83261. /**
  83262. * Creates a new rendering group.
  83263. * @param index The rendering group index
  83264. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83265. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83266. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83267. */
  83268. 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>);
  83269. /**
  83270. * Render all the sub meshes contained in the group.
  83271. * @param customRenderFunction Used to override the default render behaviour of the group.
  83272. * @returns true if rendered some submeshes.
  83273. */
  83274. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83275. /**
  83276. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83277. * @param subMeshes The submeshes to render
  83278. */
  83279. private renderOpaqueSorted;
  83280. /**
  83281. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83282. * @param subMeshes The submeshes to render
  83283. */
  83284. private renderAlphaTestSorted;
  83285. /**
  83286. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83287. * @param subMeshes The submeshes to render
  83288. */
  83289. private renderTransparentSorted;
  83290. /**
  83291. * Renders the submeshes in a specified order.
  83292. * @param subMeshes The submeshes to sort before render
  83293. * @param sortCompareFn The comparison function use to sort
  83294. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83295. * @param transparent Specifies to activate blending if true
  83296. */
  83297. private static renderSorted;
  83298. /**
  83299. * Renders the submeshes in the order they were dispatched (no sort applied).
  83300. * @param subMeshes The submeshes to render
  83301. */
  83302. private static renderUnsorted;
  83303. /**
  83304. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83305. * are rendered back to front if in the same alpha index.
  83306. *
  83307. * @param a The first submesh
  83308. * @param b The second submesh
  83309. * @returns The result of the comparison
  83310. */
  83311. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83312. /**
  83313. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83314. * are rendered back to front.
  83315. *
  83316. * @param a The first submesh
  83317. * @param b The second submesh
  83318. * @returns The result of the comparison
  83319. */
  83320. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83321. /**
  83322. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83323. * are rendered front to back (prevent overdraw).
  83324. *
  83325. * @param a The first submesh
  83326. * @param b The second submesh
  83327. * @returns The result of the comparison
  83328. */
  83329. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83330. /**
  83331. * Resets the different lists of submeshes to prepare a new frame.
  83332. */
  83333. prepare(): void;
  83334. dispose(): void;
  83335. /**
  83336. * Inserts the submesh in its correct queue depending on its material.
  83337. * @param subMesh The submesh to dispatch
  83338. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83339. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83340. */
  83341. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83342. dispatchSprites(spriteManager: ISpriteManager): void;
  83343. dispatchParticles(particleSystem: IParticleSystem): void;
  83344. private _renderParticles;
  83345. private _renderSprites;
  83346. }
  83347. }
  83348. declare module BABYLON {
  83349. /**
  83350. * Interface describing the different options available in the rendering manager
  83351. * regarding Auto Clear between groups.
  83352. */
  83353. export interface IRenderingManagerAutoClearSetup {
  83354. /**
  83355. * Defines whether or not autoclear is enable.
  83356. */
  83357. autoClear: boolean;
  83358. /**
  83359. * Defines whether or not to autoclear the depth buffer.
  83360. */
  83361. depth: boolean;
  83362. /**
  83363. * Defines whether or not to autoclear the stencil buffer.
  83364. */
  83365. stencil: boolean;
  83366. }
  83367. /**
  83368. * This class is used by the onRenderingGroupObservable
  83369. */
  83370. export class RenderingGroupInfo {
  83371. /**
  83372. * The Scene that being rendered
  83373. */
  83374. scene: Scene;
  83375. /**
  83376. * The camera currently used for the rendering pass
  83377. */
  83378. camera: Nullable<Camera>;
  83379. /**
  83380. * The ID of the renderingGroup being processed
  83381. */
  83382. renderingGroupId: number;
  83383. }
  83384. /**
  83385. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83386. * It is enable to manage the different groups as well as the different necessary sort functions.
  83387. * This should not be used directly aside of the few static configurations
  83388. */
  83389. export class RenderingManager {
  83390. /**
  83391. * The max id used for rendering groups (not included)
  83392. */
  83393. static MAX_RENDERINGGROUPS: number;
  83394. /**
  83395. * The min id used for rendering groups (included)
  83396. */
  83397. static MIN_RENDERINGGROUPS: number;
  83398. /**
  83399. * Used to globally prevent autoclearing scenes.
  83400. */
  83401. static AUTOCLEAR: boolean;
  83402. /**
  83403. * @hidden
  83404. */
  83405. _useSceneAutoClearSetup: boolean;
  83406. private _scene;
  83407. private _renderingGroups;
  83408. private _depthStencilBufferAlreadyCleaned;
  83409. private _autoClearDepthStencil;
  83410. private _customOpaqueSortCompareFn;
  83411. private _customAlphaTestSortCompareFn;
  83412. private _customTransparentSortCompareFn;
  83413. private _renderingGroupInfo;
  83414. /**
  83415. * Instantiates a new rendering group for a particular scene
  83416. * @param scene Defines the scene the groups belongs to
  83417. */
  83418. constructor(scene: Scene);
  83419. private _clearDepthStencilBuffer;
  83420. /**
  83421. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83422. * @hidden
  83423. */
  83424. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83425. /**
  83426. * Resets the different information of the group to prepare a new frame
  83427. * @hidden
  83428. */
  83429. reset(): void;
  83430. /**
  83431. * Dispose and release the group and its associated resources.
  83432. * @hidden
  83433. */
  83434. dispose(): void;
  83435. /**
  83436. * Clear the info related to rendering groups preventing retention points during dispose.
  83437. */
  83438. freeRenderingGroups(): void;
  83439. private _prepareRenderingGroup;
  83440. /**
  83441. * Add a sprite manager to the rendering manager in order to render it this frame.
  83442. * @param spriteManager Define the sprite manager to render
  83443. */
  83444. dispatchSprites(spriteManager: ISpriteManager): void;
  83445. /**
  83446. * Add a particle system to the rendering manager in order to render it this frame.
  83447. * @param particleSystem Define the particle system to render
  83448. */
  83449. dispatchParticles(particleSystem: IParticleSystem): void;
  83450. /**
  83451. * Add a submesh to the manager in order to render it this frame
  83452. * @param subMesh The submesh to dispatch
  83453. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83454. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83455. */
  83456. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83457. /**
  83458. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83459. * This allowed control for front to back rendering or reversly depending of the special needs.
  83460. *
  83461. * @param renderingGroupId The rendering group id corresponding to its index
  83462. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83463. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83464. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83465. */
  83466. 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;
  83467. /**
  83468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83469. *
  83470. * @param renderingGroupId The rendering group id corresponding to its index
  83471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83472. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83473. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83474. */
  83475. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83476. /**
  83477. * Gets the current auto clear configuration for one rendering group of the rendering
  83478. * manager.
  83479. * @param index the rendering group index to get the information for
  83480. * @returns The auto clear setup for the requested rendering group
  83481. */
  83482. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83483. }
  83484. }
  83485. declare module BABYLON {
  83486. /**
  83487. * This Helps creating a texture that will be created from a camera in your scene.
  83488. * It is basically a dynamic texture that could be used to create special effects for instance.
  83489. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83490. */
  83491. export class RenderTargetTexture extends Texture {
  83492. isCube: boolean;
  83493. /**
  83494. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83495. */
  83496. static readonly REFRESHRATE_RENDER_ONCE: number;
  83497. /**
  83498. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83499. */
  83500. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83501. /**
  83502. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83503. * the central point of your effect and can save a lot of performances.
  83504. */
  83505. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83506. /**
  83507. * Use this predicate to dynamically define the list of mesh you want to render.
  83508. * If set, the renderList property will be overwritten.
  83509. */
  83510. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83511. private _renderList;
  83512. /**
  83513. * Use this list to define the list of mesh you want to render.
  83514. */
  83515. renderList: Nullable<Array<AbstractMesh>>;
  83516. private _hookArray;
  83517. /**
  83518. * Define if particles should be rendered in your texture.
  83519. */
  83520. renderParticles: boolean;
  83521. /**
  83522. * Define if sprites should be rendered in your texture.
  83523. */
  83524. renderSprites: boolean;
  83525. /**
  83526. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83527. */
  83528. coordinatesMode: number;
  83529. /**
  83530. * Define the camera used to render the texture.
  83531. */
  83532. activeCamera: Nullable<Camera>;
  83533. /**
  83534. * Override the render function of the texture with your own one.
  83535. */
  83536. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83537. /**
  83538. * Define if camera post processes should be use while rendering the texture.
  83539. */
  83540. useCameraPostProcesses: boolean;
  83541. /**
  83542. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83543. */
  83544. ignoreCameraViewport: boolean;
  83545. private _postProcessManager;
  83546. private _postProcesses;
  83547. private _resizeObserver;
  83548. /**
  83549. * An event triggered when the texture is unbind.
  83550. */
  83551. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83552. /**
  83553. * An event triggered when the texture is unbind.
  83554. */
  83555. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83556. private _onAfterUnbindObserver;
  83557. /**
  83558. * Set a after unbind callback in the texture.
  83559. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83560. */
  83561. onAfterUnbind: () => void;
  83562. /**
  83563. * An event triggered before rendering the texture
  83564. */
  83565. onBeforeRenderObservable: Observable<number>;
  83566. private _onBeforeRenderObserver;
  83567. /**
  83568. * Set a before render callback in the texture.
  83569. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83570. */
  83571. onBeforeRender: (faceIndex: number) => void;
  83572. /**
  83573. * An event triggered after rendering the texture
  83574. */
  83575. onAfterRenderObservable: Observable<number>;
  83576. private _onAfterRenderObserver;
  83577. /**
  83578. * Set a after render callback in the texture.
  83579. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83580. */
  83581. onAfterRender: (faceIndex: number) => void;
  83582. /**
  83583. * An event triggered after the texture clear
  83584. */
  83585. onClearObservable: Observable<Engine>;
  83586. private _onClearObserver;
  83587. /**
  83588. * Set a clear callback in the texture.
  83589. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83590. */
  83591. onClear: (Engine: Engine) => void;
  83592. /**
  83593. * An event triggered when the texture is resized.
  83594. */
  83595. onResizeObservable: Observable<RenderTargetTexture>;
  83596. /**
  83597. * Define the clear color of the Render Target if it should be different from the scene.
  83598. */
  83599. clearColor: Color4;
  83600. protected _size: number | {
  83601. width: number;
  83602. height: number;
  83603. };
  83604. protected _initialSizeParameter: number | {
  83605. width: number;
  83606. height: number;
  83607. } | {
  83608. ratio: number;
  83609. };
  83610. protected _sizeRatio: Nullable<number>;
  83611. /** @hidden */
  83612. _generateMipMaps: boolean;
  83613. protected _renderingManager: RenderingManager;
  83614. /** @hidden */
  83615. _waitingRenderList: string[];
  83616. protected _doNotChangeAspectRatio: boolean;
  83617. protected _currentRefreshId: number;
  83618. protected _refreshRate: number;
  83619. protected _textureMatrix: Matrix;
  83620. protected _samples: number;
  83621. protected _renderTargetOptions: RenderTargetCreationOptions;
  83622. /**
  83623. * Gets render target creation options that were used.
  83624. */
  83625. readonly renderTargetOptions: RenderTargetCreationOptions;
  83626. protected _engine: Engine;
  83627. protected _onRatioRescale(): void;
  83628. /**
  83629. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83630. * It must define where the camera used to render the texture is set
  83631. */
  83632. boundingBoxPosition: Vector3;
  83633. private _boundingBoxSize;
  83634. /**
  83635. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83636. * When defined, the cubemap will switch to local mode
  83637. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83638. * @example https://www.babylonjs-playground.com/#RNASML
  83639. */
  83640. boundingBoxSize: Vector3;
  83641. /**
  83642. * In case the RTT has been created with a depth texture, get the associated
  83643. * depth texture.
  83644. * Otherwise, return null.
  83645. */
  83646. depthStencilTexture: Nullable<InternalTexture>;
  83647. /**
  83648. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83649. * or used a shadow, depth texture...
  83650. * @param name The friendly name of the texture
  83651. * @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)
  83652. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83653. * @param generateMipMaps True if mip maps need to be generated after render.
  83654. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83655. * @param type The type of the buffer in the RTT (int, half float, float...)
  83656. * @param isCube True if a cube texture needs to be created
  83657. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83658. * @param generateDepthBuffer True to generate a depth buffer
  83659. * @param generateStencilBuffer True to generate a stencil buffer
  83660. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83661. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83662. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83663. */
  83664. constructor(name: string, size: number | {
  83665. width: number;
  83666. height: number;
  83667. } | {
  83668. ratio: number;
  83669. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83670. /**
  83671. * Creates a depth stencil texture.
  83672. * This is only available in WebGL 2 or with the depth texture extension available.
  83673. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83674. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83675. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83676. */
  83677. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83678. private _processSizeParameter;
  83679. /**
  83680. * Define the number of samples to use in case of MSAA.
  83681. * It defaults to one meaning no MSAA has been enabled.
  83682. */
  83683. samples: number;
  83684. /**
  83685. * Resets the refresh counter of the texture and start bak from scratch.
  83686. * Could be useful to regenerate the texture if it is setup to render only once.
  83687. */
  83688. resetRefreshCounter(): void;
  83689. /**
  83690. * Define the refresh rate of the texture or the rendering frequency.
  83691. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83692. */
  83693. refreshRate: number;
  83694. /**
  83695. * Adds a post process to the render target rendering passes.
  83696. * @param postProcess define the post process to add
  83697. */
  83698. addPostProcess(postProcess: PostProcess): void;
  83699. /**
  83700. * Clear all the post processes attached to the render target
  83701. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83702. */
  83703. clearPostProcesses(dispose?: boolean): void;
  83704. /**
  83705. * Remove one of the post process from the list of attached post processes to the texture
  83706. * @param postProcess define the post process to remove from the list
  83707. */
  83708. removePostProcess(postProcess: PostProcess): void;
  83709. /** @hidden */
  83710. _shouldRender(): boolean;
  83711. /**
  83712. * Gets the actual render size of the texture.
  83713. * @returns the width of the render size
  83714. */
  83715. getRenderSize(): number;
  83716. /**
  83717. * Gets the actual render width of the texture.
  83718. * @returns the width of the render size
  83719. */
  83720. getRenderWidth(): number;
  83721. /**
  83722. * Gets the actual render height of the texture.
  83723. * @returns the height of the render size
  83724. */
  83725. getRenderHeight(): number;
  83726. /**
  83727. * Get if the texture can be rescaled or not.
  83728. */
  83729. readonly canRescale: boolean;
  83730. /**
  83731. * Resize the texture using a ratio.
  83732. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83733. */
  83734. scale(ratio: number): void;
  83735. /**
  83736. * Get the texture reflection matrix used to rotate/transform the reflection.
  83737. * @returns the reflection matrix
  83738. */
  83739. getReflectionTextureMatrix(): Matrix;
  83740. /**
  83741. * Resize the texture to a new desired size.
  83742. * Be carrefull as it will recreate all the data in the new texture.
  83743. * @param size Define the new size. It can be:
  83744. * - a number for squared texture,
  83745. * - an object containing { width: number, height: number }
  83746. * - or an object containing a ratio { ratio: number }
  83747. */
  83748. resize(size: number | {
  83749. width: number;
  83750. height: number;
  83751. } | {
  83752. ratio: number;
  83753. }): void;
  83754. /**
  83755. * Renders all the objects from the render list into the texture.
  83756. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  83757. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  83758. */
  83759. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  83760. private _bestReflectionRenderTargetDimension;
  83761. /**
  83762. * @hidden
  83763. * @param faceIndex face index to bind to if this is a cubetexture
  83764. */
  83765. _bindFrameBuffer(faceIndex?: number): void;
  83766. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83767. private renderToTarget;
  83768. /**
  83769. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83770. * This allowed control for front to back rendering or reversly depending of the special needs.
  83771. *
  83772. * @param renderingGroupId The rendering group id corresponding to its index
  83773. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83774. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83775. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83776. */
  83777. 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;
  83778. /**
  83779. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83780. *
  83781. * @param renderingGroupId The rendering group id corresponding to its index
  83782. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83783. */
  83784. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  83785. /**
  83786. * Clones the texture.
  83787. * @returns the cloned texture
  83788. */
  83789. clone(): RenderTargetTexture;
  83790. /**
  83791. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83792. * @returns The JSON representation of the texture
  83793. */
  83794. serialize(): any;
  83795. /**
  83796. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  83797. */
  83798. disposeFramebufferObjects(): void;
  83799. /**
  83800. * Dispose the texture and release its associated resources.
  83801. */
  83802. dispose(): void;
  83803. /** @hidden */
  83804. _rebuild(): void;
  83805. /**
  83806. * Clear the info related to rendering groups preventing retention point in material dispose.
  83807. */
  83808. freeRenderingGroups(): void;
  83809. /**
  83810. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83811. * @returns the view count
  83812. */
  83813. getViewCount(): number;
  83814. }
  83815. }
  83816. declare module BABYLON {
  83817. /**
  83818. * Base class for the main features of a material in Babylon.js
  83819. */
  83820. export class Material implements IAnimatable {
  83821. /**
  83822. * Returns the triangle fill mode
  83823. */
  83824. static readonly TriangleFillMode: number;
  83825. /**
  83826. * Returns the wireframe mode
  83827. */
  83828. static readonly WireFrameFillMode: number;
  83829. /**
  83830. * Returns the point fill mode
  83831. */
  83832. static readonly PointFillMode: number;
  83833. /**
  83834. * Returns the point list draw mode
  83835. */
  83836. static readonly PointListDrawMode: number;
  83837. /**
  83838. * Returns the line list draw mode
  83839. */
  83840. static readonly LineListDrawMode: number;
  83841. /**
  83842. * Returns the line loop draw mode
  83843. */
  83844. static readonly LineLoopDrawMode: number;
  83845. /**
  83846. * Returns the line strip draw mode
  83847. */
  83848. static readonly LineStripDrawMode: number;
  83849. /**
  83850. * Returns the triangle strip draw mode
  83851. */
  83852. static readonly TriangleStripDrawMode: number;
  83853. /**
  83854. * Returns the triangle fan draw mode
  83855. */
  83856. static readonly TriangleFanDrawMode: number;
  83857. /**
  83858. * Stores the clock-wise side orientation
  83859. */
  83860. static readonly ClockWiseSideOrientation: number;
  83861. /**
  83862. * Stores the counter clock-wise side orientation
  83863. */
  83864. static readonly CounterClockWiseSideOrientation: number;
  83865. /**
  83866. * The dirty texture flag value
  83867. */
  83868. static readonly TextureDirtyFlag: number;
  83869. /**
  83870. * The dirty light flag value
  83871. */
  83872. static readonly LightDirtyFlag: number;
  83873. /**
  83874. * The dirty fresnel flag value
  83875. */
  83876. static readonly FresnelDirtyFlag: number;
  83877. /**
  83878. * The dirty attribute flag value
  83879. */
  83880. static readonly AttributesDirtyFlag: number;
  83881. /**
  83882. * The dirty misc flag value
  83883. */
  83884. static readonly MiscDirtyFlag: number;
  83885. /**
  83886. * The all dirty flag value
  83887. */
  83888. static readonly AllDirtyFlag: number;
  83889. /**
  83890. * The ID of the material
  83891. */
  83892. id: string;
  83893. /**
  83894. * Gets or sets the unique id of the material
  83895. */
  83896. uniqueId: number;
  83897. /**
  83898. * The name of the material
  83899. */
  83900. name: string;
  83901. /**
  83902. * Gets or sets user defined metadata
  83903. */
  83904. metadata: any;
  83905. /**
  83906. * For internal use only. Please do not use.
  83907. */
  83908. reservedDataStore: any;
  83909. /**
  83910. * Specifies if the ready state should be checked on each call
  83911. */
  83912. checkReadyOnEveryCall: boolean;
  83913. /**
  83914. * Specifies if the ready state should be checked once
  83915. */
  83916. checkReadyOnlyOnce: boolean;
  83917. /**
  83918. * The state of the material
  83919. */
  83920. state: string;
  83921. /**
  83922. * The alpha value of the material
  83923. */
  83924. protected _alpha: number;
  83925. /**
  83926. * List of inspectable custom properties (used by the Inspector)
  83927. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83928. */
  83929. inspectableCustomProperties: IInspectable[];
  83930. /**
  83931. * Sets the alpha value of the material
  83932. */
  83933. /**
  83934. * Gets the alpha value of the material
  83935. */
  83936. alpha: number;
  83937. /**
  83938. * Specifies if back face culling is enabled
  83939. */
  83940. protected _backFaceCulling: boolean;
  83941. /**
  83942. * Sets the back-face culling state
  83943. */
  83944. /**
  83945. * Gets the back-face culling state
  83946. */
  83947. backFaceCulling: boolean;
  83948. /**
  83949. * Stores the value for side orientation
  83950. */
  83951. sideOrientation: number;
  83952. /**
  83953. * Callback triggered when the material is compiled
  83954. */
  83955. onCompiled: Nullable<(effect: Effect) => void>;
  83956. /**
  83957. * Callback triggered when an error occurs
  83958. */
  83959. onError: Nullable<(effect: Effect, errors: string) => void>;
  83960. /**
  83961. * Callback triggered to get the render target textures
  83962. */
  83963. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83964. /**
  83965. * Gets a boolean indicating that current material needs to register RTT
  83966. */
  83967. readonly hasRenderTargetTextures: boolean;
  83968. /**
  83969. * Specifies if the material should be serialized
  83970. */
  83971. doNotSerialize: boolean;
  83972. /**
  83973. * @hidden
  83974. */
  83975. _storeEffectOnSubMeshes: boolean;
  83976. /**
  83977. * Stores the animations for the material
  83978. */
  83979. animations: Nullable<Array<Animation>>;
  83980. /**
  83981. * An event triggered when the material is disposed
  83982. */
  83983. onDisposeObservable: Observable<Material>;
  83984. /**
  83985. * An observer which watches for dispose events
  83986. */
  83987. private _onDisposeObserver;
  83988. private _onUnBindObservable;
  83989. /**
  83990. * Called during a dispose event
  83991. */
  83992. onDispose: () => void;
  83993. private _onBindObservable;
  83994. /**
  83995. * An event triggered when the material is bound
  83996. */
  83997. readonly onBindObservable: Observable<AbstractMesh>;
  83998. /**
  83999. * An observer which watches for bind events
  84000. */
  84001. private _onBindObserver;
  84002. /**
  84003. * Called during a bind event
  84004. */
  84005. onBind: (Mesh: AbstractMesh) => void;
  84006. /**
  84007. * An event triggered when the material is unbound
  84008. */
  84009. readonly onUnBindObservable: Observable<Material>;
  84010. /**
  84011. * Stores the value of the alpha mode
  84012. */
  84013. private _alphaMode;
  84014. /**
  84015. * Sets the value of the alpha mode.
  84016. *
  84017. * | Value | Type | Description |
  84018. * | --- | --- | --- |
  84019. * | 0 | ALPHA_DISABLE | |
  84020. * | 1 | ALPHA_ADD | |
  84021. * | 2 | ALPHA_COMBINE | |
  84022. * | 3 | ALPHA_SUBTRACT | |
  84023. * | 4 | ALPHA_MULTIPLY | |
  84024. * | 5 | ALPHA_MAXIMIZED | |
  84025. * | 6 | ALPHA_ONEONE | |
  84026. * | 7 | ALPHA_PREMULTIPLIED | |
  84027. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84028. * | 9 | ALPHA_INTERPOLATE | |
  84029. * | 10 | ALPHA_SCREENMODE | |
  84030. *
  84031. */
  84032. /**
  84033. * Gets the value of the alpha mode
  84034. */
  84035. alphaMode: number;
  84036. /**
  84037. * Stores the state of the need depth pre-pass value
  84038. */
  84039. private _needDepthPrePass;
  84040. /**
  84041. * Sets the need depth pre-pass value
  84042. */
  84043. /**
  84044. * Gets the depth pre-pass value
  84045. */
  84046. needDepthPrePass: boolean;
  84047. /**
  84048. * Specifies if depth writing should be disabled
  84049. */
  84050. disableDepthWrite: boolean;
  84051. /**
  84052. * Specifies if depth writing should be forced
  84053. */
  84054. forceDepthWrite: boolean;
  84055. /**
  84056. * Specifies if there should be a separate pass for culling
  84057. */
  84058. separateCullingPass: boolean;
  84059. /**
  84060. * Stores the state specifing if fog should be enabled
  84061. */
  84062. private _fogEnabled;
  84063. /**
  84064. * Sets the state for enabling fog
  84065. */
  84066. /**
  84067. * Gets the value of the fog enabled state
  84068. */
  84069. fogEnabled: boolean;
  84070. /**
  84071. * Stores the size of points
  84072. */
  84073. pointSize: number;
  84074. /**
  84075. * Stores the z offset value
  84076. */
  84077. zOffset: number;
  84078. /**
  84079. * Gets a value specifying if wireframe mode is enabled
  84080. */
  84081. /**
  84082. * Sets the state of wireframe mode
  84083. */
  84084. wireframe: boolean;
  84085. /**
  84086. * Gets the value specifying if point clouds are enabled
  84087. */
  84088. /**
  84089. * Sets the state of point cloud mode
  84090. */
  84091. pointsCloud: boolean;
  84092. /**
  84093. * Gets the material fill mode
  84094. */
  84095. /**
  84096. * Sets the material fill mode
  84097. */
  84098. fillMode: number;
  84099. /**
  84100. * @hidden
  84101. * Stores the effects for the material
  84102. */
  84103. _effect: Nullable<Effect>;
  84104. /**
  84105. * @hidden
  84106. * Specifies if the material was previously ready
  84107. */
  84108. _wasPreviouslyReady: boolean;
  84109. /**
  84110. * Specifies if uniform buffers should be used
  84111. */
  84112. private _useUBO;
  84113. /**
  84114. * Stores a reference to the scene
  84115. */
  84116. private _scene;
  84117. /**
  84118. * Stores the fill mode state
  84119. */
  84120. private _fillMode;
  84121. /**
  84122. * Specifies if the depth write state should be cached
  84123. */
  84124. private _cachedDepthWriteState;
  84125. /**
  84126. * Stores the uniform buffer
  84127. */
  84128. protected _uniformBuffer: UniformBuffer;
  84129. /** @hidden */
  84130. _indexInSceneMaterialArray: number;
  84131. /** @hidden */
  84132. meshMap: Nullable<{
  84133. [id: string]: AbstractMesh | undefined;
  84134. }>;
  84135. /**
  84136. * Creates a material instance
  84137. * @param name defines the name of the material
  84138. * @param scene defines the scene to reference
  84139. * @param doNotAdd specifies if the material should be added to the scene
  84140. */
  84141. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84142. /**
  84143. * Returns a string representation of the current material
  84144. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84145. * @returns a string with material information
  84146. */
  84147. toString(fullDetails?: boolean): string;
  84148. /**
  84149. * Gets the class name of the material
  84150. * @returns a string with the class name of the material
  84151. */
  84152. getClassName(): string;
  84153. /**
  84154. * Specifies if updates for the material been locked
  84155. */
  84156. readonly isFrozen: boolean;
  84157. /**
  84158. * Locks updates for the material
  84159. */
  84160. freeze(): void;
  84161. /**
  84162. * Unlocks updates for the material
  84163. */
  84164. unfreeze(): void;
  84165. /**
  84166. * Specifies if the material is ready to be used
  84167. * @param mesh defines the mesh to check
  84168. * @param useInstances specifies if instances should be used
  84169. * @returns a boolean indicating if the material is ready to be used
  84170. */
  84171. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84172. /**
  84173. * Specifies that the submesh is ready to be used
  84174. * @param mesh defines the mesh to check
  84175. * @param subMesh defines which submesh to check
  84176. * @param useInstances specifies that instances should be used
  84177. * @returns a boolean indicating that the submesh is ready or not
  84178. */
  84179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84180. /**
  84181. * Returns the material effect
  84182. * @returns the effect associated with the material
  84183. */
  84184. getEffect(): Nullable<Effect>;
  84185. /**
  84186. * Returns the current scene
  84187. * @returns a Scene
  84188. */
  84189. getScene(): Scene;
  84190. /**
  84191. * Specifies if the material will require alpha blending
  84192. * @returns a boolean specifying if alpha blending is needed
  84193. */
  84194. needAlphaBlending(): boolean;
  84195. /**
  84196. * Specifies if the mesh will require alpha blending
  84197. * @param mesh defines the mesh to check
  84198. * @returns a boolean specifying if alpha blending is needed for the mesh
  84199. */
  84200. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84201. /**
  84202. * Specifies if this material should be rendered in alpha test mode
  84203. * @returns a boolean specifying if an alpha test is needed.
  84204. */
  84205. needAlphaTesting(): boolean;
  84206. /**
  84207. * Gets the texture used for the alpha test
  84208. * @returns the texture to use for alpha testing
  84209. */
  84210. getAlphaTestTexture(): Nullable<BaseTexture>;
  84211. /**
  84212. * Marks the material to indicate that it needs to be re-calculated
  84213. */
  84214. markDirty(): void;
  84215. /** @hidden */
  84216. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84217. /**
  84218. * Binds the material to the mesh
  84219. * @param world defines the world transformation matrix
  84220. * @param mesh defines the mesh to bind the material to
  84221. */
  84222. bind(world: Matrix, mesh?: Mesh): void;
  84223. /**
  84224. * Binds the submesh to the material
  84225. * @param world defines the world transformation matrix
  84226. * @param mesh defines the mesh containing the submesh
  84227. * @param subMesh defines the submesh to bind the material to
  84228. */
  84229. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84230. /**
  84231. * Binds the world matrix to the material
  84232. * @param world defines the world transformation matrix
  84233. */
  84234. bindOnlyWorldMatrix(world: Matrix): void;
  84235. /**
  84236. * Binds the scene's uniform buffer to the effect.
  84237. * @param effect defines the effect to bind to the scene uniform buffer
  84238. * @param sceneUbo defines the uniform buffer storing scene data
  84239. */
  84240. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84241. /**
  84242. * Binds the view matrix to the effect
  84243. * @param effect defines the effect to bind the view matrix to
  84244. */
  84245. bindView(effect: Effect): void;
  84246. /**
  84247. * Binds the view projection matrix to the effect
  84248. * @param effect defines the effect to bind the view projection matrix to
  84249. */
  84250. bindViewProjection(effect: Effect): void;
  84251. /**
  84252. * Specifies if material alpha testing should be turned on for the mesh
  84253. * @param mesh defines the mesh to check
  84254. */
  84255. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84256. /**
  84257. * Processes to execute after binding the material to a mesh
  84258. * @param mesh defines the rendered mesh
  84259. */
  84260. protected _afterBind(mesh?: Mesh): void;
  84261. /**
  84262. * Unbinds the material from the mesh
  84263. */
  84264. unbind(): void;
  84265. /**
  84266. * Gets the active textures from the material
  84267. * @returns an array of textures
  84268. */
  84269. getActiveTextures(): BaseTexture[];
  84270. /**
  84271. * Specifies if the material uses a texture
  84272. * @param texture defines the texture to check against the material
  84273. * @returns a boolean specifying if the material uses the texture
  84274. */
  84275. hasTexture(texture: BaseTexture): boolean;
  84276. /**
  84277. * Makes a duplicate of the material, and gives it a new name
  84278. * @param name defines the new name for the duplicated material
  84279. * @returns the cloned material
  84280. */
  84281. clone(name: string): Nullable<Material>;
  84282. /**
  84283. * Gets the meshes bound to the material
  84284. * @returns an array of meshes bound to the material
  84285. */
  84286. getBindedMeshes(): AbstractMesh[];
  84287. /**
  84288. * Force shader compilation
  84289. * @param mesh defines the mesh associated with this material
  84290. * @param onCompiled defines a function to execute once the material is compiled
  84291. * @param options defines the options to configure the compilation
  84292. */
  84293. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84294. clipPlane: boolean;
  84295. }>): void;
  84296. /**
  84297. * Force shader compilation
  84298. * @param mesh defines the mesh that will use this material
  84299. * @param options defines additional options for compiling the shaders
  84300. * @returns a promise that resolves when the compilation completes
  84301. */
  84302. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84303. clipPlane: boolean;
  84304. }>): Promise<void>;
  84305. private static readonly _AllDirtyCallBack;
  84306. private static readonly _ImageProcessingDirtyCallBack;
  84307. private static readonly _TextureDirtyCallBack;
  84308. private static readonly _FresnelDirtyCallBack;
  84309. private static readonly _MiscDirtyCallBack;
  84310. private static readonly _LightsDirtyCallBack;
  84311. private static readonly _AttributeDirtyCallBack;
  84312. private static _FresnelAndMiscDirtyCallBack;
  84313. private static _TextureAndMiscDirtyCallBack;
  84314. private static readonly _DirtyCallbackArray;
  84315. private static readonly _RunDirtyCallBacks;
  84316. /**
  84317. * Marks a define in the material to indicate that it needs to be re-computed
  84318. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84319. */
  84320. markAsDirty(flag: number): void;
  84321. /**
  84322. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84323. * @param func defines a function which checks material defines against the submeshes
  84324. */
  84325. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84326. /**
  84327. * Indicates that we need to re-calculated for all submeshes
  84328. */
  84329. protected _markAllSubMeshesAsAllDirty(): void;
  84330. /**
  84331. * Indicates that image processing needs to be re-calculated for all submeshes
  84332. */
  84333. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84334. /**
  84335. * Indicates that textures need to be re-calculated for all submeshes
  84336. */
  84337. protected _markAllSubMeshesAsTexturesDirty(): void;
  84338. /**
  84339. * Indicates that fresnel needs to be re-calculated for all submeshes
  84340. */
  84341. protected _markAllSubMeshesAsFresnelDirty(): void;
  84342. /**
  84343. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84344. */
  84345. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84346. /**
  84347. * Indicates that lights need to be re-calculated for all submeshes
  84348. */
  84349. protected _markAllSubMeshesAsLightsDirty(): void;
  84350. /**
  84351. * Indicates that attributes need to be re-calculated for all submeshes
  84352. */
  84353. protected _markAllSubMeshesAsAttributesDirty(): void;
  84354. /**
  84355. * Indicates that misc needs to be re-calculated for all submeshes
  84356. */
  84357. protected _markAllSubMeshesAsMiscDirty(): void;
  84358. /**
  84359. * Indicates that textures and misc need to be re-calculated for all submeshes
  84360. */
  84361. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84362. /**
  84363. * Disposes the material
  84364. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84365. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84366. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84367. */
  84368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84369. /** @hidden */
  84370. private releaseVertexArrayObject;
  84371. /**
  84372. * Serializes this material
  84373. * @returns the serialized material object
  84374. */
  84375. serialize(): any;
  84376. /**
  84377. * Creates a material from parsed material data
  84378. * @param parsedMaterial defines parsed material data
  84379. * @param scene defines the hosting scene
  84380. * @param rootUrl defines the root URL to use to load textures
  84381. * @returns a new material
  84382. */
  84383. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84384. }
  84385. }
  84386. declare module BABYLON {
  84387. /**
  84388. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84389. * separate meshes. This can be use to improve performances.
  84390. * @see http://doc.babylonjs.com/how_to/multi_materials
  84391. */
  84392. export class MultiMaterial extends Material {
  84393. private _subMaterials;
  84394. /**
  84395. * Gets or Sets the list of Materials used within the multi material.
  84396. * They need to be ordered according to the submeshes order in the associated mesh
  84397. */
  84398. subMaterials: Nullable<Material>[];
  84399. /**
  84400. * Function used to align with Node.getChildren()
  84401. * @returns the list of Materials used within the multi material
  84402. */
  84403. getChildren(): Nullable<Material>[];
  84404. /**
  84405. * Instantiates a new Multi Material
  84406. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84407. * separate meshes. This can be use to improve performances.
  84408. * @see http://doc.babylonjs.com/how_to/multi_materials
  84409. * @param name Define the name in the scene
  84410. * @param scene Define the scene the material belongs to
  84411. */
  84412. constructor(name: string, scene: Scene);
  84413. private _hookArray;
  84414. /**
  84415. * Get one of the submaterial by its index in the submaterials array
  84416. * @param index The index to look the sub material at
  84417. * @returns The Material if the index has been defined
  84418. */
  84419. getSubMaterial(index: number): Nullable<Material>;
  84420. /**
  84421. * Get the list of active textures for the whole sub materials list.
  84422. * @returns All the textures that will be used during the rendering
  84423. */
  84424. getActiveTextures(): BaseTexture[];
  84425. /**
  84426. * Gets the current class name of the material e.g. "MultiMaterial"
  84427. * Mainly use in serialization.
  84428. * @returns the class name
  84429. */
  84430. getClassName(): string;
  84431. /**
  84432. * Checks if the material is ready to render the requested sub mesh
  84433. * @param mesh Define the mesh the submesh belongs to
  84434. * @param subMesh Define the sub mesh to look readyness for
  84435. * @param useInstances Define whether or not the material is used with instances
  84436. * @returns true if ready, otherwise false
  84437. */
  84438. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84439. /**
  84440. * Clones the current material and its related sub materials
  84441. * @param name Define the name of the newly cloned material
  84442. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84443. * @returns the cloned material
  84444. */
  84445. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84446. /**
  84447. * Serializes the materials into a JSON representation.
  84448. * @returns the JSON representation
  84449. */
  84450. serialize(): any;
  84451. /**
  84452. * Dispose the material and release its associated resources
  84453. * @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)
  84454. * @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)
  84455. * @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)
  84456. */
  84457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84458. /**
  84459. * Creates a MultiMaterial from parsed MultiMaterial data.
  84460. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84461. * @param scene defines the hosting scene
  84462. * @returns a new MultiMaterial
  84463. */
  84464. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84465. }
  84466. }
  84467. declare module BABYLON {
  84468. /**
  84469. * Base class for submeshes
  84470. */
  84471. export class BaseSubMesh {
  84472. /** @hidden */
  84473. _materialDefines: Nullable<MaterialDefines>;
  84474. /** @hidden */
  84475. _materialEffect: Nullable<Effect>;
  84476. /**
  84477. * Gets associated effect
  84478. */
  84479. readonly effect: Nullable<Effect>;
  84480. /**
  84481. * Sets associated effect (effect used to render this submesh)
  84482. * @param effect defines the effect to associate with
  84483. * @param defines defines the set of defines used to compile this effect
  84484. */
  84485. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84486. }
  84487. /**
  84488. * Defines a subdivision inside a mesh
  84489. */
  84490. export class SubMesh extends BaseSubMesh implements ICullable {
  84491. /** the material index to use */
  84492. materialIndex: number;
  84493. /** vertex index start */
  84494. verticesStart: number;
  84495. /** vertices count */
  84496. verticesCount: number;
  84497. /** index start */
  84498. indexStart: number;
  84499. /** indices count */
  84500. indexCount: number;
  84501. /** @hidden */
  84502. _linesIndexCount: number;
  84503. private _mesh;
  84504. private _renderingMesh;
  84505. private _boundingInfo;
  84506. private _linesIndexBuffer;
  84507. /** @hidden */
  84508. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84509. /** @hidden */
  84510. _trianglePlanes: Plane[];
  84511. /** @hidden */
  84512. _lastColliderTransformMatrix: Nullable<Matrix>;
  84513. /** @hidden */
  84514. _renderId: number;
  84515. /** @hidden */
  84516. _alphaIndex: number;
  84517. /** @hidden */
  84518. _distanceToCamera: number;
  84519. /** @hidden */
  84520. _id: number;
  84521. private _currentMaterial;
  84522. /**
  84523. * Add a new submesh to a mesh
  84524. * @param materialIndex defines the material index to use
  84525. * @param verticesStart defines vertex index start
  84526. * @param verticesCount defines vertices count
  84527. * @param indexStart defines index start
  84528. * @param indexCount defines indices count
  84529. * @param mesh defines the parent mesh
  84530. * @param renderingMesh defines an optional rendering mesh
  84531. * @param createBoundingBox defines if bounding box should be created for this submesh
  84532. * @returns the new submesh
  84533. */
  84534. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84535. /**
  84536. * Creates a new submesh
  84537. * @param materialIndex defines the material index to use
  84538. * @param verticesStart defines vertex index start
  84539. * @param verticesCount defines vertices count
  84540. * @param indexStart defines index start
  84541. * @param indexCount defines indices count
  84542. * @param mesh defines the parent mesh
  84543. * @param renderingMesh defines an optional rendering mesh
  84544. * @param createBoundingBox defines if bounding box should be created for this submesh
  84545. */
  84546. constructor(
  84547. /** the material index to use */
  84548. materialIndex: number,
  84549. /** vertex index start */
  84550. verticesStart: number,
  84551. /** vertices count */
  84552. verticesCount: number,
  84553. /** index start */
  84554. indexStart: number,
  84555. /** indices count */
  84556. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84557. /**
  84558. * Returns true if this submesh covers the entire parent mesh
  84559. * @ignorenaming
  84560. */
  84561. readonly IsGlobal: boolean;
  84562. /**
  84563. * Returns the submesh BoudingInfo object
  84564. * @returns current bounding info (or mesh's one if the submesh is global)
  84565. */
  84566. getBoundingInfo(): BoundingInfo;
  84567. /**
  84568. * Sets the submesh BoundingInfo
  84569. * @param boundingInfo defines the new bounding info to use
  84570. * @returns the SubMesh
  84571. */
  84572. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84573. /**
  84574. * Returns the mesh of the current submesh
  84575. * @return the parent mesh
  84576. */
  84577. getMesh(): AbstractMesh;
  84578. /**
  84579. * Returns the rendering mesh of the submesh
  84580. * @returns the rendering mesh (could be different from parent mesh)
  84581. */
  84582. getRenderingMesh(): Mesh;
  84583. /**
  84584. * Returns the submesh material
  84585. * @returns null or the current material
  84586. */
  84587. getMaterial(): Nullable<Material>;
  84588. /**
  84589. * Sets a new updated BoundingInfo object to the submesh
  84590. * @param data defines an optional position array to use to determine the bounding info
  84591. * @returns the SubMesh
  84592. */
  84593. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84594. /** @hidden */
  84595. _checkCollision(collider: Collider): boolean;
  84596. /**
  84597. * Updates the submesh BoundingInfo
  84598. * @param world defines the world matrix to use to update the bounding info
  84599. * @returns the submesh
  84600. */
  84601. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84602. /**
  84603. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84604. * @param frustumPlanes defines the frustum planes
  84605. * @returns true if the submesh is intersecting with the frustum
  84606. */
  84607. isInFrustum(frustumPlanes: Plane[]): boolean;
  84608. /**
  84609. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84610. * @param frustumPlanes defines the frustum planes
  84611. * @returns true if the submesh is inside the frustum
  84612. */
  84613. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84614. /**
  84615. * Renders the submesh
  84616. * @param enableAlphaMode defines if alpha needs to be used
  84617. * @returns the submesh
  84618. */
  84619. render(enableAlphaMode: boolean): SubMesh;
  84620. /**
  84621. * @hidden
  84622. */
  84623. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84624. /**
  84625. * Checks if the submesh intersects with a ray
  84626. * @param ray defines the ray to test
  84627. * @returns true is the passed ray intersects the submesh bounding box
  84628. */
  84629. canIntersects(ray: Ray): boolean;
  84630. /**
  84631. * Intersects current submesh with a ray
  84632. * @param ray defines the ray to test
  84633. * @param positions defines mesh's positions array
  84634. * @param indices defines mesh's indices array
  84635. * @param fastCheck defines if only bounding info should be used
  84636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84637. * @returns intersection info or null if no intersection
  84638. */
  84639. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84640. /** @hidden */
  84641. private _intersectLines;
  84642. /** @hidden */
  84643. private _intersectUnIndexedLines;
  84644. /** @hidden */
  84645. private _intersectTriangles;
  84646. /** @hidden */
  84647. private _intersectUnIndexedTriangles;
  84648. /** @hidden */
  84649. _rebuild(): void;
  84650. /**
  84651. * Creates a new submesh from the passed mesh
  84652. * @param newMesh defines the new hosting mesh
  84653. * @param newRenderingMesh defines an optional rendering mesh
  84654. * @returns the new submesh
  84655. */
  84656. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84657. /**
  84658. * Release associated resources
  84659. */
  84660. dispose(): void;
  84661. /**
  84662. * Gets the class name
  84663. * @returns the string "SubMesh".
  84664. */
  84665. getClassName(): string;
  84666. /**
  84667. * Creates a new submesh from indices data
  84668. * @param materialIndex the index of the main mesh material
  84669. * @param startIndex the index where to start the copy in the mesh indices array
  84670. * @param indexCount the number of indices to copy then from the startIndex
  84671. * @param mesh the main mesh to create the submesh from
  84672. * @param renderingMesh the optional rendering mesh
  84673. * @returns a new submesh
  84674. */
  84675. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84676. }
  84677. }
  84678. declare module BABYLON {
  84679. /**
  84680. * Class used to represent data loading progression
  84681. */
  84682. export class SceneLoaderFlags {
  84683. private static _ForceFullSceneLoadingForIncremental;
  84684. private static _ShowLoadingScreen;
  84685. private static _CleanBoneMatrixWeights;
  84686. private static _loggingLevel;
  84687. /**
  84688. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84689. */
  84690. static ForceFullSceneLoadingForIncremental: boolean;
  84691. /**
  84692. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84693. */
  84694. static ShowLoadingScreen: boolean;
  84695. /**
  84696. * Defines the current logging level (while loading the scene)
  84697. * @ignorenaming
  84698. */
  84699. static loggingLevel: number;
  84700. /**
  84701. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84702. */
  84703. static CleanBoneMatrixWeights: boolean;
  84704. }
  84705. }
  84706. declare module BABYLON {
  84707. /**
  84708. * Class used to store geometry data (vertex buffers + index buffer)
  84709. */
  84710. export class Geometry implements IGetSetVerticesData {
  84711. /**
  84712. * Gets or sets the ID of the geometry
  84713. */
  84714. id: string;
  84715. /**
  84716. * Gets or sets the unique ID of the geometry
  84717. */
  84718. uniqueId: number;
  84719. /**
  84720. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84721. */
  84722. delayLoadState: number;
  84723. /**
  84724. * Gets the file containing the data to load when running in delay load state
  84725. */
  84726. delayLoadingFile: Nullable<string>;
  84727. /**
  84728. * Callback called when the geometry is updated
  84729. */
  84730. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84731. private _scene;
  84732. private _engine;
  84733. private _meshes;
  84734. private _totalVertices;
  84735. /** @hidden */
  84736. _indices: IndicesArray;
  84737. /** @hidden */
  84738. _vertexBuffers: {
  84739. [key: string]: VertexBuffer;
  84740. };
  84741. private _isDisposed;
  84742. private _extend;
  84743. private _boundingBias;
  84744. /** @hidden */
  84745. _delayInfo: Array<string>;
  84746. private _indexBuffer;
  84747. private _indexBufferIsUpdatable;
  84748. /** @hidden */
  84749. _boundingInfo: Nullable<BoundingInfo>;
  84750. /** @hidden */
  84751. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84752. /** @hidden */
  84753. _softwareSkinningFrameId: number;
  84754. private _vertexArrayObjects;
  84755. private _updatable;
  84756. /** @hidden */
  84757. _positions: Nullable<Vector3[]>;
  84758. /**
  84759. * 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
  84760. */
  84761. /**
  84762. * 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
  84763. */
  84764. boundingBias: Vector2;
  84765. /**
  84766. * Static function used to attach a new empty geometry to a mesh
  84767. * @param mesh defines the mesh to attach the geometry to
  84768. * @returns the new Geometry
  84769. */
  84770. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84771. /**
  84772. * Creates a new geometry
  84773. * @param id defines the unique ID
  84774. * @param scene defines the hosting scene
  84775. * @param vertexData defines the VertexData used to get geometry data
  84776. * @param updatable defines if geometry must be updatable (false by default)
  84777. * @param mesh defines the mesh that will be associated with the geometry
  84778. */
  84779. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84780. /**
  84781. * Gets the current extend of the geometry
  84782. */
  84783. readonly extend: {
  84784. minimum: Vector3;
  84785. maximum: Vector3;
  84786. };
  84787. /**
  84788. * Gets the hosting scene
  84789. * @returns the hosting Scene
  84790. */
  84791. getScene(): Scene;
  84792. /**
  84793. * Gets the hosting engine
  84794. * @returns the hosting Engine
  84795. */
  84796. getEngine(): Engine;
  84797. /**
  84798. * Defines if the geometry is ready to use
  84799. * @returns true if the geometry is ready to be used
  84800. */
  84801. isReady(): boolean;
  84802. /**
  84803. * Gets a value indicating that the geometry should not be serialized
  84804. */
  84805. readonly doNotSerialize: boolean;
  84806. /** @hidden */
  84807. _rebuild(): void;
  84808. /**
  84809. * Affects all geometry data in one call
  84810. * @param vertexData defines the geometry data
  84811. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84812. */
  84813. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84814. /**
  84815. * Set specific vertex data
  84816. * @param kind defines the data kind (Position, normal, etc...)
  84817. * @param data defines the vertex data to use
  84818. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84819. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84820. */
  84821. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84822. /**
  84823. * Removes a specific vertex data
  84824. * @param kind defines the data kind (Position, normal, etc...)
  84825. */
  84826. removeVerticesData(kind: string): void;
  84827. /**
  84828. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84829. * @param buffer defines the vertex buffer to use
  84830. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84831. */
  84832. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84833. /**
  84834. * Update a specific vertex buffer
  84835. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84836. * It will do nothing if the buffer is not updatable
  84837. * @param kind defines the data kind (Position, normal, etc...)
  84838. * @param data defines the data to use
  84839. * @param offset defines the offset in the target buffer where to store the data
  84840. * @param useBytes set to true if the offset is in bytes
  84841. */
  84842. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84843. /**
  84844. * Update a specific vertex buffer
  84845. * This function will create a new buffer if the current one is not updatable
  84846. * @param kind defines the data kind (Position, normal, etc...)
  84847. * @param data defines the data to use
  84848. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84849. */
  84850. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84851. private _updateBoundingInfo;
  84852. /** @hidden */
  84853. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84854. /**
  84855. * Gets total number of vertices
  84856. * @returns the total number of vertices
  84857. */
  84858. getTotalVertices(): number;
  84859. /**
  84860. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84861. * @param kind defines the data kind (Position, normal, etc...)
  84862. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84863. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84864. * @returns a float array containing vertex data
  84865. */
  84866. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84867. /**
  84868. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84869. * @param kind defines the data kind (Position, normal, etc...)
  84870. * @returns true if the vertex buffer with the specified kind is updatable
  84871. */
  84872. isVertexBufferUpdatable(kind: string): boolean;
  84873. /**
  84874. * Gets a specific vertex buffer
  84875. * @param kind defines the data kind (Position, normal, etc...)
  84876. * @returns a VertexBuffer
  84877. */
  84878. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84879. /**
  84880. * Returns all vertex buffers
  84881. * @return an object holding all vertex buffers indexed by kind
  84882. */
  84883. getVertexBuffers(): Nullable<{
  84884. [key: string]: VertexBuffer;
  84885. }>;
  84886. /**
  84887. * Gets a boolean indicating if specific vertex buffer is present
  84888. * @param kind defines the data kind (Position, normal, etc...)
  84889. * @returns true if data is present
  84890. */
  84891. isVerticesDataPresent(kind: string): boolean;
  84892. /**
  84893. * Gets a list of all attached data kinds (Position, normal, etc...)
  84894. * @returns a list of string containing all kinds
  84895. */
  84896. getVerticesDataKinds(): string[];
  84897. /**
  84898. * Update index buffer
  84899. * @param indices defines the indices to store in the index buffer
  84900. * @param offset defines the offset in the target buffer where to store the data
  84901. * @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)
  84902. */
  84903. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84904. /**
  84905. * Creates a new index buffer
  84906. * @param indices defines the indices to store in the index buffer
  84907. * @param totalVertices defines the total number of vertices (could be null)
  84908. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84909. */
  84910. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84911. /**
  84912. * Return the total number of indices
  84913. * @returns the total number of indices
  84914. */
  84915. getTotalIndices(): number;
  84916. /**
  84917. * Gets the index buffer array
  84918. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84919. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84920. * @returns the index buffer array
  84921. */
  84922. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84923. /**
  84924. * Gets the index buffer
  84925. * @return the index buffer
  84926. */
  84927. getIndexBuffer(): Nullable<DataBuffer>;
  84928. /** @hidden */
  84929. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84930. /**
  84931. * Release the associated resources for a specific mesh
  84932. * @param mesh defines the source mesh
  84933. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84934. */
  84935. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84936. /**
  84937. * Apply current geometry to a given mesh
  84938. * @param mesh defines the mesh to apply geometry to
  84939. */
  84940. applyToMesh(mesh: Mesh): void;
  84941. private _updateExtend;
  84942. private _applyToMesh;
  84943. private notifyUpdate;
  84944. /**
  84945. * Load the geometry if it was flagged as delay loaded
  84946. * @param scene defines the hosting scene
  84947. * @param onLoaded defines a callback called when the geometry is loaded
  84948. */
  84949. load(scene: Scene, onLoaded?: () => void): void;
  84950. private _queueLoad;
  84951. /**
  84952. * Invert the geometry to move from a right handed system to a left handed one.
  84953. */
  84954. toLeftHanded(): void;
  84955. /** @hidden */
  84956. _resetPointsArrayCache(): void;
  84957. /** @hidden */
  84958. _generatePointsArray(): boolean;
  84959. /**
  84960. * Gets a value indicating if the geometry is disposed
  84961. * @returns true if the geometry was disposed
  84962. */
  84963. isDisposed(): boolean;
  84964. private _disposeVertexArrayObjects;
  84965. /**
  84966. * Free all associated resources
  84967. */
  84968. dispose(): void;
  84969. /**
  84970. * Clone the current geometry into a new geometry
  84971. * @param id defines the unique ID of the new geometry
  84972. * @returns a new geometry object
  84973. */
  84974. copy(id: string): Geometry;
  84975. /**
  84976. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84977. * @return a JSON representation of the current geometry data (without the vertices data)
  84978. */
  84979. serialize(): any;
  84980. private toNumberArray;
  84981. /**
  84982. * Serialize all vertices data into a JSON oject
  84983. * @returns a JSON representation of the current geometry data
  84984. */
  84985. serializeVerticeData(): any;
  84986. /**
  84987. * Extracts a clone of a mesh geometry
  84988. * @param mesh defines the source mesh
  84989. * @param id defines the unique ID of the new geometry object
  84990. * @returns the new geometry object
  84991. */
  84992. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84993. /**
  84994. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84995. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84996. * Be aware Math.random() could cause collisions, but:
  84997. * "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"
  84998. * @returns a string containing a new GUID
  84999. */
  85000. static RandomId(): string;
  85001. /** @hidden */
  85002. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85003. private static _CleanMatricesWeights;
  85004. /**
  85005. * Create a new geometry from persisted data (Using .babylon file format)
  85006. * @param parsedVertexData defines the persisted data
  85007. * @param scene defines the hosting scene
  85008. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85009. * @returns the new geometry object
  85010. */
  85011. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85012. }
  85013. }
  85014. declare module BABYLON {
  85015. /**
  85016. * Define an interface for all classes that will get and set the data on vertices
  85017. */
  85018. export interface IGetSetVerticesData {
  85019. /**
  85020. * Gets a boolean indicating if specific vertex data is present
  85021. * @param kind defines the vertex data kind to use
  85022. * @returns true is data kind is present
  85023. */
  85024. isVerticesDataPresent(kind: string): boolean;
  85025. /**
  85026. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85027. * @param kind defines the data kind (Position, normal, etc...)
  85028. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85029. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85030. * @returns a float array containing vertex data
  85031. */
  85032. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85033. /**
  85034. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85035. * @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.
  85036. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85037. * @returns the indices array or an empty array if the mesh has no geometry
  85038. */
  85039. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85040. /**
  85041. * Set specific vertex data
  85042. * @param kind defines the data kind (Position, normal, etc...)
  85043. * @param data defines the vertex data to use
  85044. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85045. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85046. */
  85047. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85048. /**
  85049. * Update a specific associated vertex buffer
  85050. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85051. * - VertexBuffer.PositionKind
  85052. * - VertexBuffer.UVKind
  85053. * - VertexBuffer.UV2Kind
  85054. * - VertexBuffer.UV3Kind
  85055. * - VertexBuffer.UV4Kind
  85056. * - VertexBuffer.UV5Kind
  85057. * - VertexBuffer.UV6Kind
  85058. * - VertexBuffer.ColorKind
  85059. * - VertexBuffer.MatricesIndicesKind
  85060. * - VertexBuffer.MatricesIndicesExtraKind
  85061. * - VertexBuffer.MatricesWeightsKind
  85062. * - VertexBuffer.MatricesWeightsExtraKind
  85063. * @param data defines the data source
  85064. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85065. * @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)
  85066. */
  85067. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85068. /**
  85069. * Creates a new index buffer
  85070. * @param indices defines the indices to store in the index buffer
  85071. * @param totalVertices defines the total number of vertices (could be null)
  85072. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85073. */
  85074. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85075. }
  85076. /**
  85077. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85078. */
  85079. export class VertexData {
  85080. /**
  85081. * Mesh side orientation : usually the external or front surface
  85082. */
  85083. static readonly FRONTSIDE: number;
  85084. /**
  85085. * Mesh side orientation : usually the internal or back surface
  85086. */
  85087. static readonly BACKSIDE: number;
  85088. /**
  85089. * Mesh side orientation : both internal and external or front and back surfaces
  85090. */
  85091. static readonly DOUBLESIDE: number;
  85092. /**
  85093. * Mesh side orientation : by default, `FRONTSIDE`
  85094. */
  85095. static readonly DEFAULTSIDE: number;
  85096. /**
  85097. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85098. */
  85099. positions: Nullable<FloatArray>;
  85100. /**
  85101. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85102. */
  85103. normals: Nullable<FloatArray>;
  85104. /**
  85105. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85106. */
  85107. tangents: Nullable<FloatArray>;
  85108. /**
  85109. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85110. */
  85111. uvs: Nullable<FloatArray>;
  85112. /**
  85113. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85114. */
  85115. uvs2: Nullable<FloatArray>;
  85116. /**
  85117. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85118. */
  85119. uvs3: Nullable<FloatArray>;
  85120. /**
  85121. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85122. */
  85123. uvs4: Nullable<FloatArray>;
  85124. /**
  85125. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85126. */
  85127. uvs5: Nullable<FloatArray>;
  85128. /**
  85129. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85130. */
  85131. uvs6: Nullable<FloatArray>;
  85132. /**
  85133. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85134. */
  85135. colors: Nullable<FloatArray>;
  85136. /**
  85137. * 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).
  85138. */
  85139. matricesIndices: Nullable<FloatArray>;
  85140. /**
  85141. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85142. */
  85143. matricesWeights: Nullable<FloatArray>;
  85144. /**
  85145. * An array extending the number of possible indices
  85146. */
  85147. matricesIndicesExtra: Nullable<FloatArray>;
  85148. /**
  85149. * An array extending the number of possible weights when the number of indices is extended
  85150. */
  85151. matricesWeightsExtra: Nullable<FloatArray>;
  85152. /**
  85153. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85154. */
  85155. indices: Nullable<IndicesArray>;
  85156. /**
  85157. * Uses the passed data array to set the set the values for the specified kind of data
  85158. * @param data a linear array of floating numbers
  85159. * @param kind the type of data that is being set, eg positions, colors etc
  85160. */
  85161. set(data: FloatArray, kind: string): void;
  85162. /**
  85163. * Associates the vertexData to the passed Mesh.
  85164. * Sets it as updatable or not (default `false`)
  85165. * @param mesh the mesh the vertexData is applied to
  85166. * @param updatable when used and having the value true allows new data to update the vertexData
  85167. * @returns the VertexData
  85168. */
  85169. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85170. /**
  85171. * Associates the vertexData to the passed Geometry.
  85172. * Sets it as updatable or not (default `false`)
  85173. * @param geometry the geometry the vertexData is applied to
  85174. * @param updatable when used and having the value true allows new data to update the vertexData
  85175. * @returns VertexData
  85176. */
  85177. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85178. /**
  85179. * Updates the associated mesh
  85180. * @param mesh the mesh to be updated
  85181. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85182. * @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
  85183. * @returns VertexData
  85184. */
  85185. updateMesh(mesh: Mesh): VertexData;
  85186. /**
  85187. * Updates the associated geometry
  85188. * @param geometry the geometry to be updated
  85189. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85190. * @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
  85191. * @returns VertexData.
  85192. */
  85193. updateGeometry(geometry: Geometry): VertexData;
  85194. private _applyTo;
  85195. private _update;
  85196. /**
  85197. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85198. * @param matrix the transforming matrix
  85199. * @returns the VertexData
  85200. */
  85201. transform(matrix: Matrix): VertexData;
  85202. /**
  85203. * Merges the passed VertexData into the current one
  85204. * @param other the VertexData to be merged into the current one
  85205. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85206. * @returns the modified VertexData
  85207. */
  85208. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85209. private _mergeElement;
  85210. private _validate;
  85211. /**
  85212. * Serializes the VertexData
  85213. * @returns a serialized object
  85214. */
  85215. serialize(): any;
  85216. /**
  85217. * Extracts the vertexData from a mesh
  85218. * @param mesh the mesh from which to extract the VertexData
  85219. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85220. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85221. * @returns the object VertexData associated to the passed mesh
  85222. */
  85223. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85224. /**
  85225. * Extracts the vertexData from the geometry
  85226. * @param geometry the geometry from which to extract the VertexData
  85227. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85228. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85229. * @returns the object VertexData associated to the passed mesh
  85230. */
  85231. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85232. private static _ExtractFrom;
  85233. /**
  85234. * Creates the VertexData for a Ribbon
  85235. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85236. * * pathArray array of paths, each of which an array of successive Vector3
  85237. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85238. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85239. * * 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
  85240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85241. * * 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)
  85242. * * 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)
  85243. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85244. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85245. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85246. * @returns the VertexData of the ribbon
  85247. */
  85248. static CreateRibbon(options: {
  85249. pathArray: Vector3[][];
  85250. closeArray?: boolean;
  85251. closePath?: boolean;
  85252. offset?: number;
  85253. sideOrientation?: number;
  85254. frontUVs?: Vector4;
  85255. backUVs?: Vector4;
  85256. invertUV?: boolean;
  85257. uvs?: Vector2[];
  85258. colors?: Color4[];
  85259. }): VertexData;
  85260. /**
  85261. * Creates the VertexData for a box
  85262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85263. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85264. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85265. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85266. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85267. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85268. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85270. * * 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)
  85271. * * 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)
  85272. * @returns the VertexData of the box
  85273. */
  85274. static CreateBox(options: {
  85275. size?: number;
  85276. width?: number;
  85277. height?: number;
  85278. depth?: number;
  85279. faceUV?: Vector4[];
  85280. faceColors?: Color4[];
  85281. sideOrientation?: number;
  85282. frontUVs?: Vector4;
  85283. backUVs?: Vector4;
  85284. }): VertexData;
  85285. /**
  85286. * Creates the VertexData for a tiled box
  85287. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85288. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85289. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85290. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85292. * @returns the VertexData of the box
  85293. */
  85294. static CreateTiledBox(options: {
  85295. pattern?: number;
  85296. width?: number;
  85297. height?: number;
  85298. depth?: number;
  85299. tileSize?: number;
  85300. tileWidth?: number;
  85301. tileHeight?: number;
  85302. alignHorizontal?: number;
  85303. alignVertical?: number;
  85304. faceUV?: Vector4[];
  85305. faceColors?: Color4[];
  85306. sideOrientation?: number;
  85307. }): VertexData;
  85308. /**
  85309. * Creates the VertexData for a tiled plane
  85310. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85311. * * pattern a limited pattern arrangement depending on the number
  85312. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85313. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85314. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85316. * * 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)
  85317. * * 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)
  85318. * @returns the VertexData of the tiled plane
  85319. */
  85320. static CreateTiledPlane(options: {
  85321. pattern?: number;
  85322. tileSize?: number;
  85323. tileWidth?: number;
  85324. tileHeight?: number;
  85325. size?: number;
  85326. width?: number;
  85327. height?: number;
  85328. alignHorizontal?: number;
  85329. alignVertical?: number;
  85330. sideOrientation?: number;
  85331. frontUVs?: Vector4;
  85332. backUVs?: Vector4;
  85333. }): VertexData;
  85334. /**
  85335. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85337. * * segments sets the number of horizontal strips optional, default 32
  85338. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85339. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85340. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85341. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85342. * * 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
  85343. * * 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
  85344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85345. * * 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)
  85346. * * 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)
  85347. * @returns the VertexData of the ellipsoid
  85348. */
  85349. static CreateSphere(options: {
  85350. segments?: number;
  85351. diameter?: number;
  85352. diameterX?: number;
  85353. diameterY?: number;
  85354. diameterZ?: number;
  85355. arc?: number;
  85356. slice?: number;
  85357. sideOrientation?: number;
  85358. frontUVs?: Vector4;
  85359. backUVs?: Vector4;
  85360. }): VertexData;
  85361. /**
  85362. * Creates the VertexData for a cylinder, cone or prism
  85363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85364. * * height sets the height (y direction) of the cylinder, optional, default 2
  85365. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85366. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85367. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85368. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85369. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85370. * * 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
  85371. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85372. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85373. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85374. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85376. * * 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)
  85377. * * 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)
  85378. * @returns the VertexData of the cylinder, cone or prism
  85379. */
  85380. static CreateCylinder(options: {
  85381. height?: number;
  85382. diameterTop?: number;
  85383. diameterBottom?: number;
  85384. diameter?: number;
  85385. tessellation?: number;
  85386. subdivisions?: number;
  85387. arc?: number;
  85388. faceColors?: Color4[];
  85389. faceUV?: Vector4[];
  85390. hasRings?: boolean;
  85391. enclose?: boolean;
  85392. sideOrientation?: number;
  85393. frontUVs?: Vector4;
  85394. backUVs?: Vector4;
  85395. }): VertexData;
  85396. /**
  85397. * Creates the VertexData for a torus
  85398. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85399. * * diameter the diameter of the torus, optional default 1
  85400. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85401. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85403. * * 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)
  85404. * * 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)
  85405. * @returns the VertexData of the torus
  85406. */
  85407. static CreateTorus(options: {
  85408. diameter?: number;
  85409. thickness?: number;
  85410. tessellation?: number;
  85411. sideOrientation?: number;
  85412. frontUVs?: Vector4;
  85413. backUVs?: Vector4;
  85414. }): VertexData;
  85415. /**
  85416. * Creates the VertexData of the LineSystem
  85417. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85418. * - lines an array of lines, each line being an array of successive Vector3
  85419. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85420. * @returns the VertexData of the LineSystem
  85421. */
  85422. static CreateLineSystem(options: {
  85423. lines: Vector3[][];
  85424. colors?: Nullable<Color4[][]>;
  85425. }): VertexData;
  85426. /**
  85427. * Create the VertexData for a DashedLines
  85428. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85429. * - points an array successive Vector3
  85430. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85431. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85432. * - dashNb the intended total number of dashes, optional, default 200
  85433. * @returns the VertexData for the DashedLines
  85434. */
  85435. static CreateDashedLines(options: {
  85436. points: Vector3[];
  85437. dashSize?: number;
  85438. gapSize?: number;
  85439. dashNb?: number;
  85440. }): VertexData;
  85441. /**
  85442. * Creates the VertexData for a Ground
  85443. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85444. * - width the width (x direction) of the ground, optional, default 1
  85445. * - height the height (z direction) of the ground, optional, default 1
  85446. * - subdivisions the number of subdivisions per side, optional, default 1
  85447. * @returns the VertexData of the Ground
  85448. */
  85449. static CreateGround(options: {
  85450. width?: number;
  85451. height?: number;
  85452. subdivisions?: number;
  85453. subdivisionsX?: number;
  85454. subdivisionsY?: number;
  85455. }): VertexData;
  85456. /**
  85457. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85458. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85459. * * xmin the ground minimum X coordinate, optional, default -1
  85460. * * zmin the ground minimum Z coordinate, optional, default -1
  85461. * * xmax the ground maximum X coordinate, optional, default 1
  85462. * * zmax the ground maximum Z coordinate, optional, default 1
  85463. * * 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}
  85464. * * 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}
  85465. * @returns the VertexData of the TiledGround
  85466. */
  85467. static CreateTiledGround(options: {
  85468. xmin: number;
  85469. zmin: number;
  85470. xmax: number;
  85471. zmax: number;
  85472. subdivisions?: {
  85473. w: number;
  85474. h: number;
  85475. };
  85476. precision?: {
  85477. w: number;
  85478. h: number;
  85479. };
  85480. }): VertexData;
  85481. /**
  85482. * Creates the VertexData of the Ground designed from a heightmap
  85483. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85484. * * width the width (x direction) of the ground
  85485. * * height the height (z direction) of the ground
  85486. * * subdivisions the number of subdivisions per side
  85487. * * minHeight the minimum altitude on the ground, optional, default 0
  85488. * * maxHeight the maximum altitude on the ground, optional default 1
  85489. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85490. * * buffer the array holding the image color data
  85491. * * bufferWidth the width of image
  85492. * * bufferHeight the height of image
  85493. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85494. * @returns the VertexData of the Ground designed from a heightmap
  85495. */
  85496. static CreateGroundFromHeightMap(options: {
  85497. width: number;
  85498. height: number;
  85499. subdivisions: number;
  85500. minHeight: number;
  85501. maxHeight: number;
  85502. colorFilter: Color3;
  85503. buffer: Uint8Array;
  85504. bufferWidth: number;
  85505. bufferHeight: number;
  85506. alphaFilter: number;
  85507. }): VertexData;
  85508. /**
  85509. * Creates the VertexData for a Plane
  85510. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85511. * * size sets the width and height of the plane to the value of size, optional default 1
  85512. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85513. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85515. * * 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)
  85516. * * 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)
  85517. * @returns the VertexData of the box
  85518. */
  85519. static CreatePlane(options: {
  85520. size?: number;
  85521. width?: number;
  85522. height?: number;
  85523. sideOrientation?: number;
  85524. frontUVs?: Vector4;
  85525. backUVs?: Vector4;
  85526. }): VertexData;
  85527. /**
  85528. * Creates the VertexData of the Disc or regular Polygon
  85529. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85530. * * radius the radius of the disc, optional default 0.5
  85531. * * tessellation the number of polygon sides, optional, default 64
  85532. * * 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
  85533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85534. * * 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)
  85535. * * 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)
  85536. * @returns the VertexData of the box
  85537. */
  85538. static CreateDisc(options: {
  85539. radius?: number;
  85540. tessellation?: number;
  85541. arc?: number;
  85542. sideOrientation?: number;
  85543. frontUVs?: Vector4;
  85544. backUVs?: Vector4;
  85545. }): VertexData;
  85546. /**
  85547. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85548. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85549. * @param polygon a mesh built from polygonTriangulation.build()
  85550. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85551. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85552. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85553. * @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)
  85554. * @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)
  85555. * @returns the VertexData of the Polygon
  85556. */
  85557. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85558. /**
  85559. * Creates the VertexData of the IcoSphere
  85560. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85561. * * radius the radius of the IcoSphere, optional default 1
  85562. * * radiusX allows stretching in the x direction, optional, default radius
  85563. * * radiusY allows stretching in the y direction, optional, default radius
  85564. * * radiusZ allows stretching in the z direction, optional, default radius
  85565. * * flat when true creates a flat shaded mesh, optional, default true
  85566. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85567. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85568. * * 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)
  85569. * * 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)
  85570. * @returns the VertexData of the IcoSphere
  85571. */
  85572. static CreateIcoSphere(options: {
  85573. radius?: number;
  85574. radiusX?: number;
  85575. radiusY?: number;
  85576. radiusZ?: number;
  85577. flat?: boolean;
  85578. subdivisions?: number;
  85579. sideOrientation?: number;
  85580. frontUVs?: Vector4;
  85581. backUVs?: Vector4;
  85582. }): VertexData;
  85583. /**
  85584. * Creates the VertexData for a Polyhedron
  85585. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85586. * * type provided types are:
  85587. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85588. * * 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)
  85589. * * size the size of the IcoSphere, optional default 1
  85590. * * sizeX allows stretching in the x direction, optional, default size
  85591. * * sizeY allows stretching in the y direction, optional, default size
  85592. * * sizeZ allows stretching in the z direction, optional, default size
  85593. * * 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
  85594. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85595. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85596. * * flat when true creates a flat shaded mesh, optional, default true
  85597. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85598. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85599. * * 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)
  85600. * * 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)
  85601. * @returns the VertexData of the Polyhedron
  85602. */
  85603. static CreatePolyhedron(options: {
  85604. type?: number;
  85605. size?: number;
  85606. sizeX?: number;
  85607. sizeY?: number;
  85608. sizeZ?: number;
  85609. custom?: any;
  85610. faceUV?: Vector4[];
  85611. faceColors?: Color4[];
  85612. flat?: boolean;
  85613. sideOrientation?: number;
  85614. frontUVs?: Vector4;
  85615. backUVs?: Vector4;
  85616. }): VertexData;
  85617. /**
  85618. * Creates the VertexData for a TorusKnot
  85619. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85620. * * radius the radius of the torus knot, optional, default 2
  85621. * * tube the thickness of the tube, optional, default 0.5
  85622. * * radialSegments the number of sides on each tube segments, optional, default 32
  85623. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85624. * * p the number of windings around the z axis, optional, default 2
  85625. * * q the number of windings around the x axis, optional, default 3
  85626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85627. * * 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)
  85628. * * 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)
  85629. * @returns the VertexData of the Torus Knot
  85630. */
  85631. static CreateTorusKnot(options: {
  85632. radius?: number;
  85633. tube?: number;
  85634. radialSegments?: number;
  85635. tubularSegments?: number;
  85636. p?: number;
  85637. q?: number;
  85638. sideOrientation?: number;
  85639. frontUVs?: Vector4;
  85640. backUVs?: Vector4;
  85641. }): VertexData;
  85642. /**
  85643. * Compute normals for given positions and indices
  85644. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85645. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85646. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85647. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85648. * * facetNormals : optional array of facet normals (vector3)
  85649. * * facetPositions : optional array of facet positions (vector3)
  85650. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85651. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85652. * * bInfo : optional bounding info, required for facetPartitioning computation
  85653. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85654. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85655. * * useRightHandedSystem: optional boolean to for right handed system computation
  85656. * * depthSort : optional boolean to enable the facet depth sort computation
  85657. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85658. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85659. */
  85660. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85661. facetNormals?: any;
  85662. facetPositions?: any;
  85663. facetPartitioning?: any;
  85664. ratio?: number;
  85665. bInfo?: any;
  85666. bbSize?: Vector3;
  85667. subDiv?: any;
  85668. useRightHandedSystem?: boolean;
  85669. depthSort?: boolean;
  85670. distanceTo?: Vector3;
  85671. depthSortedFacets?: any;
  85672. }): void;
  85673. /** @hidden */
  85674. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85675. /**
  85676. * Applies VertexData created from the imported parameters to the geometry
  85677. * @param parsedVertexData the parsed data from an imported file
  85678. * @param geometry the geometry to apply the VertexData to
  85679. */
  85680. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85681. }
  85682. }
  85683. declare module BABYLON {
  85684. /**
  85685. * Defines a target to use with MorphTargetManager
  85686. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85687. */
  85688. export class MorphTarget implements IAnimatable {
  85689. /** defines the name of the target */
  85690. name: string;
  85691. /**
  85692. * Gets or sets the list of animations
  85693. */
  85694. animations: Animation[];
  85695. private _scene;
  85696. private _positions;
  85697. private _normals;
  85698. private _tangents;
  85699. private _uvs;
  85700. private _influence;
  85701. /**
  85702. * Observable raised when the influence changes
  85703. */
  85704. onInfluenceChanged: Observable<boolean>;
  85705. /** @hidden */
  85706. _onDataLayoutChanged: Observable<void>;
  85707. /**
  85708. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85709. */
  85710. influence: number;
  85711. /**
  85712. * Gets or sets the id of the morph Target
  85713. */
  85714. id: string;
  85715. private _animationPropertiesOverride;
  85716. /**
  85717. * Gets or sets the animation properties override
  85718. */
  85719. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85720. /**
  85721. * Creates a new MorphTarget
  85722. * @param name defines the name of the target
  85723. * @param influence defines the influence to use
  85724. * @param scene defines the scene the morphtarget belongs to
  85725. */
  85726. constructor(
  85727. /** defines the name of the target */
  85728. name: string, influence?: number, scene?: Nullable<Scene>);
  85729. /**
  85730. * Gets a boolean defining if the target contains position data
  85731. */
  85732. readonly hasPositions: boolean;
  85733. /**
  85734. * Gets a boolean defining if the target contains normal data
  85735. */
  85736. readonly hasNormals: boolean;
  85737. /**
  85738. * Gets a boolean defining if the target contains tangent data
  85739. */
  85740. readonly hasTangents: boolean;
  85741. /**
  85742. * Gets a boolean defining if the target contains texture coordinates data
  85743. */
  85744. readonly hasUVs: boolean;
  85745. /**
  85746. * Affects position data to this target
  85747. * @param data defines the position data to use
  85748. */
  85749. setPositions(data: Nullable<FloatArray>): void;
  85750. /**
  85751. * Gets the position data stored in this target
  85752. * @returns a FloatArray containing the position data (or null if not present)
  85753. */
  85754. getPositions(): Nullable<FloatArray>;
  85755. /**
  85756. * Affects normal data to this target
  85757. * @param data defines the normal data to use
  85758. */
  85759. setNormals(data: Nullable<FloatArray>): void;
  85760. /**
  85761. * Gets the normal data stored in this target
  85762. * @returns a FloatArray containing the normal data (or null if not present)
  85763. */
  85764. getNormals(): Nullable<FloatArray>;
  85765. /**
  85766. * Affects tangent data to this target
  85767. * @param data defines the tangent data to use
  85768. */
  85769. setTangents(data: Nullable<FloatArray>): void;
  85770. /**
  85771. * Gets the tangent data stored in this target
  85772. * @returns a FloatArray containing the tangent data (or null if not present)
  85773. */
  85774. getTangents(): Nullable<FloatArray>;
  85775. /**
  85776. * Affects texture coordinates data to this target
  85777. * @param data defines the texture coordinates data to use
  85778. */
  85779. setUVs(data: Nullable<FloatArray>): void;
  85780. /**
  85781. * Gets the texture coordinates data stored in this target
  85782. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  85783. */
  85784. getUVs(): Nullable<FloatArray>;
  85785. /**
  85786. * Serializes the current target into a Serialization object
  85787. * @returns the serialized object
  85788. */
  85789. serialize(): any;
  85790. /**
  85791. * Returns the string "MorphTarget"
  85792. * @returns "MorphTarget"
  85793. */
  85794. getClassName(): string;
  85795. /**
  85796. * Creates a new target from serialized data
  85797. * @param serializationObject defines the serialized data to use
  85798. * @returns a new MorphTarget
  85799. */
  85800. static Parse(serializationObject: any): MorphTarget;
  85801. /**
  85802. * Creates a MorphTarget from mesh data
  85803. * @param mesh defines the source mesh
  85804. * @param name defines the name to use for the new target
  85805. * @param influence defines the influence to attach to the target
  85806. * @returns a new MorphTarget
  85807. */
  85808. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  85809. }
  85810. }
  85811. declare module BABYLON {
  85812. /**
  85813. * This class is used to deform meshes using morphing between different targets
  85814. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85815. */
  85816. export class MorphTargetManager {
  85817. private _targets;
  85818. private _targetInfluenceChangedObservers;
  85819. private _targetDataLayoutChangedObservers;
  85820. private _activeTargets;
  85821. private _scene;
  85822. private _influences;
  85823. private _supportsNormals;
  85824. private _supportsTangents;
  85825. private _supportsUVs;
  85826. private _vertexCount;
  85827. private _uniqueId;
  85828. private _tempInfluences;
  85829. /**
  85830. * Gets or sets a boolean indicating if normals must be morphed
  85831. */
  85832. enableNormalMorphing: boolean;
  85833. /**
  85834. * Gets or sets a boolean indicating if tangents must be morphed
  85835. */
  85836. enableTangentMorphing: boolean;
  85837. /**
  85838. * Gets or sets a boolean indicating if UV must be morphed
  85839. */
  85840. enableUVMorphing: boolean;
  85841. /**
  85842. * Creates a new MorphTargetManager
  85843. * @param scene defines the current scene
  85844. */
  85845. constructor(scene?: Nullable<Scene>);
  85846. /**
  85847. * Gets the unique ID of this manager
  85848. */
  85849. readonly uniqueId: number;
  85850. /**
  85851. * Gets the number of vertices handled by this manager
  85852. */
  85853. readonly vertexCount: number;
  85854. /**
  85855. * Gets a boolean indicating if this manager supports morphing of normals
  85856. */
  85857. readonly supportsNormals: boolean;
  85858. /**
  85859. * Gets a boolean indicating if this manager supports morphing of tangents
  85860. */
  85861. readonly supportsTangents: boolean;
  85862. /**
  85863. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85864. */
  85865. readonly supportsUVs: boolean;
  85866. /**
  85867. * Gets the number of targets stored in this manager
  85868. */
  85869. readonly numTargets: number;
  85870. /**
  85871. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85872. */
  85873. readonly numInfluencers: number;
  85874. /**
  85875. * Gets the list of influences (one per target)
  85876. */
  85877. readonly influences: Float32Array;
  85878. /**
  85879. * Gets the active target at specified index. An active target is a target with an influence > 0
  85880. * @param index defines the index to check
  85881. * @returns the requested target
  85882. */
  85883. getActiveTarget(index: number): MorphTarget;
  85884. /**
  85885. * Gets the target at specified index
  85886. * @param index defines the index to check
  85887. * @returns the requested target
  85888. */
  85889. getTarget(index: number): MorphTarget;
  85890. /**
  85891. * Add a new target to this manager
  85892. * @param target defines the target to add
  85893. */
  85894. addTarget(target: MorphTarget): void;
  85895. /**
  85896. * Removes a target from the manager
  85897. * @param target defines the target to remove
  85898. */
  85899. removeTarget(target: MorphTarget): void;
  85900. /**
  85901. * Serializes the current manager into a Serialization object
  85902. * @returns the serialized object
  85903. */
  85904. serialize(): any;
  85905. private _syncActiveTargets;
  85906. /**
  85907. * Syncrhonize the targets with all the meshes using this morph target manager
  85908. */
  85909. synchronize(): void;
  85910. /**
  85911. * Creates a new MorphTargetManager from serialized data
  85912. * @param serializationObject defines the serialized data
  85913. * @param scene defines the hosting scene
  85914. * @returns the new MorphTargetManager
  85915. */
  85916. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85917. }
  85918. }
  85919. declare module BABYLON {
  85920. /**
  85921. * Class used to represent a specific level of detail of a mesh
  85922. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85923. */
  85924. export class MeshLODLevel {
  85925. /** Defines the distance where this level should star being displayed */
  85926. distance: number;
  85927. /** Defines the mesh to use to render this level */
  85928. mesh: Nullable<Mesh>;
  85929. /**
  85930. * Creates a new LOD level
  85931. * @param distance defines the distance where this level should star being displayed
  85932. * @param mesh defines the mesh to use to render this level
  85933. */
  85934. constructor(
  85935. /** Defines the distance where this level should star being displayed */
  85936. distance: number,
  85937. /** Defines the mesh to use to render this level */
  85938. mesh: Nullable<Mesh>);
  85939. }
  85940. }
  85941. declare module BABYLON {
  85942. /**
  85943. * Mesh representing the gorund
  85944. */
  85945. export class GroundMesh extends Mesh {
  85946. /** If octree should be generated */
  85947. generateOctree: boolean;
  85948. private _heightQuads;
  85949. /** @hidden */
  85950. _subdivisionsX: number;
  85951. /** @hidden */
  85952. _subdivisionsY: number;
  85953. /** @hidden */
  85954. _width: number;
  85955. /** @hidden */
  85956. _height: number;
  85957. /** @hidden */
  85958. _minX: number;
  85959. /** @hidden */
  85960. _maxX: number;
  85961. /** @hidden */
  85962. _minZ: number;
  85963. /** @hidden */
  85964. _maxZ: number;
  85965. constructor(name: string, scene: Scene);
  85966. /**
  85967. * "GroundMesh"
  85968. * @returns "GroundMesh"
  85969. */
  85970. getClassName(): string;
  85971. /**
  85972. * The minimum of x and y subdivisions
  85973. */
  85974. readonly subdivisions: number;
  85975. /**
  85976. * X subdivisions
  85977. */
  85978. readonly subdivisionsX: number;
  85979. /**
  85980. * Y subdivisions
  85981. */
  85982. readonly subdivisionsY: number;
  85983. /**
  85984. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85985. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85986. * @param chunksCount the number of subdivisions for x and y
  85987. * @param octreeBlocksSize (Default: 32)
  85988. */
  85989. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85990. /**
  85991. * Returns a height (y) value in the Worl system :
  85992. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85993. * @param x x coordinate
  85994. * @param z z coordinate
  85995. * @returns the ground y position if (x, z) are outside the ground surface.
  85996. */
  85997. getHeightAtCoordinates(x: number, z: number): number;
  85998. /**
  85999. * Returns a normalized vector (Vector3) orthogonal to the ground
  86000. * at the ground coordinates (x, z) expressed in the World system.
  86001. * @param x x coordinate
  86002. * @param z z coordinate
  86003. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86004. */
  86005. getNormalAtCoordinates(x: number, z: number): Vector3;
  86006. /**
  86007. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86008. * at the ground coordinates (x, z) expressed in the World system.
  86009. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86010. * @param x x coordinate
  86011. * @param z z coordinate
  86012. * @param ref vector to store the result
  86013. * @returns the GroundMesh.
  86014. */
  86015. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86016. /**
  86017. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86018. * if the ground has been updated.
  86019. * This can be used in the render loop.
  86020. * @returns the GroundMesh.
  86021. */
  86022. updateCoordinateHeights(): GroundMesh;
  86023. private _getFacetAt;
  86024. private _initHeightQuads;
  86025. private _computeHeightQuads;
  86026. /**
  86027. * Serializes this ground mesh
  86028. * @param serializationObject object to write serialization to
  86029. */
  86030. serialize(serializationObject: any): void;
  86031. /**
  86032. * Parses a serialized ground mesh
  86033. * @param parsedMesh the serialized mesh
  86034. * @param scene the scene to create the ground mesh in
  86035. * @returns the created ground mesh
  86036. */
  86037. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86038. }
  86039. }
  86040. declare module BABYLON {
  86041. /**
  86042. * Interface for Physics-Joint data
  86043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86044. */
  86045. export interface PhysicsJointData {
  86046. /**
  86047. * The main pivot of the joint
  86048. */
  86049. mainPivot?: Vector3;
  86050. /**
  86051. * The connected pivot of the joint
  86052. */
  86053. connectedPivot?: Vector3;
  86054. /**
  86055. * The main axis of the joint
  86056. */
  86057. mainAxis?: Vector3;
  86058. /**
  86059. * The connected axis of the joint
  86060. */
  86061. connectedAxis?: Vector3;
  86062. /**
  86063. * The collision of the joint
  86064. */
  86065. collision?: boolean;
  86066. /**
  86067. * Native Oimo/Cannon/Energy data
  86068. */
  86069. nativeParams?: any;
  86070. }
  86071. /**
  86072. * This is a holder class for the physics joint created by the physics plugin
  86073. * It holds a set of functions to control the underlying joint
  86074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86075. */
  86076. export class PhysicsJoint {
  86077. /**
  86078. * The type of the physics joint
  86079. */
  86080. type: number;
  86081. /**
  86082. * The data for the physics joint
  86083. */
  86084. jointData: PhysicsJointData;
  86085. private _physicsJoint;
  86086. protected _physicsPlugin: IPhysicsEnginePlugin;
  86087. /**
  86088. * Initializes the physics joint
  86089. * @param type The type of the physics joint
  86090. * @param jointData The data for the physics joint
  86091. */
  86092. constructor(
  86093. /**
  86094. * The type of the physics joint
  86095. */
  86096. type: number,
  86097. /**
  86098. * The data for the physics joint
  86099. */
  86100. jointData: PhysicsJointData);
  86101. /**
  86102. * Gets the physics joint
  86103. */
  86104. /**
  86105. * Sets the physics joint
  86106. */
  86107. physicsJoint: any;
  86108. /**
  86109. * Sets the physics plugin
  86110. */
  86111. physicsPlugin: IPhysicsEnginePlugin;
  86112. /**
  86113. * Execute a function that is physics-plugin specific.
  86114. * @param {Function} func the function that will be executed.
  86115. * It accepts two parameters: the physics world and the physics joint
  86116. */
  86117. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86118. /**
  86119. * Distance-Joint type
  86120. */
  86121. static DistanceJoint: number;
  86122. /**
  86123. * Hinge-Joint type
  86124. */
  86125. static HingeJoint: number;
  86126. /**
  86127. * Ball-and-Socket joint type
  86128. */
  86129. static BallAndSocketJoint: number;
  86130. /**
  86131. * Wheel-Joint type
  86132. */
  86133. static WheelJoint: number;
  86134. /**
  86135. * Slider-Joint type
  86136. */
  86137. static SliderJoint: number;
  86138. /**
  86139. * Prismatic-Joint type
  86140. */
  86141. static PrismaticJoint: number;
  86142. /**
  86143. * Universal-Joint type
  86144. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86145. */
  86146. static UniversalJoint: number;
  86147. /**
  86148. * Hinge-Joint 2 type
  86149. */
  86150. static Hinge2Joint: number;
  86151. /**
  86152. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86153. */
  86154. static PointToPointJoint: number;
  86155. /**
  86156. * Spring-Joint type
  86157. */
  86158. static SpringJoint: number;
  86159. /**
  86160. * Lock-Joint type
  86161. */
  86162. static LockJoint: number;
  86163. }
  86164. /**
  86165. * A class representing a physics distance joint
  86166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86167. */
  86168. export class DistanceJoint extends PhysicsJoint {
  86169. /**
  86170. *
  86171. * @param jointData The data for the Distance-Joint
  86172. */
  86173. constructor(jointData: DistanceJointData);
  86174. /**
  86175. * Update the predefined distance.
  86176. * @param maxDistance The maximum preferred distance
  86177. * @param minDistance The minimum preferred distance
  86178. */
  86179. updateDistance(maxDistance: number, minDistance?: number): void;
  86180. }
  86181. /**
  86182. * Represents a Motor-Enabled Joint
  86183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86184. */
  86185. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86186. /**
  86187. * Initializes the Motor-Enabled Joint
  86188. * @param type The type of the joint
  86189. * @param jointData The physica joint data for the joint
  86190. */
  86191. constructor(type: number, jointData: PhysicsJointData);
  86192. /**
  86193. * Set the motor values.
  86194. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86195. * @param force the force to apply
  86196. * @param maxForce max force for this motor.
  86197. */
  86198. setMotor(force?: number, maxForce?: number): void;
  86199. /**
  86200. * Set the motor's limits.
  86201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86202. * @param upperLimit The upper limit of the motor
  86203. * @param lowerLimit The lower limit of the motor
  86204. */
  86205. setLimit(upperLimit: number, lowerLimit?: number): void;
  86206. }
  86207. /**
  86208. * This class represents a single physics Hinge-Joint
  86209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86210. */
  86211. export class HingeJoint extends MotorEnabledJoint {
  86212. /**
  86213. * Initializes the Hinge-Joint
  86214. * @param jointData The joint data for the Hinge-Joint
  86215. */
  86216. constructor(jointData: PhysicsJointData);
  86217. /**
  86218. * Set the motor values.
  86219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86220. * @param {number} force the force to apply
  86221. * @param {number} maxForce max force for this motor.
  86222. */
  86223. setMotor(force?: number, maxForce?: number): void;
  86224. /**
  86225. * Set the motor's limits.
  86226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86227. * @param upperLimit The upper limit of the motor
  86228. * @param lowerLimit The lower limit of the motor
  86229. */
  86230. setLimit(upperLimit: number, lowerLimit?: number): void;
  86231. }
  86232. /**
  86233. * This class represents a dual hinge physics joint (same as wheel joint)
  86234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86235. */
  86236. export class Hinge2Joint extends MotorEnabledJoint {
  86237. /**
  86238. * Initializes the Hinge2-Joint
  86239. * @param jointData The joint data for the Hinge2-Joint
  86240. */
  86241. constructor(jointData: PhysicsJointData);
  86242. /**
  86243. * Set the motor values.
  86244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86245. * @param {number} targetSpeed the speed the motor is to reach
  86246. * @param {number} maxForce max force for this motor.
  86247. * @param {motorIndex} the motor's index, 0 or 1.
  86248. */
  86249. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86250. /**
  86251. * Set the motor limits.
  86252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86253. * @param {number} upperLimit the upper limit
  86254. * @param {number} lowerLimit lower limit
  86255. * @param {motorIndex} the motor's index, 0 or 1.
  86256. */
  86257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86258. }
  86259. /**
  86260. * Interface for a motor enabled joint
  86261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86262. */
  86263. export interface IMotorEnabledJoint {
  86264. /**
  86265. * Physics joint
  86266. */
  86267. physicsJoint: any;
  86268. /**
  86269. * Sets the motor of the motor-enabled joint
  86270. * @param force The force of the motor
  86271. * @param maxForce The maximum force of the motor
  86272. * @param motorIndex The index of the motor
  86273. */
  86274. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86275. /**
  86276. * Sets the limit of the motor
  86277. * @param upperLimit The upper limit of the motor
  86278. * @param lowerLimit The lower limit of the motor
  86279. * @param motorIndex The index of the motor
  86280. */
  86281. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86282. }
  86283. /**
  86284. * Joint data for a Distance-Joint
  86285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86286. */
  86287. export interface DistanceJointData extends PhysicsJointData {
  86288. /**
  86289. * Max distance the 2 joint objects can be apart
  86290. */
  86291. maxDistance: number;
  86292. }
  86293. /**
  86294. * Joint data from a spring joint
  86295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86296. */
  86297. export interface SpringJointData extends PhysicsJointData {
  86298. /**
  86299. * Length of the spring
  86300. */
  86301. length: number;
  86302. /**
  86303. * Stiffness of the spring
  86304. */
  86305. stiffness: number;
  86306. /**
  86307. * Damping of the spring
  86308. */
  86309. damping: number;
  86310. /** this callback will be called when applying the force to the impostors. */
  86311. forceApplicationCallback: () => void;
  86312. }
  86313. }
  86314. declare module BABYLON {
  86315. /**
  86316. * Holds the data for the raycast result
  86317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86318. */
  86319. export class PhysicsRaycastResult {
  86320. private _hasHit;
  86321. private _hitDistance;
  86322. private _hitNormalWorld;
  86323. private _hitPointWorld;
  86324. private _rayFromWorld;
  86325. private _rayToWorld;
  86326. /**
  86327. * Gets if there was a hit
  86328. */
  86329. readonly hasHit: boolean;
  86330. /**
  86331. * Gets the distance from the hit
  86332. */
  86333. readonly hitDistance: number;
  86334. /**
  86335. * Gets the hit normal/direction in the world
  86336. */
  86337. readonly hitNormalWorld: Vector3;
  86338. /**
  86339. * Gets the hit point in the world
  86340. */
  86341. readonly hitPointWorld: Vector3;
  86342. /**
  86343. * Gets the ray "start point" of the ray in the world
  86344. */
  86345. readonly rayFromWorld: Vector3;
  86346. /**
  86347. * Gets the ray "end point" of the ray in the world
  86348. */
  86349. readonly rayToWorld: Vector3;
  86350. /**
  86351. * Sets the hit data (normal & point in world space)
  86352. * @param hitNormalWorld defines the normal in world space
  86353. * @param hitPointWorld defines the point in world space
  86354. */
  86355. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86356. /**
  86357. * Sets the distance from the start point to the hit point
  86358. * @param distance
  86359. */
  86360. setHitDistance(distance: number): void;
  86361. /**
  86362. * Calculates the distance manually
  86363. */
  86364. calculateHitDistance(): void;
  86365. /**
  86366. * Resets all the values to default
  86367. * @param from The from point on world space
  86368. * @param to The to point on world space
  86369. */
  86370. reset(from?: Vector3, to?: Vector3): void;
  86371. }
  86372. /**
  86373. * Interface for the size containing width and height
  86374. */
  86375. interface IXYZ {
  86376. /**
  86377. * X
  86378. */
  86379. x: number;
  86380. /**
  86381. * Y
  86382. */
  86383. y: number;
  86384. /**
  86385. * Z
  86386. */
  86387. z: number;
  86388. }
  86389. }
  86390. declare module BABYLON {
  86391. /**
  86392. * Interface used to describe a physics joint
  86393. */
  86394. export interface PhysicsImpostorJoint {
  86395. /** Defines the main impostor to which the joint is linked */
  86396. mainImpostor: PhysicsImpostor;
  86397. /** Defines the impostor that is connected to the main impostor using this joint */
  86398. connectedImpostor: PhysicsImpostor;
  86399. /** Defines the joint itself */
  86400. joint: PhysicsJoint;
  86401. }
  86402. /** @hidden */
  86403. export interface IPhysicsEnginePlugin {
  86404. world: any;
  86405. name: string;
  86406. setGravity(gravity: Vector3): void;
  86407. setTimeStep(timeStep: number): void;
  86408. getTimeStep(): number;
  86409. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86411. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86412. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86413. removePhysicsBody(impostor: PhysicsImpostor): void;
  86414. generateJoint(joint: PhysicsImpostorJoint): void;
  86415. removeJoint(joint: PhysicsImpostorJoint): void;
  86416. isSupported(): boolean;
  86417. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86424. getBodyMass(impostor: PhysicsImpostor): number;
  86425. getBodyFriction(impostor: PhysicsImpostor): number;
  86426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86427. getBodyRestitution(impostor: PhysicsImpostor): number;
  86428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86429. getBodyPressure?(impostor: PhysicsImpostor): number;
  86430. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86431. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86432. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86433. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86434. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86435. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86436. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86437. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86438. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86439. sleepBody(impostor: PhysicsImpostor): void;
  86440. wakeUpBody(impostor: PhysicsImpostor): void;
  86441. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86442. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86443. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86444. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86445. getRadius(impostor: PhysicsImpostor): number;
  86446. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86447. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86448. dispose(): void;
  86449. }
  86450. /**
  86451. * Interface used to define a physics engine
  86452. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86453. */
  86454. export interface IPhysicsEngine {
  86455. /**
  86456. * Gets the gravity vector used by the simulation
  86457. */
  86458. gravity: Vector3;
  86459. /**
  86460. * Sets the gravity vector used by the simulation
  86461. * @param gravity defines the gravity vector to use
  86462. */
  86463. setGravity(gravity: Vector3): void;
  86464. /**
  86465. * Set the time step of the physics engine.
  86466. * Default is 1/60.
  86467. * To slow it down, enter 1/600 for example.
  86468. * To speed it up, 1/30
  86469. * @param newTimeStep the new timestep to apply to this world.
  86470. */
  86471. setTimeStep(newTimeStep: number): void;
  86472. /**
  86473. * Get the time step of the physics engine.
  86474. * @returns the current time step
  86475. */
  86476. getTimeStep(): number;
  86477. /**
  86478. * Release all resources
  86479. */
  86480. dispose(): void;
  86481. /**
  86482. * Gets the name of the current physics plugin
  86483. * @returns the name of the plugin
  86484. */
  86485. getPhysicsPluginName(): string;
  86486. /**
  86487. * Adding a new impostor for the impostor tracking.
  86488. * This will be done by the impostor itself.
  86489. * @param impostor the impostor to add
  86490. */
  86491. addImpostor(impostor: PhysicsImpostor): void;
  86492. /**
  86493. * Remove an impostor from the engine.
  86494. * This impostor and its mesh will not longer be updated by the physics engine.
  86495. * @param impostor the impostor to remove
  86496. */
  86497. removeImpostor(impostor: PhysicsImpostor): void;
  86498. /**
  86499. * Add a joint to the physics engine
  86500. * @param mainImpostor defines the main impostor to which the joint is added.
  86501. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86502. * @param joint defines the joint that will connect both impostors.
  86503. */
  86504. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86505. /**
  86506. * Removes a joint from the simulation
  86507. * @param mainImpostor defines the impostor used with the joint
  86508. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86509. * @param joint defines the joint to remove
  86510. */
  86511. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86512. /**
  86513. * Gets the current plugin used to run the simulation
  86514. * @returns current plugin
  86515. */
  86516. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86517. /**
  86518. * Gets the list of physic impostors
  86519. * @returns an array of PhysicsImpostor
  86520. */
  86521. getImpostors(): Array<PhysicsImpostor>;
  86522. /**
  86523. * Gets the impostor for a physics enabled object
  86524. * @param object defines the object impersonated by the impostor
  86525. * @returns the PhysicsImpostor or null if not found
  86526. */
  86527. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86528. /**
  86529. * Gets the impostor for a physics body object
  86530. * @param body defines physics body used by the impostor
  86531. * @returns the PhysicsImpostor or null if not found
  86532. */
  86533. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86534. /**
  86535. * Does a raycast in the physics world
  86536. * @param from when should the ray start?
  86537. * @param to when should the ray end?
  86538. * @returns PhysicsRaycastResult
  86539. */
  86540. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86541. /**
  86542. * Called by the scene. No need to call it.
  86543. * @param delta defines the timespam between frames
  86544. */
  86545. _step(delta: number): void;
  86546. }
  86547. }
  86548. declare module BABYLON {
  86549. /**
  86550. * The interface for the physics imposter parameters
  86551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86552. */
  86553. export interface PhysicsImpostorParameters {
  86554. /**
  86555. * The mass of the physics imposter
  86556. */
  86557. mass: number;
  86558. /**
  86559. * The friction of the physics imposter
  86560. */
  86561. friction?: number;
  86562. /**
  86563. * The coefficient of restitution of the physics imposter
  86564. */
  86565. restitution?: number;
  86566. /**
  86567. * The native options of the physics imposter
  86568. */
  86569. nativeOptions?: any;
  86570. /**
  86571. * Specifies if the parent should be ignored
  86572. */
  86573. ignoreParent?: boolean;
  86574. /**
  86575. * Specifies if bi-directional transformations should be disabled
  86576. */
  86577. disableBidirectionalTransformation?: boolean;
  86578. /**
  86579. * The pressure inside the physics imposter, soft object only
  86580. */
  86581. pressure?: number;
  86582. /**
  86583. * The stiffness the physics imposter, soft object only
  86584. */
  86585. stiffness?: number;
  86586. /**
  86587. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86588. */
  86589. velocityIterations?: number;
  86590. /**
  86591. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86592. */
  86593. positionIterations?: number;
  86594. /**
  86595. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86596. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86597. * Add to fix multiple points
  86598. */
  86599. fixedPoints?: number;
  86600. /**
  86601. * The collision margin around a soft object
  86602. */
  86603. margin?: number;
  86604. /**
  86605. * The collision margin around a soft object
  86606. */
  86607. damping?: number;
  86608. /**
  86609. * The path for a rope based on an extrusion
  86610. */
  86611. path?: any;
  86612. /**
  86613. * The shape of an extrusion used for a rope based on an extrusion
  86614. */
  86615. shape?: any;
  86616. }
  86617. /**
  86618. * Interface for a physics-enabled object
  86619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86620. */
  86621. export interface IPhysicsEnabledObject {
  86622. /**
  86623. * The position of the physics-enabled object
  86624. */
  86625. position: Vector3;
  86626. /**
  86627. * The rotation of the physics-enabled object
  86628. */
  86629. rotationQuaternion: Nullable<Quaternion>;
  86630. /**
  86631. * The scale of the physics-enabled object
  86632. */
  86633. scaling: Vector3;
  86634. /**
  86635. * The rotation of the physics-enabled object
  86636. */
  86637. rotation?: Vector3;
  86638. /**
  86639. * The parent of the physics-enabled object
  86640. */
  86641. parent?: any;
  86642. /**
  86643. * The bounding info of the physics-enabled object
  86644. * @returns The bounding info of the physics-enabled object
  86645. */
  86646. getBoundingInfo(): BoundingInfo;
  86647. /**
  86648. * Computes the world matrix
  86649. * @param force Specifies if the world matrix should be computed by force
  86650. * @returns A world matrix
  86651. */
  86652. computeWorldMatrix(force: boolean): Matrix;
  86653. /**
  86654. * Gets the world matrix
  86655. * @returns A world matrix
  86656. */
  86657. getWorldMatrix?(): Matrix;
  86658. /**
  86659. * Gets the child meshes
  86660. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86661. * @returns An array of abstract meshes
  86662. */
  86663. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86664. /**
  86665. * Gets the vertex data
  86666. * @param kind The type of vertex data
  86667. * @returns A nullable array of numbers, or a float32 array
  86668. */
  86669. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86670. /**
  86671. * Gets the indices from the mesh
  86672. * @returns A nullable array of index arrays
  86673. */
  86674. getIndices?(): Nullable<IndicesArray>;
  86675. /**
  86676. * Gets the scene from the mesh
  86677. * @returns the indices array or null
  86678. */
  86679. getScene?(): Scene;
  86680. /**
  86681. * Gets the absolute position from the mesh
  86682. * @returns the absolute position
  86683. */
  86684. getAbsolutePosition(): Vector3;
  86685. /**
  86686. * Gets the absolute pivot point from the mesh
  86687. * @returns the absolute pivot point
  86688. */
  86689. getAbsolutePivotPoint(): Vector3;
  86690. /**
  86691. * Rotates the mesh
  86692. * @param axis The axis of rotation
  86693. * @param amount The amount of rotation
  86694. * @param space The space of the rotation
  86695. * @returns The rotation transform node
  86696. */
  86697. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86698. /**
  86699. * Translates the mesh
  86700. * @param axis The axis of translation
  86701. * @param distance The distance of translation
  86702. * @param space The space of the translation
  86703. * @returns The transform node
  86704. */
  86705. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86706. /**
  86707. * Sets the absolute position of the mesh
  86708. * @param absolutePosition The absolute position of the mesh
  86709. * @returns The transform node
  86710. */
  86711. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86712. /**
  86713. * Gets the class name of the mesh
  86714. * @returns The class name
  86715. */
  86716. getClassName(): string;
  86717. }
  86718. /**
  86719. * Represents a physics imposter
  86720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86721. */
  86722. export class PhysicsImpostor {
  86723. /**
  86724. * The physics-enabled object used as the physics imposter
  86725. */
  86726. object: IPhysicsEnabledObject;
  86727. /**
  86728. * The type of the physics imposter
  86729. */
  86730. type: number;
  86731. private _options;
  86732. private _scene?;
  86733. /**
  86734. * The default object size of the imposter
  86735. */
  86736. static DEFAULT_OBJECT_SIZE: Vector3;
  86737. /**
  86738. * The identity quaternion of the imposter
  86739. */
  86740. static IDENTITY_QUATERNION: Quaternion;
  86741. /** @hidden */
  86742. _pluginData: any;
  86743. private _physicsEngine;
  86744. private _physicsBody;
  86745. private _bodyUpdateRequired;
  86746. private _onBeforePhysicsStepCallbacks;
  86747. private _onAfterPhysicsStepCallbacks;
  86748. /** @hidden */
  86749. _onPhysicsCollideCallbacks: Array<{
  86750. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86751. otherImpostors: Array<PhysicsImpostor>;
  86752. }>;
  86753. private _deltaPosition;
  86754. private _deltaRotation;
  86755. private _deltaRotationConjugated;
  86756. /** @hidden */
  86757. _isFromLine: boolean;
  86758. private _parent;
  86759. private _isDisposed;
  86760. private static _tmpVecs;
  86761. private static _tmpQuat;
  86762. /**
  86763. * Specifies if the physics imposter is disposed
  86764. */
  86765. readonly isDisposed: boolean;
  86766. /**
  86767. * Gets the mass of the physics imposter
  86768. */
  86769. mass: number;
  86770. /**
  86771. * Gets the coefficient of friction
  86772. */
  86773. /**
  86774. * Sets the coefficient of friction
  86775. */
  86776. friction: number;
  86777. /**
  86778. * Gets the coefficient of restitution
  86779. */
  86780. /**
  86781. * Sets the coefficient of restitution
  86782. */
  86783. restitution: number;
  86784. /**
  86785. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  86786. */
  86787. /**
  86788. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  86789. */
  86790. pressure: number;
  86791. /**
  86792. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86793. */
  86794. /**
  86795. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86796. */
  86797. stiffness: number;
  86798. /**
  86799. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86800. */
  86801. /**
  86802. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86803. */
  86804. velocityIterations: number;
  86805. /**
  86806. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86807. */
  86808. /**
  86809. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86810. */
  86811. positionIterations: number;
  86812. /**
  86813. * The unique id of the physics imposter
  86814. * set by the physics engine when adding this impostor to the array
  86815. */
  86816. uniqueId: number;
  86817. /**
  86818. * @hidden
  86819. */
  86820. soft: boolean;
  86821. /**
  86822. * @hidden
  86823. */
  86824. segments: number;
  86825. private _joints;
  86826. /**
  86827. * Initializes the physics imposter
  86828. * @param object The physics-enabled object used as the physics imposter
  86829. * @param type The type of the physics imposter
  86830. * @param _options The options for the physics imposter
  86831. * @param _scene The Babylon scene
  86832. */
  86833. constructor(
  86834. /**
  86835. * The physics-enabled object used as the physics imposter
  86836. */
  86837. object: IPhysicsEnabledObject,
  86838. /**
  86839. * The type of the physics imposter
  86840. */
  86841. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86842. /**
  86843. * This function will completly initialize this impostor.
  86844. * It will create a new body - but only if this mesh has no parent.
  86845. * If it has, this impostor will not be used other than to define the impostor
  86846. * of the child mesh.
  86847. * @hidden
  86848. */
  86849. _init(): void;
  86850. private _getPhysicsParent;
  86851. /**
  86852. * Should a new body be generated.
  86853. * @returns boolean specifying if body initialization is required
  86854. */
  86855. isBodyInitRequired(): boolean;
  86856. /**
  86857. * Sets the updated scaling
  86858. * @param updated Specifies if the scaling is updated
  86859. */
  86860. setScalingUpdated(): void;
  86861. /**
  86862. * Force a regeneration of this or the parent's impostor's body.
  86863. * Use under cautious - This will remove all joints already implemented.
  86864. */
  86865. forceUpdate(): void;
  86866. /**
  86867. * Gets the body that holds this impostor. Either its own, or its parent.
  86868. */
  86869. /**
  86870. * Set the physics body. Used mainly by the physics engine/plugin
  86871. */
  86872. physicsBody: any;
  86873. /**
  86874. * Get the parent of the physics imposter
  86875. * @returns Physics imposter or null
  86876. */
  86877. /**
  86878. * Sets the parent of the physics imposter
  86879. */
  86880. parent: Nullable<PhysicsImpostor>;
  86881. /**
  86882. * Resets the update flags
  86883. */
  86884. resetUpdateFlags(): void;
  86885. /**
  86886. * Gets the object extend size
  86887. * @returns the object extend size
  86888. */
  86889. getObjectExtendSize(): Vector3;
  86890. /**
  86891. * Gets the object center
  86892. * @returns The object center
  86893. */
  86894. getObjectCenter(): Vector3;
  86895. /**
  86896. * Get a specific parametes from the options parameter
  86897. * @param paramName The object parameter name
  86898. * @returns The object parameter
  86899. */
  86900. getParam(paramName: string): any;
  86901. /**
  86902. * Sets a specific parameter in the options given to the physics plugin
  86903. * @param paramName The parameter name
  86904. * @param value The value of the parameter
  86905. */
  86906. setParam(paramName: string, value: number): void;
  86907. /**
  86908. * Specifically change the body's mass option. Won't recreate the physics body object
  86909. * @param mass The mass of the physics imposter
  86910. */
  86911. setMass(mass: number): void;
  86912. /**
  86913. * Gets the linear velocity
  86914. * @returns linear velocity or null
  86915. */
  86916. getLinearVelocity(): Nullable<Vector3>;
  86917. /**
  86918. * Sets the linear velocity
  86919. * @param velocity linear velocity or null
  86920. */
  86921. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86922. /**
  86923. * Gets the angular velocity
  86924. * @returns angular velocity or null
  86925. */
  86926. getAngularVelocity(): Nullable<Vector3>;
  86927. /**
  86928. * Sets the angular velocity
  86929. * @param velocity The velocity or null
  86930. */
  86931. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86932. /**
  86933. * Execute a function with the physics plugin native code
  86934. * Provide a function the will have two variables - the world object and the physics body object
  86935. * @param func The function to execute with the physics plugin native code
  86936. */
  86937. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86938. /**
  86939. * Register a function that will be executed before the physics world is stepping forward
  86940. * @param func The function to execute before the physics world is stepped forward
  86941. */
  86942. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86943. /**
  86944. * Unregister a function that will be executed before the physics world is stepping forward
  86945. * @param func The function to execute before the physics world is stepped forward
  86946. */
  86947. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86948. /**
  86949. * Register a function that will be executed after the physics step
  86950. * @param func The function to execute after physics step
  86951. */
  86952. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86953. /**
  86954. * Unregisters a function that will be executed after the physics step
  86955. * @param func The function to execute after physics step
  86956. */
  86957. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86958. /**
  86959. * register a function that will be executed when this impostor collides against a different body
  86960. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86961. * @param func Callback that is executed on collision
  86962. */
  86963. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86964. /**
  86965. * Unregisters the physics imposter on contact
  86966. * @param collideAgainst The physics object to collide against
  86967. * @param func Callback to execute on collision
  86968. */
  86969. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86970. private _tmpQuat;
  86971. private _tmpQuat2;
  86972. /**
  86973. * Get the parent rotation
  86974. * @returns The parent rotation
  86975. */
  86976. getParentsRotation(): Quaternion;
  86977. /**
  86978. * this function is executed by the physics engine.
  86979. */
  86980. beforeStep: () => void;
  86981. /**
  86982. * this function is executed by the physics engine
  86983. */
  86984. afterStep: () => void;
  86985. /**
  86986. * Legacy collision detection event support
  86987. */
  86988. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86989. /**
  86990. * event and body object due to cannon's event-based architecture.
  86991. */
  86992. onCollide: (e: {
  86993. body: any;
  86994. }) => void;
  86995. /**
  86996. * Apply a force
  86997. * @param force The force to apply
  86998. * @param contactPoint The contact point for the force
  86999. * @returns The physics imposter
  87000. */
  87001. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87002. /**
  87003. * Apply an impulse
  87004. * @param force The impulse force
  87005. * @param contactPoint The contact point for the impulse force
  87006. * @returns The physics imposter
  87007. */
  87008. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87009. /**
  87010. * A help function to create a joint
  87011. * @param otherImpostor A physics imposter used to create a joint
  87012. * @param jointType The type of joint
  87013. * @param jointData The data for the joint
  87014. * @returns The physics imposter
  87015. */
  87016. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87017. /**
  87018. * Add a joint to this impostor with a different impostor
  87019. * @param otherImpostor A physics imposter used to add a joint
  87020. * @param joint The joint to add
  87021. * @returns The physics imposter
  87022. */
  87023. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87024. /**
  87025. * Add an anchor to a cloth impostor
  87026. * @param otherImpostor rigid impostor to anchor to
  87027. * @param width ratio across width from 0 to 1
  87028. * @param height ratio up height from 0 to 1
  87029. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87030. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87031. * @returns impostor the soft imposter
  87032. */
  87033. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87034. /**
  87035. * Add a hook to a rope impostor
  87036. * @param otherImpostor rigid impostor to anchor to
  87037. * @param length ratio across rope from 0 to 1
  87038. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87039. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87040. * @returns impostor the rope imposter
  87041. */
  87042. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87043. /**
  87044. * Will keep this body still, in a sleep mode.
  87045. * @returns the physics imposter
  87046. */
  87047. sleep(): PhysicsImpostor;
  87048. /**
  87049. * Wake the body up.
  87050. * @returns The physics imposter
  87051. */
  87052. wakeUp(): PhysicsImpostor;
  87053. /**
  87054. * Clones the physics imposter
  87055. * @param newObject The physics imposter clones to this physics-enabled object
  87056. * @returns A nullable physics imposter
  87057. */
  87058. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87059. /**
  87060. * Disposes the physics imposter
  87061. */
  87062. dispose(): void;
  87063. /**
  87064. * Sets the delta position
  87065. * @param position The delta position amount
  87066. */
  87067. setDeltaPosition(position: Vector3): void;
  87068. /**
  87069. * Sets the delta rotation
  87070. * @param rotation The delta rotation amount
  87071. */
  87072. setDeltaRotation(rotation: Quaternion): void;
  87073. /**
  87074. * Gets the box size of the physics imposter and stores the result in the input parameter
  87075. * @param result Stores the box size
  87076. * @returns The physics imposter
  87077. */
  87078. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87079. /**
  87080. * Gets the radius of the physics imposter
  87081. * @returns Radius of the physics imposter
  87082. */
  87083. getRadius(): number;
  87084. /**
  87085. * Sync a bone with this impostor
  87086. * @param bone The bone to sync to the impostor.
  87087. * @param boneMesh The mesh that the bone is influencing.
  87088. * @param jointPivot The pivot of the joint / bone in local space.
  87089. * @param distToJoint Optional distance from the impostor to the joint.
  87090. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87091. */
  87092. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87093. /**
  87094. * Sync impostor to a bone
  87095. * @param bone The bone that the impostor will be synced to.
  87096. * @param boneMesh The mesh that the bone is influencing.
  87097. * @param jointPivot The pivot of the joint / bone in local space.
  87098. * @param distToJoint Optional distance from the impostor to the joint.
  87099. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87100. * @param boneAxis Optional vector3 axis the bone is aligned with
  87101. */
  87102. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87103. /**
  87104. * No-Imposter type
  87105. */
  87106. static NoImpostor: number;
  87107. /**
  87108. * Sphere-Imposter type
  87109. */
  87110. static SphereImpostor: number;
  87111. /**
  87112. * Box-Imposter type
  87113. */
  87114. static BoxImpostor: number;
  87115. /**
  87116. * Plane-Imposter type
  87117. */
  87118. static PlaneImpostor: number;
  87119. /**
  87120. * Mesh-imposter type
  87121. */
  87122. static MeshImpostor: number;
  87123. /**
  87124. * Capsule-Impostor type (Ammo.js plugin only)
  87125. */
  87126. static CapsuleImpostor: number;
  87127. /**
  87128. * Cylinder-Imposter type
  87129. */
  87130. static CylinderImpostor: number;
  87131. /**
  87132. * Particle-Imposter type
  87133. */
  87134. static ParticleImpostor: number;
  87135. /**
  87136. * Heightmap-Imposter type
  87137. */
  87138. static HeightmapImpostor: number;
  87139. /**
  87140. * ConvexHull-Impostor type (Ammo.js plugin only)
  87141. */
  87142. static ConvexHullImpostor: number;
  87143. /**
  87144. * Rope-Imposter type
  87145. */
  87146. static RopeImpostor: number;
  87147. /**
  87148. * Cloth-Imposter type
  87149. */
  87150. static ClothImpostor: number;
  87151. /**
  87152. * Softbody-Imposter type
  87153. */
  87154. static SoftbodyImpostor: number;
  87155. }
  87156. }
  87157. declare module BABYLON {
  87158. /**
  87159. * @hidden
  87160. **/
  87161. export class _CreationDataStorage {
  87162. closePath?: boolean;
  87163. closeArray?: boolean;
  87164. idx: number[];
  87165. dashSize: number;
  87166. gapSize: number;
  87167. path3D: Path3D;
  87168. pathArray: Vector3[][];
  87169. arc: number;
  87170. radius: number;
  87171. cap: number;
  87172. tessellation: number;
  87173. }
  87174. /**
  87175. * @hidden
  87176. **/
  87177. class _InstanceDataStorage {
  87178. visibleInstances: any;
  87179. batchCache: _InstancesBatch;
  87180. instancesBufferSize: number;
  87181. instancesBuffer: Nullable<Buffer>;
  87182. instancesData: Float32Array;
  87183. overridenInstanceCount: number;
  87184. isFrozen: boolean;
  87185. previousBatch: Nullable<_InstancesBatch>;
  87186. hardwareInstancedRendering: boolean;
  87187. sideOrientation: number;
  87188. }
  87189. /**
  87190. * @hidden
  87191. **/
  87192. export class _InstancesBatch {
  87193. mustReturn: boolean;
  87194. visibleInstances: Nullable<InstancedMesh[]>[];
  87195. renderSelf: boolean[];
  87196. hardwareInstancedRendering: boolean[];
  87197. }
  87198. /**
  87199. * Class used to represent renderable models
  87200. */
  87201. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87202. /**
  87203. * Mesh side orientation : usually the external or front surface
  87204. */
  87205. static readonly FRONTSIDE: number;
  87206. /**
  87207. * Mesh side orientation : usually the internal or back surface
  87208. */
  87209. static readonly BACKSIDE: number;
  87210. /**
  87211. * Mesh side orientation : both internal and external or front and back surfaces
  87212. */
  87213. static readonly DOUBLESIDE: number;
  87214. /**
  87215. * Mesh side orientation : by default, `FRONTSIDE`
  87216. */
  87217. static readonly DEFAULTSIDE: number;
  87218. /**
  87219. * Mesh cap setting : no cap
  87220. */
  87221. static readonly NO_CAP: number;
  87222. /**
  87223. * Mesh cap setting : one cap at the beginning of the mesh
  87224. */
  87225. static readonly CAP_START: number;
  87226. /**
  87227. * Mesh cap setting : one cap at the end of the mesh
  87228. */
  87229. static readonly CAP_END: number;
  87230. /**
  87231. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87232. */
  87233. static readonly CAP_ALL: number;
  87234. /**
  87235. * Mesh pattern setting : no flip or rotate
  87236. */
  87237. static readonly NO_FLIP: number;
  87238. /**
  87239. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87240. */
  87241. static readonly FLIP_TILE: number;
  87242. /**
  87243. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87244. */
  87245. static readonly ROTATE_TILE: number;
  87246. /**
  87247. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87248. */
  87249. static readonly FLIP_ROW: number;
  87250. /**
  87251. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87252. */
  87253. static readonly ROTATE_ROW: number;
  87254. /**
  87255. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87256. */
  87257. static readonly FLIP_N_ROTATE_TILE: number;
  87258. /**
  87259. * Mesh pattern setting : rotate pattern and rotate
  87260. */
  87261. static readonly FLIP_N_ROTATE_ROW: number;
  87262. /**
  87263. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87264. */
  87265. static readonly CENTER: number;
  87266. /**
  87267. * Mesh tile positioning : part tiles on left
  87268. */
  87269. static readonly LEFT: number;
  87270. /**
  87271. * Mesh tile positioning : part tiles on right
  87272. */
  87273. static readonly RIGHT: number;
  87274. /**
  87275. * Mesh tile positioning : part tiles on top
  87276. */
  87277. static readonly TOP: number;
  87278. /**
  87279. * Mesh tile positioning : part tiles on bottom
  87280. */
  87281. static readonly BOTTOM: number;
  87282. /**
  87283. * Gets the default side orientation.
  87284. * @param orientation the orientation to value to attempt to get
  87285. * @returns the default orientation
  87286. * @hidden
  87287. */
  87288. static _GetDefaultSideOrientation(orientation?: number): number;
  87289. private _internalMeshDataInfo;
  87290. /**
  87291. * An event triggered before rendering the mesh
  87292. */
  87293. readonly onBeforeRenderObservable: Observable<Mesh>;
  87294. /**
  87295. * An event triggered before binding the mesh
  87296. */
  87297. readonly onBeforeBindObservable: Observable<Mesh>;
  87298. /**
  87299. * An event triggered after rendering the mesh
  87300. */
  87301. readonly onAfterRenderObservable: Observable<Mesh>;
  87302. /**
  87303. * An event triggered before drawing the mesh
  87304. */
  87305. readonly onBeforeDrawObservable: Observable<Mesh>;
  87306. private _onBeforeDrawObserver;
  87307. /**
  87308. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87309. */
  87310. onBeforeDraw: () => void;
  87311. /**
  87312. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87313. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87314. */
  87315. delayLoadState: number;
  87316. /**
  87317. * Gets the list of instances created from this mesh
  87318. * it is not supposed to be modified manually.
  87319. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87321. */
  87322. instances: InstancedMesh[];
  87323. /**
  87324. * Gets the file containing delay loading data for this mesh
  87325. */
  87326. delayLoadingFile: string;
  87327. /** @hidden */
  87328. _binaryInfo: any;
  87329. /**
  87330. * User defined function used to change how LOD level selection is done
  87331. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87332. */
  87333. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87334. /**
  87335. * Gets or sets the morph target manager
  87336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87337. */
  87338. morphTargetManager: Nullable<MorphTargetManager>;
  87339. /** @hidden */
  87340. _creationDataStorage: Nullable<_CreationDataStorage>;
  87341. /** @hidden */
  87342. _geometry: Nullable<Geometry>;
  87343. /** @hidden */
  87344. _delayInfo: Array<string>;
  87345. /** @hidden */
  87346. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87347. /** @hidden */
  87348. _instanceDataStorage: _InstanceDataStorage;
  87349. private _effectiveMaterial;
  87350. /** @hidden */
  87351. _shouldGenerateFlatShading: boolean;
  87352. /** @hidden */
  87353. _originalBuilderSideOrientation: number;
  87354. /**
  87355. * Use this property to change the original side orientation defined at construction time
  87356. */
  87357. overrideMaterialSideOrientation: Nullable<number>;
  87358. /**
  87359. * Gets the source mesh (the one used to clone this one from)
  87360. */
  87361. readonly source: Nullable<Mesh>;
  87362. /**
  87363. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87364. */
  87365. isUnIndexed: boolean;
  87366. /**
  87367. * @constructor
  87368. * @param name The value used by scene.getMeshByName() to do a lookup.
  87369. * @param scene The scene to add this mesh to.
  87370. * @param parent The parent of this mesh, if it has one
  87371. * @param source An optional Mesh from which geometry is shared, cloned.
  87372. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87373. * When false, achieved by calling a clone(), also passing False.
  87374. * This will make creation of children, recursive.
  87375. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87376. */
  87377. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87378. /**
  87379. * Gets the class name
  87380. * @returns the string "Mesh".
  87381. */
  87382. getClassName(): string;
  87383. /** @hidden */
  87384. readonly _isMesh: boolean;
  87385. /**
  87386. * Returns a description of this mesh
  87387. * @param fullDetails define if full details about this mesh must be used
  87388. * @returns a descriptive string representing this mesh
  87389. */
  87390. toString(fullDetails?: boolean): string;
  87391. /** @hidden */
  87392. _unBindEffect(): void;
  87393. /**
  87394. * Gets a boolean indicating if this mesh has LOD
  87395. */
  87396. readonly hasLODLevels: boolean;
  87397. /**
  87398. * Gets the list of MeshLODLevel associated with the current mesh
  87399. * @returns an array of MeshLODLevel
  87400. */
  87401. getLODLevels(): MeshLODLevel[];
  87402. private _sortLODLevels;
  87403. /**
  87404. * Add a mesh as LOD level triggered at the given distance.
  87405. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87406. * @param distance The distance from the center of the object to show this level
  87407. * @param mesh The mesh to be added as LOD level (can be null)
  87408. * @return This mesh (for chaining)
  87409. */
  87410. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87411. /**
  87412. * Returns the LOD level mesh at the passed distance or null if not found.
  87413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87414. * @param distance The distance from the center of the object to show this level
  87415. * @returns a Mesh or `null`
  87416. */
  87417. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87418. /**
  87419. * Remove a mesh from the LOD array
  87420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87421. * @param mesh defines the mesh to be removed
  87422. * @return This mesh (for chaining)
  87423. */
  87424. removeLODLevel(mesh: Mesh): Mesh;
  87425. /**
  87426. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87428. * @param camera defines the camera to use to compute distance
  87429. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87430. * @return This mesh (for chaining)
  87431. */
  87432. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87433. /**
  87434. * Gets the mesh internal Geometry object
  87435. */
  87436. readonly geometry: Nullable<Geometry>;
  87437. /**
  87438. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87439. * @returns the total number of vertices
  87440. */
  87441. getTotalVertices(): number;
  87442. /**
  87443. * Returns the content of an associated vertex buffer
  87444. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87445. * - VertexBuffer.PositionKind
  87446. * - VertexBuffer.UVKind
  87447. * - VertexBuffer.UV2Kind
  87448. * - VertexBuffer.UV3Kind
  87449. * - VertexBuffer.UV4Kind
  87450. * - VertexBuffer.UV5Kind
  87451. * - VertexBuffer.UV6Kind
  87452. * - VertexBuffer.ColorKind
  87453. * - VertexBuffer.MatricesIndicesKind
  87454. * - VertexBuffer.MatricesIndicesExtraKind
  87455. * - VertexBuffer.MatricesWeightsKind
  87456. * - VertexBuffer.MatricesWeightsExtraKind
  87457. * @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
  87458. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87459. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87460. */
  87461. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87462. /**
  87463. * Returns the mesh VertexBuffer object from the requested `kind`
  87464. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87465. * - VertexBuffer.PositionKind
  87466. * - VertexBuffer.NormalKind
  87467. * - VertexBuffer.UVKind
  87468. * - VertexBuffer.UV2Kind
  87469. * - VertexBuffer.UV3Kind
  87470. * - VertexBuffer.UV4Kind
  87471. * - VertexBuffer.UV5Kind
  87472. * - VertexBuffer.UV6Kind
  87473. * - VertexBuffer.ColorKind
  87474. * - VertexBuffer.MatricesIndicesKind
  87475. * - VertexBuffer.MatricesIndicesExtraKind
  87476. * - VertexBuffer.MatricesWeightsKind
  87477. * - VertexBuffer.MatricesWeightsExtraKind
  87478. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87479. */
  87480. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87481. /**
  87482. * Tests if a specific vertex buffer is associated with this mesh
  87483. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87484. * - VertexBuffer.PositionKind
  87485. * - VertexBuffer.NormalKind
  87486. * - VertexBuffer.UVKind
  87487. * - VertexBuffer.UV2Kind
  87488. * - VertexBuffer.UV3Kind
  87489. * - VertexBuffer.UV4Kind
  87490. * - VertexBuffer.UV5Kind
  87491. * - VertexBuffer.UV6Kind
  87492. * - VertexBuffer.ColorKind
  87493. * - VertexBuffer.MatricesIndicesKind
  87494. * - VertexBuffer.MatricesIndicesExtraKind
  87495. * - VertexBuffer.MatricesWeightsKind
  87496. * - VertexBuffer.MatricesWeightsExtraKind
  87497. * @returns a boolean
  87498. */
  87499. isVerticesDataPresent(kind: string): boolean;
  87500. /**
  87501. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87502. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87503. * - VertexBuffer.PositionKind
  87504. * - VertexBuffer.UVKind
  87505. * - VertexBuffer.UV2Kind
  87506. * - VertexBuffer.UV3Kind
  87507. * - VertexBuffer.UV4Kind
  87508. * - VertexBuffer.UV5Kind
  87509. * - VertexBuffer.UV6Kind
  87510. * - VertexBuffer.ColorKind
  87511. * - VertexBuffer.MatricesIndicesKind
  87512. * - VertexBuffer.MatricesIndicesExtraKind
  87513. * - VertexBuffer.MatricesWeightsKind
  87514. * - VertexBuffer.MatricesWeightsExtraKind
  87515. * @returns a boolean
  87516. */
  87517. isVertexBufferUpdatable(kind: string): boolean;
  87518. /**
  87519. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87520. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87521. * - VertexBuffer.PositionKind
  87522. * - VertexBuffer.NormalKind
  87523. * - VertexBuffer.UVKind
  87524. * - VertexBuffer.UV2Kind
  87525. * - VertexBuffer.UV3Kind
  87526. * - VertexBuffer.UV4Kind
  87527. * - VertexBuffer.UV5Kind
  87528. * - VertexBuffer.UV6Kind
  87529. * - VertexBuffer.ColorKind
  87530. * - VertexBuffer.MatricesIndicesKind
  87531. * - VertexBuffer.MatricesIndicesExtraKind
  87532. * - VertexBuffer.MatricesWeightsKind
  87533. * - VertexBuffer.MatricesWeightsExtraKind
  87534. * @returns an array of strings
  87535. */
  87536. getVerticesDataKinds(): string[];
  87537. /**
  87538. * Returns a positive integer : the total number of indices in this mesh geometry.
  87539. * @returns the numner of indices or zero if the mesh has no geometry.
  87540. */
  87541. getTotalIndices(): number;
  87542. /**
  87543. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87544. * @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.
  87545. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87546. * @returns the indices array or an empty array if the mesh has no geometry
  87547. */
  87548. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87549. readonly isBlocked: boolean;
  87550. /**
  87551. * Determine if the current mesh is ready to be rendered
  87552. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87553. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87554. * @returns true if all associated assets are ready (material, textures, shaders)
  87555. */
  87556. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87557. /**
  87558. * 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.
  87559. */
  87560. readonly areNormalsFrozen: boolean;
  87561. /**
  87562. * 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.
  87563. * @returns the current mesh
  87564. */
  87565. freezeNormals(): Mesh;
  87566. /**
  87567. * 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
  87568. * @returns the current mesh
  87569. */
  87570. unfreezeNormals(): Mesh;
  87571. /**
  87572. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87573. */
  87574. overridenInstanceCount: number;
  87575. /** @hidden */
  87576. _preActivate(): Mesh;
  87577. /** @hidden */
  87578. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87579. /** @hidden */
  87580. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87581. /**
  87582. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87583. * This means the mesh underlying bounding box and sphere are recomputed.
  87584. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87585. * @returns the current mesh
  87586. */
  87587. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87588. /** @hidden */
  87589. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87590. /**
  87591. * This function will subdivide the mesh into multiple submeshes
  87592. * @param count defines the expected number of submeshes
  87593. */
  87594. subdivide(count: number): void;
  87595. /**
  87596. * Copy a FloatArray into a specific associated vertex buffer
  87597. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87598. * - VertexBuffer.PositionKind
  87599. * - VertexBuffer.UVKind
  87600. * - VertexBuffer.UV2Kind
  87601. * - VertexBuffer.UV3Kind
  87602. * - VertexBuffer.UV4Kind
  87603. * - VertexBuffer.UV5Kind
  87604. * - VertexBuffer.UV6Kind
  87605. * - VertexBuffer.ColorKind
  87606. * - VertexBuffer.MatricesIndicesKind
  87607. * - VertexBuffer.MatricesIndicesExtraKind
  87608. * - VertexBuffer.MatricesWeightsKind
  87609. * - VertexBuffer.MatricesWeightsExtraKind
  87610. * @param data defines the data source
  87611. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87612. * @param stride defines the data stride size (can be null)
  87613. * @returns the current mesh
  87614. */
  87615. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87616. /**
  87617. * Flags an associated vertex buffer as updatable
  87618. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87619. * - VertexBuffer.PositionKind
  87620. * - VertexBuffer.UVKind
  87621. * - VertexBuffer.UV2Kind
  87622. * - VertexBuffer.UV3Kind
  87623. * - VertexBuffer.UV4Kind
  87624. * - VertexBuffer.UV5Kind
  87625. * - VertexBuffer.UV6Kind
  87626. * - VertexBuffer.ColorKind
  87627. * - VertexBuffer.MatricesIndicesKind
  87628. * - VertexBuffer.MatricesIndicesExtraKind
  87629. * - VertexBuffer.MatricesWeightsKind
  87630. * - VertexBuffer.MatricesWeightsExtraKind
  87631. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87632. */
  87633. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87634. /**
  87635. * Sets the mesh global Vertex Buffer
  87636. * @param buffer defines the buffer to use
  87637. * @returns the current mesh
  87638. */
  87639. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87640. /**
  87641. * Update a specific associated vertex buffer
  87642. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87643. * - VertexBuffer.PositionKind
  87644. * - VertexBuffer.UVKind
  87645. * - VertexBuffer.UV2Kind
  87646. * - VertexBuffer.UV3Kind
  87647. * - VertexBuffer.UV4Kind
  87648. * - VertexBuffer.UV5Kind
  87649. * - VertexBuffer.UV6Kind
  87650. * - VertexBuffer.ColorKind
  87651. * - VertexBuffer.MatricesIndicesKind
  87652. * - VertexBuffer.MatricesIndicesExtraKind
  87653. * - VertexBuffer.MatricesWeightsKind
  87654. * - VertexBuffer.MatricesWeightsExtraKind
  87655. * @param data defines the data source
  87656. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87657. * @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)
  87658. * @returns the current mesh
  87659. */
  87660. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87661. /**
  87662. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87663. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87664. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87665. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87666. * @returns the current mesh
  87667. */
  87668. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87669. /**
  87670. * Creates a un-shared specific occurence of the geometry for the mesh.
  87671. * @returns the current mesh
  87672. */
  87673. makeGeometryUnique(): Mesh;
  87674. /**
  87675. * Set the index buffer of this mesh
  87676. * @param indices defines the source data
  87677. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87678. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87679. * @returns the current mesh
  87680. */
  87681. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87682. /**
  87683. * Update the current index buffer
  87684. * @param indices defines the source data
  87685. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87686. * @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)
  87687. * @returns the current mesh
  87688. */
  87689. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87690. /**
  87691. * Invert the geometry to move from a right handed system to a left handed one.
  87692. * @returns the current mesh
  87693. */
  87694. toLeftHanded(): Mesh;
  87695. /** @hidden */
  87696. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87697. /** @hidden */
  87698. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87699. /**
  87700. * Registers for this mesh a javascript function called just before the rendering process
  87701. * @param func defines the function to call before rendering this mesh
  87702. * @returns the current mesh
  87703. */
  87704. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87705. /**
  87706. * Disposes a previously registered javascript function called before the rendering
  87707. * @param func defines the function to remove
  87708. * @returns the current mesh
  87709. */
  87710. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87711. /**
  87712. * Registers for this mesh a javascript function called just after the rendering is complete
  87713. * @param func defines the function to call after rendering this mesh
  87714. * @returns the current mesh
  87715. */
  87716. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87717. /**
  87718. * Disposes a previously registered javascript function called after the rendering.
  87719. * @param func defines the function to remove
  87720. * @returns the current mesh
  87721. */
  87722. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87723. /** @hidden */
  87724. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87725. /** @hidden */
  87726. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87727. /** @hidden */
  87728. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87729. /** @hidden */
  87730. _rebuild(): void;
  87731. /** @hidden */
  87732. _freeze(): void;
  87733. /** @hidden */
  87734. _unFreeze(): void;
  87735. /**
  87736. * 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
  87737. * @param subMesh defines the subMesh to render
  87738. * @param enableAlphaMode defines if alpha mode can be changed
  87739. * @returns the current mesh
  87740. */
  87741. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87742. private _onBeforeDraw;
  87743. /**
  87744. * Renormalize the mesh and patch it up if there are no weights
  87745. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87746. * However in the case of zero weights then we set just a single influence to 1.
  87747. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87748. */
  87749. cleanMatrixWeights(): void;
  87750. private normalizeSkinFourWeights;
  87751. private normalizeSkinWeightsAndExtra;
  87752. /**
  87753. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87754. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87755. * the user know there was an issue with importing the mesh
  87756. * @returns a validation object with skinned, valid and report string
  87757. */
  87758. validateSkinning(): {
  87759. skinned: boolean;
  87760. valid: boolean;
  87761. report: string;
  87762. };
  87763. /** @hidden */
  87764. _checkDelayState(): Mesh;
  87765. private _queueLoad;
  87766. /**
  87767. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87768. * A mesh is in the frustum if its bounding box intersects the frustum
  87769. * @param frustumPlanes defines the frustum to test
  87770. * @returns true if the mesh is in the frustum planes
  87771. */
  87772. isInFrustum(frustumPlanes: Plane[]): boolean;
  87773. /**
  87774. * Sets the mesh material by the material or multiMaterial `id` property
  87775. * @param id is a string identifying the material or the multiMaterial
  87776. * @returns the current mesh
  87777. */
  87778. setMaterialByID(id: string): Mesh;
  87779. /**
  87780. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87781. * @returns an array of IAnimatable
  87782. */
  87783. getAnimatables(): IAnimatable[];
  87784. /**
  87785. * Modifies the mesh geometry according to the passed transformation matrix.
  87786. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87787. * The mesh normals are modified using the same transformation.
  87788. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87789. * @param transform defines the transform matrix to use
  87790. * @see http://doc.babylonjs.com/resources/baking_transformations
  87791. * @returns the current mesh
  87792. */
  87793. bakeTransformIntoVertices(transform: Matrix): Mesh;
  87794. /**
  87795. * Modifies the mesh geometry according to its own current World Matrix.
  87796. * The mesh World Matrix is then reset.
  87797. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87798. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87799. * @see http://doc.babylonjs.com/resources/baking_transformations
  87800. * @returns the current mesh
  87801. */
  87802. bakeCurrentTransformIntoVertices(): Mesh;
  87803. /** @hidden */
  87804. readonly _positions: Nullable<Vector3[]>;
  87805. /** @hidden */
  87806. _resetPointsArrayCache(): Mesh;
  87807. /** @hidden */
  87808. _generatePointsArray(): boolean;
  87809. /**
  87810. * Returns a new Mesh object generated from the current mesh properties.
  87811. * This method must not get confused with createInstance()
  87812. * @param name is a string, the name given to the new mesh
  87813. * @param newParent can be any Node object (default `null`)
  87814. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87815. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87816. * @returns a new mesh
  87817. */
  87818. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87819. /**
  87820. * Releases resources associated with this mesh.
  87821. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87822. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87823. */
  87824. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87825. /**
  87826. * Modifies the mesh geometry according to a displacement map.
  87827. * 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.
  87828. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87829. * @param url is a string, the URL from the image file is to be downloaded.
  87830. * @param minHeight is the lower limit of the displacement.
  87831. * @param maxHeight is the upper limit of the displacement.
  87832. * @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.
  87833. * @param uvOffset is an optional vector2 used to offset UV.
  87834. * @param uvScale is an optional vector2 used to scale UV.
  87835. * @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.
  87836. * @returns the Mesh.
  87837. */
  87838. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87839. /**
  87840. * Modifies the mesh geometry according to a displacementMap buffer.
  87841. * 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.
  87842. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87843. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87844. * @param heightMapWidth is the width of the buffer image.
  87845. * @param heightMapHeight is the height of the buffer image.
  87846. * @param minHeight is the lower limit of the displacement.
  87847. * @param maxHeight is the upper limit of the displacement.
  87848. * @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.
  87849. * @param uvOffset is an optional vector2 used to offset UV.
  87850. * @param uvScale is an optional vector2 used to scale UV.
  87851. * @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.
  87852. * @returns the Mesh.
  87853. */
  87854. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87855. /**
  87856. * Modify the mesh to get a flat shading rendering.
  87857. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87858. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87859. * @returns current mesh
  87860. */
  87861. convertToFlatShadedMesh(): Mesh;
  87862. /**
  87863. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87864. * In other words, more vertices, no more indices and a single bigger VBO.
  87865. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87866. * @returns current mesh
  87867. */
  87868. convertToUnIndexedMesh(): Mesh;
  87869. /**
  87870. * Inverses facet orientations.
  87871. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87872. * @param flipNormals will also inverts the normals
  87873. * @returns current mesh
  87874. */
  87875. flipFaces(flipNormals?: boolean): Mesh;
  87876. /**
  87877. * Increase the number of facets and hence vertices in a mesh
  87878. * Vertex normals are interpolated from existing vertex normals
  87879. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87880. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87881. */
  87882. increaseVertices(numberPerEdge: number): void;
  87883. /**
  87884. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87885. * This will undo any application of covertToFlatShadedMesh
  87886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87887. */
  87888. forceSharedVertices(): void;
  87889. /** @hidden */
  87890. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87891. /** @hidden */
  87892. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87893. /**
  87894. * Creates a new InstancedMesh object from the mesh model.
  87895. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87896. * @param name defines the name of the new instance
  87897. * @returns a new InstancedMesh
  87898. */
  87899. createInstance(name: string): InstancedMesh;
  87900. /**
  87901. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87902. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87903. * @returns the current mesh
  87904. */
  87905. synchronizeInstances(): Mesh;
  87906. /**
  87907. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87908. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87909. * This should be used together with the simplification to avoid disappearing triangles.
  87910. * @param successCallback an optional success callback to be called after the optimization finished.
  87911. * @returns the current mesh
  87912. */
  87913. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87914. /**
  87915. * Serialize current mesh
  87916. * @param serializationObject defines the object which will receive the serialization data
  87917. */
  87918. serialize(serializationObject: any): void;
  87919. /** @hidden */
  87920. _syncGeometryWithMorphTargetManager(): void;
  87921. /** @hidden */
  87922. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87923. /**
  87924. * Returns a new Mesh object parsed from the source provided.
  87925. * @param parsedMesh is the source
  87926. * @param scene defines the hosting scene
  87927. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87928. * @returns a new Mesh
  87929. */
  87930. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87931. /**
  87932. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87933. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87934. * @param name defines the name of the mesh to create
  87935. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87936. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87937. * @param closePath creates a seam between the first and the last points of each path of the path array
  87938. * @param offset is taken in account only if the `pathArray` is containing a single path
  87939. * @param scene defines the hosting scene
  87940. * @param updatable defines if the mesh must be flagged as updatable
  87941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87942. * @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)
  87943. * @returns a new Mesh
  87944. */
  87945. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87946. /**
  87947. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87948. * @param name defines the name of the mesh to create
  87949. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87950. * @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
  87951. * @param scene defines the hosting scene
  87952. * @param updatable defines if the mesh must be flagged as updatable
  87953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87954. * @returns a new Mesh
  87955. */
  87956. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87957. /**
  87958. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87959. * @param name defines the name of the mesh to create
  87960. * @param size sets the size (float) of each box side (default 1)
  87961. * @param scene defines the hosting scene
  87962. * @param updatable defines if the mesh must be flagged as updatable
  87963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87964. * @returns a new Mesh
  87965. */
  87966. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87967. /**
  87968. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87969. * @param name defines the name of the mesh to create
  87970. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87971. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87972. * @param scene defines the hosting scene
  87973. * @param updatable defines if the mesh must be flagged as updatable
  87974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87975. * @returns a new Mesh
  87976. */
  87977. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87978. /**
  87979. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87980. * @param name defines the name of the mesh to create
  87981. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87982. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87983. * @param scene defines the hosting scene
  87984. * @returns a new Mesh
  87985. */
  87986. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87987. /**
  87988. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87989. * @param name defines the name of the mesh to create
  87990. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87991. * @param diameterTop set the top cap diameter (floats, default 1)
  87992. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87993. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87994. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87995. * @param scene defines the hosting scene
  87996. * @param updatable defines if the mesh must be flagged as updatable
  87997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87998. * @returns a new Mesh
  87999. */
  88000. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88001. /**
  88002. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88003. * @param name defines the name of the mesh to create
  88004. * @param diameter sets the diameter size (float) of the torus (default 1)
  88005. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88006. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88007. * @param scene defines the hosting scene
  88008. * @param updatable defines if the mesh must be flagged as updatable
  88009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88010. * @returns a new Mesh
  88011. */
  88012. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88013. /**
  88014. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88015. * @param name defines the name of the mesh to create
  88016. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88017. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88018. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88019. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88020. * @param p the number of windings on X axis (positive integers, default 2)
  88021. * @param q the number of windings on Y axis (positive integers, default 3)
  88022. * @param scene defines the hosting scene
  88023. * @param updatable defines if the mesh must be flagged as updatable
  88024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88025. * @returns a new Mesh
  88026. */
  88027. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88028. /**
  88029. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88030. * @param name defines the name of the mesh to create
  88031. * @param points is an array successive Vector3
  88032. * @param scene defines the hosting scene
  88033. * @param updatable defines if the mesh must be flagged as updatable
  88034. * @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).
  88035. * @returns a new Mesh
  88036. */
  88037. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88038. /**
  88039. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88040. * @param name defines the name of the mesh to create
  88041. * @param points is an array successive Vector3
  88042. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88043. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88044. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88045. * @param scene defines the hosting scene
  88046. * @param updatable defines if the mesh must be flagged as updatable
  88047. * @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)
  88048. * @returns a new Mesh
  88049. */
  88050. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88051. /**
  88052. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88053. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88054. * 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.
  88055. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88056. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88057. * Remember you can only change the shape positions, not their number when updating a polygon.
  88058. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88059. * @param name defines the name of the mesh to create
  88060. * @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
  88061. * @param scene defines the hosting scene
  88062. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88063. * @param updatable defines if the mesh must be flagged as updatable
  88064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88065. * @param earcutInjection can be used to inject your own earcut reference
  88066. * @returns a new Mesh
  88067. */
  88068. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88069. /**
  88070. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88072. * @param name defines the name of the mesh to create
  88073. * @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
  88074. * @param depth defines the height of extrusion
  88075. * @param scene defines the hosting scene
  88076. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88077. * @param updatable defines if the mesh must be flagged as updatable
  88078. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88079. * @param earcutInjection can be used to inject your own earcut reference
  88080. * @returns a new Mesh
  88081. */
  88082. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88083. /**
  88084. * Creates an extruded shape mesh.
  88085. * 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
  88086. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88088. * @param name defines the name of the mesh to create
  88089. * @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
  88090. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88091. * @param scale is the value to scale the shape
  88092. * @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
  88093. * @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
  88094. * @param scene defines the hosting scene
  88095. * @param updatable defines if the mesh must be flagged as updatable
  88096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88097. * @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)
  88098. * @returns a new Mesh
  88099. */
  88100. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88101. /**
  88102. * Creates an custom extruded shape mesh.
  88103. * The custom extrusion is a parametric shape.
  88104. * It has no predefined shape. Its final shape will depend on the input parameters.
  88105. * Please consider using the same method from the MeshBuilder class instead
  88106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88107. * @param name defines the name of the mesh to create
  88108. * @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
  88109. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88110. * @param scaleFunction is a custom Javascript function called on each path point
  88111. * @param rotationFunction is a custom Javascript function called on each path point
  88112. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88113. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88114. * @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
  88115. * @param scene defines the hosting scene
  88116. * @param updatable defines if the mesh must be flagged as updatable
  88117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88118. * @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)
  88119. * @returns a new Mesh
  88120. */
  88121. 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;
  88122. /**
  88123. * Creates lathe mesh.
  88124. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88125. * Please consider using the same method from the MeshBuilder class instead
  88126. * @param name defines the name of the mesh to create
  88127. * @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
  88128. * @param radius is the radius value of the lathe
  88129. * @param tessellation is the side number of the lathe.
  88130. * @param scene defines the hosting scene
  88131. * @param updatable defines if the mesh must be flagged as updatable
  88132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88133. * @returns a new Mesh
  88134. */
  88135. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88136. /**
  88137. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88138. * @param name defines the name of the mesh to create
  88139. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88140. * @param scene defines the hosting scene
  88141. * @param updatable defines if the mesh must be flagged as updatable
  88142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88143. * @returns a new Mesh
  88144. */
  88145. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88146. /**
  88147. * Creates a ground mesh.
  88148. * Please consider using the same method from the MeshBuilder class instead
  88149. * @param name defines the name of the mesh to create
  88150. * @param width set the width of the ground
  88151. * @param height set the height of the ground
  88152. * @param subdivisions sets the number of subdivisions per side
  88153. * @param scene defines the hosting scene
  88154. * @param updatable defines if the mesh must be flagged as updatable
  88155. * @returns a new Mesh
  88156. */
  88157. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88158. /**
  88159. * Creates a tiled ground mesh.
  88160. * Please consider using the same method from the MeshBuilder class instead
  88161. * @param name defines the name of the mesh to create
  88162. * @param xmin set the ground minimum X coordinate
  88163. * @param zmin set the ground minimum Y coordinate
  88164. * @param xmax set the ground maximum X coordinate
  88165. * @param zmax set the ground maximum Z coordinate
  88166. * @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
  88167. * @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
  88168. * @param scene defines the hosting scene
  88169. * @param updatable defines if the mesh must be flagged as updatable
  88170. * @returns a new Mesh
  88171. */
  88172. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88173. w: number;
  88174. h: number;
  88175. }, precision: {
  88176. w: number;
  88177. h: number;
  88178. }, scene: Scene, updatable?: boolean): Mesh;
  88179. /**
  88180. * Creates a ground mesh from a height map.
  88181. * Please consider using the same method from the MeshBuilder class instead
  88182. * @see http://doc.babylonjs.com/babylon101/height_map
  88183. * @param name defines the name of the mesh to create
  88184. * @param url sets the URL of the height map image resource
  88185. * @param width set the ground width size
  88186. * @param height set the ground height size
  88187. * @param subdivisions sets the number of subdivision per side
  88188. * @param minHeight is the minimum altitude on the ground
  88189. * @param maxHeight is the maximum altitude on the ground
  88190. * @param scene defines the hosting scene
  88191. * @param updatable defines if the mesh must be flagged as updatable
  88192. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88193. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88194. * @returns a new Mesh
  88195. */
  88196. 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;
  88197. /**
  88198. * Creates a tube mesh.
  88199. * The tube is a parametric shape.
  88200. * It has no predefined shape. Its final shape will depend on the input parameters.
  88201. * Please consider using the same method from the MeshBuilder class instead
  88202. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88203. * @param name defines the name of the mesh to create
  88204. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88205. * @param radius sets the tube radius size
  88206. * @param tessellation is the number of sides on the tubular surface
  88207. * @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
  88208. * @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
  88209. * @param scene defines the hosting scene
  88210. * @param updatable defines if the mesh must be flagged as updatable
  88211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88212. * @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)
  88213. * @returns a new Mesh
  88214. */
  88215. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88216. (i: number, distance: number): number;
  88217. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88218. /**
  88219. * Creates a polyhedron mesh.
  88220. * Please consider using the same method from the MeshBuilder class instead.
  88221. * * 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
  88222. * * The parameter `size` (positive float, default 1) sets the polygon size
  88223. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88224. * * 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`
  88225. * * 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
  88226. * * 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)`)
  88227. * * 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
  88228. * * 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
  88229. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88230. * * If you create a double-sided mesh, you can choose what parts of 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
  88231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88232. * @param name defines the name of the mesh to create
  88233. * @param options defines the options used to create the mesh
  88234. * @param scene defines the hosting scene
  88235. * @returns a new Mesh
  88236. */
  88237. static CreatePolyhedron(name: string, options: {
  88238. type?: number;
  88239. size?: number;
  88240. sizeX?: number;
  88241. sizeY?: number;
  88242. sizeZ?: number;
  88243. custom?: any;
  88244. faceUV?: Vector4[];
  88245. faceColors?: Color4[];
  88246. updatable?: boolean;
  88247. sideOrientation?: number;
  88248. }, scene: Scene): Mesh;
  88249. /**
  88250. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88251. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88252. * * 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`)
  88253. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88254. * * 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
  88255. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88256. * * If you create a double-sided mesh, you can choose what parts of 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
  88257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88258. * @param name defines the name of the mesh
  88259. * @param options defines the options used to create the mesh
  88260. * @param scene defines the hosting scene
  88261. * @returns a new Mesh
  88262. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88263. */
  88264. static CreateIcoSphere(name: string, options: {
  88265. radius?: number;
  88266. flat?: boolean;
  88267. subdivisions?: number;
  88268. sideOrientation?: number;
  88269. updatable?: boolean;
  88270. }, scene: Scene): Mesh;
  88271. /**
  88272. * Creates a decal mesh.
  88273. * Please consider using the same method from the MeshBuilder class instead.
  88274. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88275. * @param name defines the name of the mesh
  88276. * @param sourceMesh defines the mesh receiving the decal
  88277. * @param position sets the position of the decal in world coordinates
  88278. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88279. * @param size sets the decal scaling
  88280. * @param angle sets the angle to rotate the decal
  88281. * @returns a new Mesh
  88282. */
  88283. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88284. /**
  88285. * Prepare internal position array for software CPU skinning
  88286. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88287. */
  88288. setPositionsForCPUSkinning(): Float32Array;
  88289. /**
  88290. * Prepare internal normal array for software CPU skinning
  88291. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88292. */
  88293. setNormalsForCPUSkinning(): Float32Array;
  88294. /**
  88295. * Updates the vertex buffer by applying transformation from the bones
  88296. * @param skeleton defines the skeleton to apply to current mesh
  88297. * @returns the current mesh
  88298. */
  88299. applySkeleton(skeleton: Skeleton): Mesh;
  88300. /**
  88301. * 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
  88302. * @param meshes defines the list of meshes to scan
  88303. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88304. */
  88305. static MinMax(meshes: AbstractMesh[]): {
  88306. min: Vector3;
  88307. max: Vector3;
  88308. };
  88309. /**
  88310. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88311. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88312. * @returns a vector3
  88313. */
  88314. static Center(meshesOrMinMaxVector: {
  88315. min: Vector3;
  88316. max: Vector3;
  88317. } | AbstractMesh[]): Vector3;
  88318. /**
  88319. * Merge the array of meshes into a single mesh for performance reasons.
  88320. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88321. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88322. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88323. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88324. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88325. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88326. * @returns a new mesh
  88327. */
  88328. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88329. /** @hidden */
  88330. addInstance(instance: InstancedMesh): void;
  88331. /** @hidden */
  88332. removeInstance(instance: InstancedMesh): void;
  88333. }
  88334. }
  88335. declare module BABYLON {
  88336. /**
  88337. * This is the base class of all the camera used in the application.
  88338. * @see http://doc.babylonjs.com/features/cameras
  88339. */
  88340. export class Camera extends Node {
  88341. /** @hidden */
  88342. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88343. /**
  88344. * This is the default projection mode used by the cameras.
  88345. * It helps recreating a feeling of perspective and better appreciate depth.
  88346. * This is the best way to simulate real life cameras.
  88347. */
  88348. static readonly PERSPECTIVE_CAMERA: number;
  88349. /**
  88350. * This helps creating camera with an orthographic mode.
  88351. * 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.
  88352. */
  88353. static readonly ORTHOGRAPHIC_CAMERA: number;
  88354. /**
  88355. * This is the default FOV mode for perspective cameras.
  88356. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88357. */
  88358. static readonly FOVMODE_VERTICAL_FIXED: number;
  88359. /**
  88360. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88361. */
  88362. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88363. /**
  88364. * This specifies ther is no need for a camera rig.
  88365. * Basically only one eye is rendered corresponding to the camera.
  88366. */
  88367. static readonly RIG_MODE_NONE: number;
  88368. /**
  88369. * Simulates a camera Rig with one blue eye and one red eye.
  88370. * This can be use with 3d blue and red glasses.
  88371. */
  88372. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88373. /**
  88374. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88375. */
  88376. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88377. /**
  88378. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88379. */
  88380. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88381. /**
  88382. * Defines that both eyes of the camera will be rendered over under each other.
  88383. */
  88384. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88385. /**
  88386. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88387. */
  88388. static readonly RIG_MODE_VR: number;
  88389. /**
  88390. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88391. */
  88392. static readonly RIG_MODE_WEBVR: number;
  88393. /**
  88394. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88395. */
  88396. static readonly RIG_MODE_CUSTOM: number;
  88397. /**
  88398. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88399. */
  88400. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88401. /**
  88402. * Define the input manager associated with the camera.
  88403. */
  88404. inputs: CameraInputsManager<Camera>;
  88405. /** @hidden */
  88406. _position: Vector3;
  88407. /**
  88408. * Define the current local position of the camera in the scene
  88409. */
  88410. position: Vector3;
  88411. /**
  88412. * The vector the camera should consider as up.
  88413. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88414. */
  88415. upVector: Vector3;
  88416. /**
  88417. * Define the current limit on the left side for an orthographic camera
  88418. * In scene unit
  88419. */
  88420. orthoLeft: Nullable<number>;
  88421. /**
  88422. * Define the current limit on the right side for an orthographic camera
  88423. * In scene unit
  88424. */
  88425. orthoRight: Nullable<number>;
  88426. /**
  88427. * Define the current limit on the bottom side for an orthographic camera
  88428. * In scene unit
  88429. */
  88430. orthoBottom: Nullable<number>;
  88431. /**
  88432. * Define the current limit on the top side for an orthographic camera
  88433. * In scene unit
  88434. */
  88435. orthoTop: Nullable<number>;
  88436. /**
  88437. * Field Of View is set in Radians. (default is 0.8)
  88438. */
  88439. fov: number;
  88440. /**
  88441. * Define the minimum distance the camera can see from.
  88442. * This is important to note that the depth buffer are not infinite and the closer it starts
  88443. * the more your scene might encounter depth fighting issue.
  88444. */
  88445. minZ: number;
  88446. /**
  88447. * Define the maximum distance the camera can see to.
  88448. * This is important to note that the depth buffer are not infinite and the further it end
  88449. * the more your scene might encounter depth fighting issue.
  88450. */
  88451. maxZ: number;
  88452. /**
  88453. * Define the default inertia of the camera.
  88454. * This helps giving a smooth feeling to the camera movement.
  88455. */
  88456. inertia: number;
  88457. /**
  88458. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88459. */
  88460. mode: number;
  88461. /**
  88462. * Define wether the camera is intermediate.
  88463. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88464. */
  88465. isIntermediate: boolean;
  88466. /**
  88467. * Define the viewport of the camera.
  88468. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88469. */
  88470. viewport: Viewport;
  88471. /**
  88472. * Restricts the camera to viewing objects with the same layerMask.
  88473. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88474. */
  88475. layerMask: number;
  88476. /**
  88477. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88478. */
  88479. fovMode: number;
  88480. /**
  88481. * Rig mode of the camera.
  88482. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88483. * This is normally controlled byt the camera themselves as internal use.
  88484. */
  88485. cameraRigMode: number;
  88486. /**
  88487. * Defines the distance between both "eyes" in case of a RIG
  88488. */
  88489. interaxialDistance: number;
  88490. /**
  88491. * Defines if stereoscopic rendering is done side by side or over under.
  88492. */
  88493. isStereoscopicSideBySide: boolean;
  88494. /**
  88495. * 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
  88496. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88497. * else in the scene. (Eg. security camera)
  88498. *
  88499. * 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)
  88500. */
  88501. customRenderTargets: RenderTargetTexture[];
  88502. /**
  88503. * When set, the camera will render to this render target instead of the default canvas
  88504. *
  88505. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88506. */
  88507. outputRenderTarget: Nullable<RenderTargetTexture>;
  88508. /**
  88509. * Observable triggered when the camera view matrix has changed.
  88510. */
  88511. onViewMatrixChangedObservable: Observable<Camera>;
  88512. /**
  88513. * Observable triggered when the camera Projection matrix has changed.
  88514. */
  88515. onProjectionMatrixChangedObservable: Observable<Camera>;
  88516. /**
  88517. * Observable triggered when the inputs have been processed.
  88518. */
  88519. onAfterCheckInputsObservable: Observable<Camera>;
  88520. /**
  88521. * Observable triggered when reset has been called and applied to the camera.
  88522. */
  88523. onRestoreStateObservable: Observable<Camera>;
  88524. /** @hidden */
  88525. _cameraRigParams: any;
  88526. /** @hidden */
  88527. _rigCameras: Camera[];
  88528. /** @hidden */
  88529. _rigPostProcess: Nullable<PostProcess>;
  88530. protected _webvrViewMatrix: Matrix;
  88531. /** @hidden */
  88532. _skipRendering: boolean;
  88533. /** @hidden */
  88534. _projectionMatrix: Matrix;
  88535. /** @hidden */
  88536. _postProcesses: Nullable<PostProcess>[];
  88537. /** @hidden */
  88538. _activeMeshes: SmartArray<AbstractMesh>;
  88539. protected _globalPosition: Vector3;
  88540. /** @hidden */
  88541. _computedViewMatrix: Matrix;
  88542. private _doNotComputeProjectionMatrix;
  88543. private _transformMatrix;
  88544. private _frustumPlanes;
  88545. private _refreshFrustumPlanes;
  88546. private _storedFov;
  88547. private _stateStored;
  88548. /**
  88549. * Instantiates a new camera object.
  88550. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88551. * @see http://doc.babylonjs.com/features/cameras
  88552. * @param name Defines the name of the camera in the scene
  88553. * @param position Defines the position of the camera
  88554. * @param scene Defines the scene the camera belongs too
  88555. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88556. */
  88557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88558. /**
  88559. * Store current camera state (fov, position, etc..)
  88560. * @returns the camera
  88561. */
  88562. storeState(): Camera;
  88563. /**
  88564. * Restores the camera state values if it has been stored. You must call storeState() first
  88565. */
  88566. protected _restoreStateValues(): boolean;
  88567. /**
  88568. * Restored camera state. You must call storeState() first.
  88569. * @returns true if restored and false otherwise
  88570. */
  88571. restoreState(): boolean;
  88572. /**
  88573. * Gets the class name of the camera.
  88574. * @returns the class name
  88575. */
  88576. getClassName(): string;
  88577. /** @hidden */
  88578. readonly _isCamera: boolean;
  88579. /**
  88580. * Gets a string representation of the camera useful for debug purpose.
  88581. * @param fullDetails Defines that a more verboe level of logging is required
  88582. * @returns the string representation
  88583. */
  88584. toString(fullDetails?: boolean): string;
  88585. /**
  88586. * Gets the current world space position of the camera.
  88587. */
  88588. readonly globalPosition: Vector3;
  88589. /**
  88590. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88591. * @returns the active meshe list
  88592. */
  88593. getActiveMeshes(): SmartArray<AbstractMesh>;
  88594. /**
  88595. * Check wether a mesh is part of the current active mesh list of the camera
  88596. * @param mesh Defines the mesh to check
  88597. * @returns true if active, false otherwise
  88598. */
  88599. isActiveMesh(mesh: Mesh): boolean;
  88600. /**
  88601. * Is this camera ready to be used/rendered
  88602. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88603. * @return true if the camera is ready
  88604. */
  88605. isReady(completeCheck?: boolean): boolean;
  88606. /** @hidden */
  88607. _initCache(): void;
  88608. /** @hidden */
  88609. _updateCache(ignoreParentClass?: boolean): void;
  88610. /** @hidden */
  88611. _isSynchronized(): boolean;
  88612. /** @hidden */
  88613. _isSynchronizedViewMatrix(): boolean;
  88614. /** @hidden */
  88615. _isSynchronizedProjectionMatrix(): boolean;
  88616. /**
  88617. * Attach the input controls to a specific dom element to get the input from.
  88618. * @param element Defines the element the controls should be listened from
  88619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88620. */
  88621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88622. /**
  88623. * Detach the current controls from the specified dom element.
  88624. * @param element Defines the element to stop listening the inputs from
  88625. */
  88626. detachControl(element: HTMLElement): void;
  88627. /**
  88628. * Update the camera state according to the different inputs gathered during the frame.
  88629. */
  88630. update(): void;
  88631. /** @hidden */
  88632. _checkInputs(): void;
  88633. /** @hidden */
  88634. readonly rigCameras: Camera[];
  88635. /**
  88636. * Gets the post process used by the rig cameras
  88637. */
  88638. readonly rigPostProcess: Nullable<PostProcess>;
  88639. /**
  88640. * Internal, gets the first post proces.
  88641. * @returns the first post process to be run on this camera.
  88642. */
  88643. _getFirstPostProcess(): Nullable<PostProcess>;
  88644. private _cascadePostProcessesToRigCams;
  88645. /**
  88646. * Attach a post process to the camera.
  88647. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88648. * @param postProcess The post process to attach to the camera
  88649. * @param insertAt The position of the post process in case several of them are in use in the scene
  88650. * @returns the position the post process has been inserted at
  88651. */
  88652. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88653. /**
  88654. * Detach a post process to the camera.
  88655. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88656. * @param postProcess The post process to detach from the camera
  88657. */
  88658. detachPostProcess(postProcess: PostProcess): void;
  88659. /**
  88660. * Gets the current world matrix of the camera
  88661. */
  88662. getWorldMatrix(): Matrix;
  88663. /** @hidden */
  88664. _getViewMatrix(): Matrix;
  88665. /**
  88666. * Gets the current view matrix of the camera.
  88667. * @param force forces the camera to recompute the matrix without looking at the cached state
  88668. * @returns the view matrix
  88669. */
  88670. getViewMatrix(force?: boolean): Matrix;
  88671. /**
  88672. * Freeze the projection matrix.
  88673. * It will prevent the cache check of the camera projection compute and can speed up perf
  88674. * if no parameter of the camera are meant to change
  88675. * @param projection Defines manually a projection if necessary
  88676. */
  88677. freezeProjectionMatrix(projection?: Matrix): void;
  88678. /**
  88679. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88680. */
  88681. unfreezeProjectionMatrix(): void;
  88682. /**
  88683. * Gets the current projection matrix of the camera.
  88684. * @param force forces the camera to recompute the matrix without looking at the cached state
  88685. * @returns the projection matrix
  88686. */
  88687. getProjectionMatrix(force?: boolean): Matrix;
  88688. /**
  88689. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88690. * @returns a Matrix
  88691. */
  88692. getTransformationMatrix(): Matrix;
  88693. private _updateFrustumPlanes;
  88694. /**
  88695. * Checks if a cullable object (mesh...) is in the camera frustum
  88696. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88697. * @param target The object to check
  88698. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88699. * @returns true if the object is in frustum otherwise false
  88700. */
  88701. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88702. /**
  88703. * Checks if a cullable object (mesh...) is in the camera frustum
  88704. * Unlike isInFrustum this cheks the full bounding box
  88705. * @param target The object to check
  88706. * @returns true if the object is in frustum otherwise false
  88707. */
  88708. isCompletelyInFrustum(target: ICullable): boolean;
  88709. /**
  88710. * Gets a ray in the forward direction from the camera.
  88711. * @param length Defines the length of the ray to create
  88712. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88713. * @param origin Defines the start point of the ray which defaults to the camera position
  88714. * @returns the forward ray
  88715. */
  88716. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88717. /**
  88718. * Releases resources associated with this node.
  88719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88721. */
  88722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88723. /** @hidden */
  88724. _isLeftCamera: boolean;
  88725. /**
  88726. * Gets the left camera of a rig setup in case of Rigged Camera
  88727. */
  88728. readonly isLeftCamera: boolean;
  88729. /** @hidden */
  88730. _isRightCamera: boolean;
  88731. /**
  88732. * Gets the right camera of a rig setup in case of Rigged Camera
  88733. */
  88734. readonly isRightCamera: boolean;
  88735. /**
  88736. * Gets the left camera of a rig setup in case of Rigged Camera
  88737. */
  88738. readonly leftCamera: Nullable<FreeCamera>;
  88739. /**
  88740. * Gets the right camera of a rig setup in case of Rigged Camera
  88741. */
  88742. readonly rightCamera: Nullable<FreeCamera>;
  88743. /**
  88744. * Gets the left camera target of a rig setup in case of Rigged Camera
  88745. * @returns the target position
  88746. */
  88747. getLeftTarget(): Nullable<Vector3>;
  88748. /**
  88749. * Gets the right camera target of a rig setup in case of Rigged Camera
  88750. * @returns the target position
  88751. */
  88752. getRightTarget(): Nullable<Vector3>;
  88753. /**
  88754. * @hidden
  88755. */
  88756. setCameraRigMode(mode: number, rigParams: any): void;
  88757. /** @hidden */
  88758. static _setStereoscopicRigMode(camera: Camera): void;
  88759. /** @hidden */
  88760. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88761. /** @hidden */
  88762. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88763. /** @hidden */
  88764. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88765. /** @hidden */
  88766. _getVRProjectionMatrix(): Matrix;
  88767. protected _updateCameraRotationMatrix(): void;
  88768. protected _updateWebVRCameraRotationMatrix(): void;
  88769. /**
  88770. * This function MUST be overwritten by the different WebVR cameras available.
  88771. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88772. * @hidden
  88773. */
  88774. _getWebVRProjectionMatrix(): Matrix;
  88775. /**
  88776. * This function MUST be overwritten by the different WebVR cameras available.
  88777. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88778. * @hidden
  88779. */
  88780. _getWebVRViewMatrix(): Matrix;
  88781. /** @hidden */
  88782. setCameraRigParameter(name: string, value: any): void;
  88783. /**
  88784. * needs to be overridden by children so sub has required properties to be copied
  88785. * @hidden
  88786. */
  88787. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88788. /**
  88789. * May need to be overridden by children
  88790. * @hidden
  88791. */
  88792. _updateRigCameras(): void;
  88793. /** @hidden */
  88794. _setupInputs(): void;
  88795. /**
  88796. * Serialiaze the camera setup to a json represention
  88797. * @returns the JSON representation
  88798. */
  88799. serialize(): any;
  88800. /**
  88801. * Clones the current camera.
  88802. * @param name The cloned camera name
  88803. * @returns the cloned camera
  88804. */
  88805. clone(name: string): Camera;
  88806. /**
  88807. * Gets the direction of the camera relative to a given local axis.
  88808. * @param localAxis Defines the reference axis to provide a relative direction.
  88809. * @return the direction
  88810. */
  88811. getDirection(localAxis: Vector3): Vector3;
  88812. /**
  88813. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88814. * @param localAxis Defines the reference axis to provide a relative direction.
  88815. * @param result Defines the vector to store the result in
  88816. */
  88817. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88818. /**
  88819. * Gets a camera constructor for a given camera type
  88820. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88821. * @param name The name of the camera the result will be able to instantiate
  88822. * @param scene The scene the result will construct the camera in
  88823. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88824. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88825. * @returns a factory method to construc the camera
  88826. */
  88827. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88828. /**
  88829. * Compute the world matrix of the camera.
  88830. * @returns the camera workd matrix
  88831. */
  88832. computeWorldMatrix(): Matrix;
  88833. /**
  88834. * Parse a JSON and creates the camera from the parsed information
  88835. * @param parsedCamera The JSON to parse
  88836. * @param scene The scene to instantiate the camera in
  88837. * @returns the newly constructed camera
  88838. */
  88839. static Parse(parsedCamera: any, scene: Scene): Camera;
  88840. }
  88841. }
  88842. declare module BABYLON {
  88843. /**
  88844. * Class containing static functions to help procedurally build meshes
  88845. */
  88846. export class DiscBuilder {
  88847. /**
  88848. * Creates a plane polygonal mesh. By default, this is a disc
  88849. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88850. * * 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
  88851. * * 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
  88852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88855. * @param name defines the name of the mesh
  88856. * @param options defines the options used to create the mesh
  88857. * @param scene defines the hosting scene
  88858. * @returns the plane polygonal mesh
  88859. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88860. */
  88861. static CreateDisc(name: string, options: {
  88862. radius?: number;
  88863. tessellation?: number;
  88864. arc?: number;
  88865. updatable?: boolean;
  88866. sideOrientation?: number;
  88867. frontUVs?: Vector4;
  88868. backUVs?: Vector4;
  88869. }, scene?: Nullable<Scene>): Mesh;
  88870. }
  88871. }
  88872. declare module BABYLON {
  88873. /**
  88874. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88875. *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.
  88876. * The SPS is also a particle system. It provides some methods to manage the particles.
  88877. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88878. *
  88879. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  88880. */
  88881. export class SolidParticleSystem implements IDisposable {
  88882. /**
  88883. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88884. * Example : var p = SPS.particles[i];
  88885. */
  88886. particles: SolidParticle[];
  88887. /**
  88888. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88889. */
  88890. nbParticles: number;
  88891. /**
  88892. * If the particles must ever face the camera (default false). Useful for planar particles.
  88893. */
  88894. billboard: boolean;
  88895. /**
  88896. * Recompute normals when adding a shape
  88897. */
  88898. recomputeNormals: boolean;
  88899. /**
  88900. * This a counter ofr your own usage. It's not set by any SPS functions.
  88901. */
  88902. counter: number;
  88903. /**
  88904. * The SPS name. This name is also given to the underlying mesh.
  88905. */
  88906. name: string;
  88907. /**
  88908. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88909. */
  88910. mesh: Mesh;
  88911. /**
  88912. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88913. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  88914. */
  88915. vars: any;
  88916. /**
  88917. * This array is populated when the SPS is set as 'pickable'.
  88918. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88919. * Each element of this array is an object `{idx: int, faceId: int}`.
  88920. * `idx` is the picked particle index in the `SPS.particles` array
  88921. * `faceId` is the picked face index counted within this particle.
  88922. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  88923. */
  88924. pickedParticles: {
  88925. idx: number;
  88926. faceId: number;
  88927. }[];
  88928. /**
  88929. * This array is populated when `enableDepthSort` is set to true.
  88930. * Each element of this array is an instance of the class DepthSortedParticle.
  88931. */
  88932. depthSortedParticles: DepthSortedParticle[];
  88933. /**
  88934. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88935. * @hidden
  88936. */
  88937. _bSphereOnly: boolean;
  88938. /**
  88939. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88940. * @hidden
  88941. */
  88942. _bSphereRadiusFactor: number;
  88943. private _scene;
  88944. private _positions;
  88945. private _indices;
  88946. private _normals;
  88947. private _colors;
  88948. private _uvs;
  88949. private _indices32;
  88950. private _positions32;
  88951. private _normals32;
  88952. private _fixedNormal32;
  88953. private _colors32;
  88954. private _uvs32;
  88955. private _index;
  88956. private _updatable;
  88957. private _pickable;
  88958. private _isVisibilityBoxLocked;
  88959. private _alwaysVisible;
  88960. private _depthSort;
  88961. private _shapeCounter;
  88962. private _copy;
  88963. private _color;
  88964. private _computeParticleColor;
  88965. private _computeParticleTexture;
  88966. private _computeParticleRotation;
  88967. private _computeParticleVertex;
  88968. private _computeBoundingBox;
  88969. private _depthSortParticles;
  88970. private _camera;
  88971. private _mustUnrotateFixedNormals;
  88972. private _particlesIntersect;
  88973. private _needs32Bits;
  88974. /**
  88975. * Creates a SPS (Solid Particle System) object.
  88976. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88977. * @param scene (Scene) is the scene in which the SPS is added.
  88978. * @param options defines the options of the sps e.g.
  88979. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88980. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88981. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88982. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88983. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88984. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88985. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88986. */
  88987. constructor(name: string, scene: Scene, options?: {
  88988. updatable?: boolean;
  88989. isPickable?: boolean;
  88990. enableDepthSort?: boolean;
  88991. particleIntersection?: boolean;
  88992. boundingSphereOnly?: boolean;
  88993. bSphereRadiusFactor?: number;
  88994. });
  88995. /**
  88996. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88997. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88998. * @returns the created mesh
  88999. */
  89000. buildMesh(): Mesh;
  89001. /**
  89002. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89003. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89004. * Thus the particles generated from `digest()` have their property `position` set yet.
  89005. * @param mesh ( Mesh ) is the mesh to be digested
  89006. * @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
  89007. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89008. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89009. * @returns the current SPS
  89010. */
  89011. digest(mesh: Mesh, options?: {
  89012. facetNb?: number;
  89013. number?: number;
  89014. delta?: number;
  89015. }): SolidParticleSystem;
  89016. private _unrotateFixedNormals;
  89017. private _resetCopy;
  89018. private _meshBuilder;
  89019. private _posToShape;
  89020. private _uvsToShapeUV;
  89021. private _addParticle;
  89022. /**
  89023. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89024. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89025. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89026. * @param nb (positive integer) the number of particles to be created from this model
  89027. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89028. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89029. * @returns the number of shapes in the system
  89030. */
  89031. addShape(mesh: Mesh, nb: number, options?: {
  89032. positionFunction?: any;
  89033. vertexFunction?: any;
  89034. }): number;
  89035. private _rebuildParticle;
  89036. /**
  89037. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89038. * @returns the SPS.
  89039. */
  89040. rebuildMesh(): SolidParticleSystem;
  89041. /**
  89042. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89043. * This method calls `updateParticle()` for each particle of the SPS.
  89044. * For an animated SPS, it is usually called within the render loop.
  89045. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89046. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89047. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89048. * @returns the SPS.
  89049. */
  89050. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89051. /**
  89052. * Disposes the SPS.
  89053. */
  89054. dispose(): void;
  89055. /**
  89056. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89057. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89058. * @returns the SPS.
  89059. */
  89060. refreshVisibleSize(): SolidParticleSystem;
  89061. /**
  89062. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89063. * @param size the size (float) of the visibility box
  89064. * note : this doesn't lock the SPS mesh bounding box.
  89065. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89066. */
  89067. setVisibilityBox(size: number): void;
  89068. /**
  89069. * Gets whether the SPS as always visible or not
  89070. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89071. */
  89072. /**
  89073. * Sets the SPS as always visible or not
  89074. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89075. */
  89076. isAlwaysVisible: boolean;
  89077. /**
  89078. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89079. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89080. */
  89081. /**
  89082. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89083. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89084. */
  89085. isVisibilityBoxLocked: boolean;
  89086. /**
  89087. * Tells to `setParticles()` to compute the particle rotations or not.
  89088. * Default value : true. The SPS is faster when it's set to false.
  89089. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89090. */
  89091. /**
  89092. * Gets if `setParticles()` computes the particle rotations or not.
  89093. * Default value : true. The SPS is faster when it's set to false.
  89094. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89095. */
  89096. computeParticleRotation: boolean;
  89097. /**
  89098. * Tells to `setParticles()` to compute the particle colors or not.
  89099. * Default value : true. The SPS is faster when it's set to false.
  89100. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89101. */
  89102. /**
  89103. * Gets if `setParticles()` computes the particle colors or not.
  89104. * Default value : true. The SPS is faster when it's set to false.
  89105. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89106. */
  89107. computeParticleColor: boolean;
  89108. /**
  89109. * Gets if `setParticles()` computes the particle textures or not.
  89110. * Default value : true. The SPS is faster when it's set to false.
  89111. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89112. */
  89113. computeParticleTexture: boolean;
  89114. /**
  89115. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89116. * Default value : false. The SPS is faster when it's set to false.
  89117. * Note : the particle custom vertex positions aren't stored values.
  89118. */
  89119. /**
  89120. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89121. * Default value : false. The SPS is faster when it's set to false.
  89122. * Note : the particle custom vertex positions aren't stored values.
  89123. */
  89124. computeParticleVertex: boolean;
  89125. /**
  89126. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89127. */
  89128. /**
  89129. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89130. */
  89131. computeBoundingBox: boolean;
  89132. /**
  89133. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89134. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89135. * Default : `true`
  89136. */
  89137. /**
  89138. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89139. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89140. * Default : `true`
  89141. */
  89142. depthSortParticles: boolean;
  89143. /**
  89144. * This function does nothing. It may be overwritten to set all the particle first values.
  89145. * The SPS doesn't call this function, you may have to call it by your own.
  89146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89147. */
  89148. initParticles(): void;
  89149. /**
  89150. * This function does nothing. It may be overwritten to recycle a particle.
  89151. * The SPS doesn't call this function, you may have to call it by your own.
  89152. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89153. * @param particle The particle to recycle
  89154. * @returns the recycled particle
  89155. */
  89156. recycleParticle(particle: SolidParticle): SolidParticle;
  89157. /**
  89158. * Updates a particle : this function should be overwritten by the user.
  89159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89161. * @example : just set a particle position or velocity and recycle conditions
  89162. * @param particle The particle to update
  89163. * @returns the updated particle
  89164. */
  89165. updateParticle(particle: SolidParticle): SolidParticle;
  89166. /**
  89167. * Updates a vertex of a particle : it can be overwritten by the user.
  89168. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89169. * @param particle the current particle
  89170. * @param vertex the current index of the current particle
  89171. * @param pt the index of the current vertex in the particle shape
  89172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89173. * @example : just set a vertex particle position
  89174. * @returns the updated vertex
  89175. */
  89176. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89177. /**
  89178. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89179. * This does nothing and may be overwritten by the user.
  89180. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89181. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89182. * @param update the boolean update value actually passed to setParticles()
  89183. */
  89184. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89185. /**
  89186. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89187. * This will be passed three parameters.
  89188. * This does nothing and may be overwritten by the user.
  89189. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89191. * @param update the boolean update value actually passed to setParticles()
  89192. */
  89193. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89194. }
  89195. }
  89196. declare module BABYLON {
  89197. /**
  89198. * Represents one particle of a solid particle system.
  89199. */
  89200. export class SolidParticle {
  89201. /**
  89202. * particle global index
  89203. */
  89204. idx: number;
  89205. /**
  89206. * The color of the particle
  89207. */
  89208. color: Nullable<Color4>;
  89209. /**
  89210. * The world space position of the particle.
  89211. */
  89212. position: Vector3;
  89213. /**
  89214. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89215. */
  89216. rotation: Vector3;
  89217. /**
  89218. * The world space rotation quaternion of the particle.
  89219. */
  89220. rotationQuaternion: Nullable<Quaternion>;
  89221. /**
  89222. * The scaling of the particle.
  89223. */
  89224. scaling: Vector3;
  89225. /**
  89226. * The uvs of the particle.
  89227. */
  89228. uvs: Vector4;
  89229. /**
  89230. * The current speed of the particle.
  89231. */
  89232. velocity: Vector3;
  89233. /**
  89234. * The pivot point in the particle local space.
  89235. */
  89236. pivot: Vector3;
  89237. /**
  89238. * Must the particle be translated from its pivot point in its local space ?
  89239. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89240. * Default : false
  89241. */
  89242. translateFromPivot: boolean;
  89243. /**
  89244. * Is the particle active or not ?
  89245. */
  89246. alive: boolean;
  89247. /**
  89248. * Is the particle visible or not ?
  89249. */
  89250. isVisible: boolean;
  89251. /**
  89252. * Index of this particle in the global "positions" array (Internal use)
  89253. * @hidden
  89254. */
  89255. _pos: number;
  89256. /**
  89257. * @hidden Index of this particle in the global "indices" array (Internal use)
  89258. */
  89259. _ind: number;
  89260. /**
  89261. * @hidden ModelShape of this particle (Internal use)
  89262. */
  89263. _model: ModelShape;
  89264. /**
  89265. * ModelShape id of this particle
  89266. */
  89267. shapeId: number;
  89268. /**
  89269. * Index of the particle in its shape id (Internal use)
  89270. */
  89271. idxInShape: number;
  89272. /**
  89273. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89274. */
  89275. _modelBoundingInfo: BoundingInfo;
  89276. /**
  89277. * @hidden Particle BoundingInfo object (Internal use)
  89278. */
  89279. _boundingInfo: BoundingInfo;
  89280. /**
  89281. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89282. */
  89283. _sps: SolidParticleSystem;
  89284. /**
  89285. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89286. */
  89287. _stillInvisible: boolean;
  89288. /**
  89289. * @hidden Last computed particle rotation matrix
  89290. */
  89291. _rotationMatrix: number[];
  89292. /**
  89293. * Parent particle Id, if any.
  89294. * Default null.
  89295. */
  89296. parentId: Nullable<number>;
  89297. /**
  89298. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89299. * The possible values are :
  89300. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89301. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89302. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89303. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89304. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89305. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89306. * */
  89307. cullingStrategy: number;
  89308. /**
  89309. * @hidden Internal global position in the SPS.
  89310. */
  89311. _globalPosition: Vector3;
  89312. /**
  89313. * Creates a Solid Particle object.
  89314. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89315. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89316. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89317. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89318. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89319. * @param shapeId (integer) is the model shape identifier in the SPS.
  89320. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89321. * @param sps defines the sps it is associated to
  89322. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89323. */
  89324. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89325. /**
  89326. * Legacy support, changed scale to scaling
  89327. */
  89328. /**
  89329. * Legacy support, changed scale to scaling
  89330. */
  89331. scale: Vector3;
  89332. /**
  89333. * Legacy support, changed quaternion to rotationQuaternion
  89334. */
  89335. /**
  89336. * Legacy support, changed quaternion to rotationQuaternion
  89337. */
  89338. quaternion: Nullable<Quaternion>;
  89339. /**
  89340. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89341. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89342. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89343. * @returns true if it intersects
  89344. */
  89345. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89346. /**
  89347. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89348. * A particle is in the frustum if its bounding box intersects the frustum
  89349. * @param frustumPlanes defines the frustum to test
  89350. * @returns true if the particle is in the frustum planes
  89351. */
  89352. isInFrustum(frustumPlanes: Plane[]): boolean;
  89353. /**
  89354. * get the rotation matrix of the particle
  89355. * @hidden
  89356. */
  89357. getRotationMatrix(m: Matrix): void;
  89358. }
  89359. /**
  89360. * Represents the shape of the model used by one particle of a solid particle system.
  89361. * SPS internal tool, don't use it manually.
  89362. */
  89363. export class ModelShape {
  89364. /**
  89365. * The shape id
  89366. * @hidden
  89367. */
  89368. shapeID: number;
  89369. /**
  89370. * flat array of model positions (internal use)
  89371. * @hidden
  89372. */
  89373. _shape: Vector3[];
  89374. /**
  89375. * flat array of model UVs (internal use)
  89376. * @hidden
  89377. */
  89378. _shapeUV: number[];
  89379. /**
  89380. * length of the shape in the model indices array (internal use)
  89381. * @hidden
  89382. */
  89383. _indicesLength: number;
  89384. /**
  89385. * Custom position function (internal use)
  89386. * @hidden
  89387. */
  89388. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89389. /**
  89390. * Custom vertex function (internal use)
  89391. * @hidden
  89392. */
  89393. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89394. /**
  89395. * 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.
  89396. * SPS internal tool, don't use it manually.
  89397. * @hidden
  89398. */
  89399. 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>);
  89400. }
  89401. /**
  89402. * Represents a Depth Sorted Particle in the solid particle system.
  89403. */
  89404. export class DepthSortedParticle {
  89405. /**
  89406. * Index of the particle in the "indices" array
  89407. */
  89408. ind: number;
  89409. /**
  89410. * Length of the particle shape in the "indices" array
  89411. */
  89412. indicesLength: number;
  89413. /**
  89414. * Squared distance from the particle to the camera
  89415. */
  89416. sqDistance: number;
  89417. }
  89418. }
  89419. declare module BABYLON {
  89420. /**
  89421. * @hidden
  89422. */
  89423. export class _MeshCollisionData {
  89424. _checkCollisions: boolean;
  89425. _collisionMask: number;
  89426. _collisionGroup: number;
  89427. _collider: Nullable<Collider>;
  89428. _oldPositionForCollisions: Vector3;
  89429. _diffPositionForCollisions: Vector3;
  89430. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89431. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89432. }
  89433. }
  89434. declare module BABYLON {
  89435. /** @hidden */
  89436. class _FacetDataStorage {
  89437. facetPositions: Vector3[];
  89438. facetNormals: Vector3[];
  89439. facetPartitioning: number[][];
  89440. facetNb: number;
  89441. partitioningSubdivisions: number;
  89442. partitioningBBoxRatio: number;
  89443. facetDataEnabled: boolean;
  89444. facetParameters: any;
  89445. bbSize: Vector3;
  89446. subDiv: {
  89447. max: number;
  89448. X: number;
  89449. Y: number;
  89450. Z: number;
  89451. };
  89452. facetDepthSort: boolean;
  89453. facetDepthSortEnabled: boolean;
  89454. depthSortedIndices: IndicesArray;
  89455. depthSortedFacets: {
  89456. ind: number;
  89457. sqDistance: number;
  89458. }[];
  89459. facetDepthSortFunction: (f1: {
  89460. ind: number;
  89461. sqDistance: number;
  89462. }, f2: {
  89463. ind: number;
  89464. sqDistance: number;
  89465. }) => number;
  89466. facetDepthSortFrom: Vector3;
  89467. facetDepthSortOrigin: Vector3;
  89468. invertedMatrix: Matrix;
  89469. }
  89470. /**
  89471. * @hidden
  89472. **/
  89473. class _InternalAbstractMeshDataInfo {
  89474. _hasVertexAlpha: boolean;
  89475. _useVertexColors: boolean;
  89476. _numBoneInfluencers: number;
  89477. _applyFog: boolean;
  89478. _receiveShadows: boolean;
  89479. _facetData: _FacetDataStorage;
  89480. _visibility: number;
  89481. _skeleton: Nullable<Skeleton>;
  89482. _layerMask: number;
  89483. _computeBonesUsingShaders: boolean;
  89484. _isActive: boolean;
  89485. _onlyForInstances: boolean;
  89486. _isActiveIntermediate: boolean;
  89487. _onlyForInstancesIntermediate: boolean;
  89488. }
  89489. /**
  89490. * Class used to store all common mesh properties
  89491. */
  89492. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89493. /** No occlusion */
  89494. static OCCLUSION_TYPE_NONE: number;
  89495. /** Occlusion set to optimisitic */
  89496. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89497. /** Occlusion set to strict */
  89498. static OCCLUSION_TYPE_STRICT: number;
  89499. /** Use an accurante occlusion algorithm */
  89500. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89501. /** Use a conservative occlusion algorithm */
  89502. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89503. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89504. * Test order :
  89505. * Is the bounding sphere outside the frustum ?
  89506. * If not, are the bounding box vertices outside the frustum ?
  89507. * It not, then the cullable object is in the frustum.
  89508. */
  89509. static readonly CULLINGSTRATEGY_STANDARD: number;
  89510. /** Culling strategy : Bounding Sphere Only.
  89511. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89512. * It's also less accurate than the standard because some not visible objects can still be selected.
  89513. * Test : is the bounding sphere outside the frustum ?
  89514. * If not, then the cullable object is in the frustum.
  89515. */
  89516. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89517. /** Culling strategy : Optimistic Inclusion.
  89518. * This in an inclusion test first, then the standard exclusion test.
  89519. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89520. * 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.
  89521. * Anyway, it's as accurate as the standard strategy.
  89522. * Test :
  89523. * Is the cullable object bounding sphere center in the frustum ?
  89524. * If not, apply the default culling strategy.
  89525. */
  89526. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89527. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89528. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89529. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89530. * 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.
  89531. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89532. * Test :
  89533. * Is the cullable object bounding sphere center in the frustum ?
  89534. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89535. */
  89536. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89537. /**
  89538. * No billboard
  89539. */
  89540. static readonly BILLBOARDMODE_NONE: number;
  89541. /** Billboard on X axis */
  89542. static readonly BILLBOARDMODE_X: number;
  89543. /** Billboard on Y axis */
  89544. static readonly BILLBOARDMODE_Y: number;
  89545. /** Billboard on Z axis */
  89546. static readonly BILLBOARDMODE_Z: number;
  89547. /** Billboard on all axes */
  89548. static readonly BILLBOARDMODE_ALL: number;
  89549. /** @hidden */
  89550. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89551. /**
  89552. * The culling strategy to use to check whether the mesh must be rendered or not.
  89553. * This value can be changed at any time and will be used on the next render mesh selection.
  89554. * The possible values are :
  89555. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89556. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89558. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89559. * Please read each static variable documentation to get details about the culling process.
  89560. * */
  89561. cullingStrategy: number;
  89562. /**
  89563. * Gets the number of facets in the mesh
  89564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89565. */
  89566. readonly facetNb: number;
  89567. /**
  89568. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89570. */
  89571. partitioningSubdivisions: number;
  89572. /**
  89573. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89574. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89576. */
  89577. partitioningBBoxRatio: number;
  89578. /**
  89579. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89580. * Works only for updatable meshes.
  89581. * Doesn't work with multi-materials
  89582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89583. */
  89584. mustDepthSortFacets: boolean;
  89585. /**
  89586. * The location (Vector3) where the facet depth sort must be computed from.
  89587. * By default, the active camera position.
  89588. * Used only when facet depth sort is enabled
  89589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89590. */
  89591. facetDepthSortFrom: Vector3;
  89592. /**
  89593. * gets a boolean indicating if facetData is enabled
  89594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89595. */
  89596. readonly isFacetDataEnabled: boolean;
  89597. /** @hidden */
  89598. _updateNonUniformScalingState(value: boolean): boolean;
  89599. /**
  89600. * An event triggered when this mesh collides with another one
  89601. */
  89602. onCollideObservable: Observable<AbstractMesh>;
  89603. /** Set a function to call when this mesh collides with another one */
  89604. onCollide: () => void;
  89605. /**
  89606. * An event triggered when the collision's position changes
  89607. */
  89608. onCollisionPositionChangeObservable: Observable<Vector3>;
  89609. /** Set a function to call when the collision's position changes */
  89610. onCollisionPositionChange: () => void;
  89611. /**
  89612. * An event triggered when material is changed
  89613. */
  89614. onMaterialChangedObservable: Observable<AbstractMesh>;
  89615. /**
  89616. * Gets or sets the orientation for POV movement & rotation
  89617. */
  89618. definedFacingForward: boolean;
  89619. /** @hidden */
  89620. _occlusionQuery: Nullable<WebGLQuery>;
  89621. /** @hidden */
  89622. _renderingGroup: Nullable<RenderingGroup>;
  89623. /**
  89624. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89625. */
  89626. /**
  89627. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89628. */
  89629. visibility: number;
  89630. /** Gets or sets the alpha index used to sort transparent meshes
  89631. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89632. */
  89633. alphaIndex: number;
  89634. /**
  89635. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89636. */
  89637. isVisible: boolean;
  89638. /**
  89639. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89640. */
  89641. isPickable: boolean;
  89642. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89643. showSubMeshesBoundingBox: boolean;
  89644. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89646. */
  89647. isBlocker: boolean;
  89648. /**
  89649. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89650. */
  89651. enablePointerMoveEvents: boolean;
  89652. /**
  89653. * Specifies the rendering group id for this mesh (0 by default)
  89654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89655. */
  89656. renderingGroupId: number;
  89657. private _material;
  89658. /** Gets or sets current material */
  89659. material: Nullable<Material>;
  89660. /**
  89661. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89662. * @see http://doc.babylonjs.com/babylon101/shadows
  89663. */
  89664. receiveShadows: boolean;
  89665. /** Defines color to use when rendering outline */
  89666. outlineColor: Color3;
  89667. /** Define width to use when rendering outline */
  89668. outlineWidth: number;
  89669. /** Defines color to use when rendering overlay */
  89670. overlayColor: Color3;
  89671. /** Defines alpha to use when rendering overlay */
  89672. overlayAlpha: number;
  89673. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89674. hasVertexAlpha: boolean;
  89675. /** 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) */
  89676. useVertexColors: boolean;
  89677. /**
  89678. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89679. */
  89680. computeBonesUsingShaders: boolean;
  89681. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89682. numBoneInfluencers: number;
  89683. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89684. applyFog: boolean;
  89685. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89686. useOctreeForRenderingSelection: boolean;
  89687. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89688. useOctreeForPicking: boolean;
  89689. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89690. useOctreeForCollisions: boolean;
  89691. /**
  89692. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89693. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89694. */
  89695. layerMask: number;
  89696. /**
  89697. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89698. */
  89699. alwaysSelectAsActiveMesh: boolean;
  89700. /**
  89701. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89702. */
  89703. doNotSyncBoundingInfo: boolean;
  89704. /**
  89705. * Gets or sets the current action manager
  89706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89707. */
  89708. actionManager: Nullable<AbstractActionManager>;
  89709. private _meshCollisionData;
  89710. /**
  89711. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89713. */
  89714. ellipsoid: Vector3;
  89715. /**
  89716. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89718. */
  89719. ellipsoidOffset: Vector3;
  89720. /**
  89721. * Gets or sets a collision mask used to mask collisions (default is -1).
  89722. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89723. */
  89724. collisionMask: number;
  89725. /**
  89726. * Gets or sets the current collision group mask (-1 by default).
  89727. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89728. */
  89729. collisionGroup: number;
  89730. /**
  89731. * Defines edge width used when edgesRenderer is enabled
  89732. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89733. */
  89734. edgesWidth: number;
  89735. /**
  89736. * Defines edge color used when edgesRenderer is enabled
  89737. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89738. */
  89739. edgesColor: Color4;
  89740. /** @hidden */
  89741. _edgesRenderer: Nullable<IEdgesRenderer>;
  89742. /** @hidden */
  89743. _masterMesh: Nullable<AbstractMesh>;
  89744. /** @hidden */
  89745. _boundingInfo: Nullable<BoundingInfo>;
  89746. /** @hidden */
  89747. _renderId: number;
  89748. /**
  89749. * Gets or sets the list of subMeshes
  89750. * @see http://doc.babylonjs.com/how_to/multi_materials
  89751. */
  89752. subMeshes: SubMesh[];
  89753. /** @hidden */
  89754. _intersectionsInProgress: AbstractMesh[];
  89755. /** @hidden */
  89756. _unIndexed: boolean;
  89757. /** @hidden */
  89758. _lightSources: Light[];
  89759. /** Gets the list of lights affecting that mesh */
  89760. readonly lightSources: Light[];
  89761. /** @hidden */
  89762. readonly _positions: Nullable<Vector3[]>;
  89763. /** @hidden */
  89764. _waitingData: {
  89765. lods: Nullable<any>;
  89766. actions: Nullable<any>;
  89767. freezeWorldMatrix: Nullable<boolean>;
  89768. };
  89769. /** @hidden */
  89770. _bonesTransformMatrices: Nullable<Float32Array>;
  89771. /** @hidden */
  89772. _transformMatrixTexture: Nullable<RawTexture>;
  89773. /**
  89774. * Gets or sets a skeleton to apply skining transformations
  89775. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89776. */
  89777. skeleton: Nullable<Skeleton>;
  89778. /**
  89779. * An event triggered when the mesh is rebuilt.
  89780. */
  89781. onRebuildObservable: Observable<AbstractMesh>;
  89782. /**
  89783. * Creates a new AbstractMesh
  89784. * @param name defines the name of the mesh
  89785. * @param scene defines the hosting scene
  89786. */
  89787. constructor(name: string, scene?: Nullable<Scene>);
  89788. /**
  89789. * Returns the string "AbstractMesh"
  89790. * @returns "AbstractMesh"
  89791. */
  89792. getClassName(): string;
  89793. /**
  89794. * Gets a string representation of the current mesh
  89795. * @param fullDetails defines a boolean indicating if full details must be included
  89796. * @returns a string representation of the current mesh
  89797. */
  89798. toString(fullDetails?: boolean): string;
  89799. /**
  89800. * @hidden
  89801. */
  89802. protected _getEffectiveParent(): Nullable<Node>;
  89803. /** @hidden */
  89804. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89805. /** @hidden */
  89806. _rebuild(): void;
  89807. /** @hidden */
  89808. _resyncLightSources(): void;
  89809. /** @hidden */
  89810. _resyncLighSource(light: Light): void;
  89811. /** @hidden */
  89812. _unBindEffect(): void;
  89813. /** @hidden */
  89814. _removeLightSource(light: Light): void;
  89815. private _markSubMeshesAsDirty;
  89816. /** @hidden */
  89817. _markSubMeshesAsLightDirty(): void;
  89818. /** @hidden */
  89819. _markSubMeshesAsAttributesDirty(): void;
  89820. /** @hidden */
  89821. _markSubMeshesAsMiscDirty(): void;
  89822. /**
  89823. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89824. */
  89825. scaling: Vector3;
  89826. /**
  89827. * Returns true if the mesh is blocked. Implemented by child classes
  89828. */
  89829. readonly isBlocked: boolean;
  89830. /**
  89831. * Returns the mesh itself by default. Implemented by child classes
  89832. * @param camera defines the camera to use to pick the right LOD level
  89833. * @returns the currentAbstractMesh
  89834. */
  89835. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89836. /**
  89837. * Returns 0 by default. Implemented by child classes
  89838. * @returns an integer
  89839. */
  89840. getTotalVertices(): number;
  89841. /**
  89842. * Returns a positive integer : the total number of indices in this mesh geometry.
  89843. * @returns the numner of indices or zero if the mesh has no geometry.
  89844. */
  89845. getTotalIndices(): number;
  89846. /**
  89847. * Returns null by default. Implemented by child classes
  89848. * @returns null
  89849. */
  89850. getIndices(): Nullable<IndicesArray>;
  89851. /**
  89852. * Returns the array of the requested vertex data kind. Implemented by child classes
  89853. * @param kind defines the vertex data kind to use
  89854. * @returns null
  89855. */
  89856. getVerticesData(kind: string): Nullable<FloatArray>;
  89857. /**
  89858. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89859. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89860. * Note that a new underlying VertexBuffer object is created each call.
  89861. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89862. * @param kind defines vertex data kind:
  89863. * * VertexBuffer.PositionKind
  89864. * * VertexBuffer.UVKind
  89865. * * VertexBuffer.UV2Kind
  89866. * * VertexBuffer.UV3Kind
  89867. * * VertexBuffer.UV4Kind
  89868. * * VertexBuffer.UV5Kind
  89869. * * VertexBuffer.UV6Kind
  89870. * * VertexBuffer.ColorKind
  89871. * * VertexBuffer.MatricesIndicesKind
  89872. * * VertexBuffer.MatricesIndicesExtraKind
  89873. * * VertexBuffer.MatricesWeightsKind
  89874. * * VertexBuffer.MatricesWeightsExtraKind
  89875. * @param data defines the data source
  89876. * @param updatable defines if the data must be flagged as updatable (or static)
  89877. * @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
  89878. * @returns the current mesh
  89879. */
  89880. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89881. /**
  89882. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89883. * If the mesh has no geometry, it is simply returned as it is.
  89884. * @param kind defines vertex data kind:
  89885. * * VertexBuffer.PositionKind
  89886. * * VertexBuffer.UVKind
  89887. * * VertexBuffer.UV2Kind
  89888. * * VertexBuffer.UV3Kind
  89889. * * VertexBuffer.UV4Kind
  89890. * * VertexBuffer.UV5Kind
  89891. * * VertexBuffer.UV6Kind
  89892. * * VertexBuffer.ColorKind
  89893. * * VertexBuffer.MatricesIndicesKind
  89894. * * VertexBuffer.MatricesIndicesExtraKind
  89895. * * VertexBuffer.MatricesWeightsKind
  89896. * * VertexBuffer.MatricesWeightsExtraKind
  89897. * @param data defines the data source
  89898. * @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
  89899. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89900. * @returns the current mesh
  89901. */
  89902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89903. /**
  89904. * Sets the mesh indices,
  89905. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89906. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89907. * @param totalVertices Defines the total number of vertices
  89908. * @returns the current mesh
  89909. */
  89910. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89911. /**
  89912. * Gets a boolean indicating if specific vertex data is present
  89913. * @param kind defines the vertex data kind to use
  89914. * @returns true is data kind is present
  89915. */
  89916. isVerticesDataPresent(kind: string): boolean;
  89917. /**
  89918. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89919. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89920. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89921. * @returns a BoundingInfo
  89922. */
  89923. getBoundingInfo(): BoundingInfo;
  89924. /**
  89925. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89926. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89927. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89928. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89929. * @returns the current mesh
  89930. */
  89931. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89932. /**
  89933. * Overwrite the current bounding info
  89934. * @param boundingInfo defines the new bounding info
  89935. * @returns the current mesh
  89936. */
  89937. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89938. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89939. readonly useBones: boolean;
  89940. /** @hidden */
  89941. _preActivate(): void;
  89942. /** @hidden */
  89943. _preActivateForIntermediateRendering(renderId: number): void;
  89944. /** @hidden */
  89945. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89946. /** @hidden */
  89947. _postActivate(): void;
  89948. /** @hidden */
  89949. _freeze(): void;
  89950. /** @hidden */
  89951. _unFreeze(): void;
  89952. /**
  89953. * Gets the current world matrix
  89954. * @returns a Matrix
  89955. */
  89956. getWorldMatrix(): Matrix;
  89957. /** @hidden */
  89958. _getWorldMatrixDeterminant(): number;
  89959. /**
  89960. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89961. */
  89962. readonly isAnInstance: boolean;
  89963. /**
  89964. * Perform relative position change from the point of view of behind the front of the mesh.
  89965. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89966. * Supports definition of mesh facing forward or backward
  89967. * @param amountRight defines the distance on the right axis
  89968. * @param amountUp defines the distance on the up axis
  89969. * @param amountForward defines the distance on the forward axis
  89970. * @returns the current mesh
  89971. */
  89972. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89973. /**
  89974. * Calculate relative position change from the point of view of behind the front of the mesh.
  89975. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89976. * Supports definition of mesh facing forward or backward
  89977. * @param amountRight defines the distance on the right axis
  89978. * @param amountUp defines the distance on the up axis
  89979. * @param amountForward defines the distance on the forward axis
  89980. * @returns the new displacement vector
  89981. */
  89982. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89983. /**
  89984. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89985. * Supports definition of mesh facing forward or backward
  89986. * @param flipBack defines the flip
  89987. * @param twirlClockwise defines the twirl
  89988. * @param tiltRight defines the tilt
  89989. * @returns the current mesh
  89990. */
  89991. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89992. /**
  89993. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89994. * Supports definition of mesh facing forward or backward.
  89995. * @param flipBack defines the flip
  89996. * @param twirlClockwise defines the twirl
  89997. * @param tiltRight defines the tilt
  89998. * @returns the new rotation vector
  89999. */
  90000. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90001. /**
  90002. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90003. * This means the mesh underlying bounding box and sphere are recomputed.
  90004. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90005. * @returns the current mesh
  90006. */
  90007. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90008. /** @hidden */
  90009. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90010. /** @hidden */
  90011. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90012. /** @hidden */
  90013. _updateBoundingInfo(): AbstractMesh;
  90014. /** @hidden */
  90015. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90016. /** @hidden */
  90017. protected _afterComputeWorldMatrix(): void;
  90018. /** @hidden */
  90019. readonly _effectiveMesh: AbstractMesh;
  90020. /**
  90021. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90022. * A mesh is in the frustum if its bounding box intersects the frustum
  90023. * @param frustumPlanes defines the frustum to test
  90024. * @returns true if the mesh is in the frustum planes
  90025. */
  90026. isInFrustum(frustumPlanes: Plane[]): boolean;
  90027. /**
  90028. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90029. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90030. * @param frustumPlanes defines the frustum to test
  90031. * @returns true if the mesh is completely in the frustum planes
  90032. */
  90033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90034. /**
  90035. * True if the mesh intersects another mesh or a SolidParticle object
  90036. * @param mesh defines a target mesh or SolidParticle to test
  90037. * @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)
  90038. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90039. * @returns true if there is an intersection
  90040. */
  90041. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90042. /**
  90043. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90044. * @param point defines the point to test
  90045. * @returns true if there is an intersection
  90046. */
  90047. intersectsPoint(point: Vector3): boolean;
  90048. /**
  90049. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90050. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90051. */
  90052. checkCollisions: boolean;
  90053. /**
  90054. * Gets Collider object used to compute collisions (not physics)
  90055. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90056. */
  90057. readonly collider: Nullable<Collider>;
  90058. /**
  90059. * Move the mesh using collision engine
  90060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90061. * @param displacement defines the requested displacement vector
  90062. * @returns the current mesh
  90063. */
  90064. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90065. private _onCollisionPositionChange;
  90066. /** @hidden */
  90067. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90068. /** @hidden */
  90069. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90070. /** @hidden */
  90071. _checkCollision(collider: Collider): AbstractMesh;
  90072. /** @hidden */
  90073. _generatePointsArray(): boolean;
  90074. /**
  90075. * Checks if the passed Ray intersects with the mesh
  90076. * @param ray defines the ray to use
  90077. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90078. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90079. * @returns the picking info
  90080. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90081. */
  90082. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90083. /**
  90084. * Clones the current mesh
  90085. * @param name defines the mesh name
  90086. * @param newParent defines the new mesh parent
  90087. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90088. * @returns the new mesh
  90089. */
  90090. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90091. /**
  90092. * Disposes all the submeshes of the current meshnp
  90093. * @returns the current mesh
  90094. */
  90095. releaseSubMeshes(): AbstractMesh;
  90096. /**
  90097. * Releases resources associated with this abstract mesh.
  90098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90100. */
  90101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90102. /**
  90103. * Adds the passed mesh as a child to the current mesh
  90104. * @param mesh defines the child mesh
  90105. * @returns the current mesh
  90106. */
  90107. addChild(mesh: AbstractMesh): AbstractMesh;
  90108. /**
  90109. * Removes the passed mesh from the current mesh children list
  90110. * @param mesh defines the child mesh
  90111. * @returns the current mesh
  90112. */
  90113. removeChild(mesh: AbstractMesh): AbstractMesh;
  90114. /** @hidden */
  90115. private _initFacetData;
  90116. /**
  90117. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90118. * This method can be called within the render loop.
  90119. * 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
  90120. * @returns the current mesh
  90121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90122. */
  90123. updateFacetData(): AbstractMesh;
  90124. /**
  90125. * Returns the facetLocalNormals array.
  90126. * The normals are expressed in the mesh local spac
  90127. * @returns an array of Vector3
  90128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90129. */
  90130. getFacetLocalNormals(): Vector3[];
  90131. /**
  90132. * Returns the facetLocalPositions array.
  90133. * The facet positions are expressed in the mesh local space
  90134. * @returns an array of Vector3
  90135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90136. */
  90137. getFacetLocalPositions(): Vector3[];
  90138. /**
  90139. * Returns the facetLocalPartioning array
  90140. * @returns an array of array of numbers
  90141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90142. */
  90143. getFacetLocalPartitioning(): number[][];
  90144. /**
  90145. * Returns the i-th facet position in the world system.
  90146. * This method allocates a new Vector3 per call
  90147. * @param i defines the facet index
  90148. * @returns a new Vector3
  90149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90150. */
  90151. getFacetPosition(i: number): Vector3;
  90152. /**
  90153. * Sets the reference Vector3 with the i-th facet position in the world system
  90154. * @param i defines the facet index
  90155. * @param ref defines the target vector
  90156. * @returns the current mesh
  90157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90158. */
  90159. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90160. /**
  90161. * Returns the i-th facet normal in the world system.
  90162. * This method allocates a new Vector3 per call
  90163. * @param i defines the facet index
  90164. * @returns a new Vector3
  90165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90166. */
  90167. getFacetNormal(i: number): Vector3;
  90168. /**
  90169. * Sets the reference Vector3 with the i-th facet normal in the world system
  90170. * @param i defines the facet index
  90171. * @param ref defines the target vector
  90172. * @returns the current mesh
  90173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90174. */
  90175. getFacetNormalToRef(i: number, ref: Vector3): this;
  90176. /**
  90177. * 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)
  90178. * @param x defines x coordinate
  90179. * @param y defines y coordinate
  90180. * @param z defines z coordinate
  90181. * @returns the array of facet indexes
  90182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90183. */
  90184. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90185. /**
  90186. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90187. * @param projected sets as the (x,y,z) world projection on the facet
  90188. * @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
  90189. * @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
  90190. * @param x defines x coordinate
  90191. * @param y defines y coordinate
  90192. * @param z defines z coordinate
  90193. * @returns the face index if found (or null instead)
  90194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90195. */
  90196. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90197. /**
  90198. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90199. * @param projected sets as the (x,y,z) local projection on the facet
  90200. * @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
  90201. * @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
  90202. * @param x defines x coordinate
  90203. * @param y defines y coordinate
  90204. * @param z defines z coordinate
  90205. * @returns the face index if found (or null instead)
  90206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90207. */
  90208. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90209. /**
  90210. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90211. * @returns the parameters
  90212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90213. */
  90214. getFacetDataParameters(): any;
  90215. /**
  90216. * Disables the feature FacetData and frees the related memory
  90217. * @returns the current mesh
  90218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90219. */
  90220. disableFacetData(): AbstractMesh;
  90221. /**
  90222. * Updates the AbstractMesh indices array
  90223. * @param indices defines the data source
  90224. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90225. * @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)
  90226. * @returns the current mesh
  90227. */
  90228. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90229. /**
  90230. * Creates new normals data for the mesh
  90231. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90232. * @returns the current mesh
  90233. */
  90234. createNormals(updatable: boolean): AbstractMesh;
  90235. /**
  90236. * Align the mesh with a normal
  90237. * @param normal defines the normal to use
  90238. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90239. * @returns the current mesh
  90240. */
  90241. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90242. /** @hidden */
  90243. _checkOcclusionQuery(): boolean;
  90244. /**
  90245. * Disables the mesh edge rendering mode
  90246. * @returns the currentAbstractMesh
  90247. */
  90248. disableEdgesRendering(): AbstractMesh;
  90249. /**
  90250. * Enables the edge rendering mode on the mesh.
  90251. * This mode makes the mesh edges visible
  90252. * @param epsilon defines the maximal distance between two angles to detect a face
  90253. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90254. * @returns the currentAbstractMesh
  90255. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90256. */
  90257. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90258. }
  90259. }
  90260. declare module BABYLON {
  90261. /**
  90262. * Interface used to define ActionEvent
  90263. */
  90264. export interface IActionEvent {
  90265. /** The mesh or sprite that triggered the action */
  90266. source: any;
  90267. /** The X mouse cursor position at the time of the event */
  90268. pointerX: number;
  90269. /** The Y mouse cursor position at the time of the event */
  90270. pointerY: number;
  90271. /** The mesh that is currently pointed at (can be null) */
  90272. meshUnderPointer: Nullable<AbstractMesh>;
  90273. /** the original (browser) event that triggered the ActionEvent */
  90274. sourceEvent?: any;
  90275. /** additional data for the event */
  90276. additionalData?: any;
  90277. }
  90278. /**
  90279. * ActionEvent is the event being sent when an action is triggered.
  90280. */
  90281. export class ActionEvent implements IActionEvent {
  90282. /** The mesh or sprite that triggered the action */
  90283. source: any;
  90284. /** The X mouse cursor position at the time of the event */
  90285. pointerX: number;
  90286. /** The Y mouse cursor position at the time of the event */
  90287. pointerY: number;
  90288. /** The mesh that is currently pointed at (can be null) */
  90289. meshUnderPointer: Nullable<AbstractMesh>;
  90290. /** the original (browser) event that triggered the ActionEvent */
  90291. sourceEvent?: any;
  90292. /** additional data for the event */
  90293. additionalData?: any;
  90294. /**
  90295. * Creates a new ActionEvent
  90296. * @param source The mesh or sprite that triggered the action
  90297. * @param pointerX The X mouse cursor position at the time of the event
  90298. * @param pointerY The Y mouse cursor position at the time of the event
  90299. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90300. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90301. * @param additionalData additional data for the event
  90302. */
  90303. constructor(
  90304. /** The mesh or sprite that triggered the action */
  90305. source: any,
  90306. /** The X mouse cursor position at the time of the event */
  90307. pointerX: number,
  90308. /** The Y mouse cursor position at the time of the event */
  90309. pointerY: number,
  90310. /** The mesh that is currently pointed at (can be null) */
  90311. meshUnderPointer: Nullable<AbstractMesh>,
  90312. /** the original (browser) event that triggered the ActionEvent */
  90313. sourceEvent?: any,
  90314. /** additional data for the event */
  90315. additionalData?: any);
  90316. /**
  90317. * Helper function to auto-create an ActionEvent from a source mesh.
  90318. * @param source The source mesh that triggered the event
  90319. * @param evt The original (browser) event
  90320. * @param additionalData additional data for the event
  90321. * @returns the new ActionEvent
  90322. */
  90323. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90324. /**
  90325. * Helper function to auto-create an ActionEvent from a source sprite
  90326. * @param source The source sprite that triggered the event
  90327. * @param scene Scene associated with the sprite
  90328. * @param evt The original (browser) event
  90329. * @param additionalData additional data for the event
  90330. * @returns the new ActionEvent
  90331. */
  90332. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90333. /**
  90334. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90335. * @param scene the scene where the event occurred
  90336. * @param evt The original (browser) event
  90337. * @returns the new ActionEvent
  90338. */
  90339. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90340. /**
  90341. * Helper function to auto-create an ActionEvent from a primitive
  90342. * @param prim defines the target primitive
  90343. * @param pointerPos defines the pointer position
  90344. * @param evt The original (browser) event
  90345. * @param additionalData additional data for the event
  90346. * @returns the new ActionEvent
  90347. */
  90348. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90349. }
  90350. }
  90351. declare module BABYLON {
  90352. /**
  90353. * Abstract class used to decouple action Manager from scene and meshes.
  90354. * Do not instantiate.
  90355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90356. */
  90357. export abstract class AbstractActionManager implements IDisposable {
  90358. /** Gets the list of active triggers */
  90359. static Triggers: {
  90360. [key: string]: number;
  90361. };
  90362. /** Gets the cursor to use when hovering items */
  90363. hoverCursor: string;
  90364. /** Gets the list of actions */
  90365. actions: IAction[];
  90366. /**
  90367. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90368. */
  90369. isRecursive: boolean;
  90370. /**
  90371. * Releases all associated resources
  90372. */
  90373. abstract dispose(): void;
  90374. /**
  90375. * Does this action manager has pointer triggers
  90376. */
  90377. abstract readonly hasPointerTriggers: boolean;
  90378. /**
  90379. * Does this action manager has pick triggers
  90380. */
  90381. abstract readonly hasPickTriggers: boolean;
  90382. /**
  90383. * Process a specific trigger
  90384. * @param trigger defines the trigger to process
  90385. * @param evt defines the event details to be processed
  90386. */
  90387. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90388. /**
  90389. * Does this action manager handles actions of any of the given triggers
  90390. * @param triggers defines the triggers to be tested
  90391. * @return a boolean indicating whether one (or more) of the triggers is handled
  90392. */
  90393. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90394. /**
  90395. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90396. * speed.
  90397. * @param triggerA defines the trigger to be tested
  90398. * @param triggerB defines the trigger to be tested
  90399. * @return a boolean indicating whether one (or more) of the triggers is handled
  90400. */
  90401. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90402. /**
  90403. * Does this action manager handles actions of a given trigger
  90404. * @param trigger defines the trigger to be tested
  90405. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90406. * @return whether the trigger is handled
  90407. */
  90408. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90409. /**
  90410. * Serialize this manager to a JSON object
  90411. * @param name defines the property name to store this manager
  90412. * @returns a JSON representation of this manager
  90413. */
  90414. abstract serialize(name: string): any;
  90415. /**
  90416. * Registers an action to this action manager
  90417. * @param action defines the action to be registered
  90418. * @return the action amended (prepared) after registration
  90419. */
  90420. abstract registerAction(action: IAction): Nullable<IAction>;
  90421. /**
  90422. * Unregisters an action to this action manager
  90423. * @param action defines the action to be unregistered
  90424. * @return a boolean indicating whether the action has been unregistered
  90425. */
  90426. abstract unregisterAction(action: IAction): Boolean;
  90427. /**
  90428. * Does exist one action manager with at least one trigger
  90429. **/
  90430. static readonly HasTriggers: boolean;
  90431. /**
  90432. * Does exist one action manager with at least one pick trigger
  90433. **/
  90434. static readonly HasPickTriggers: boolean;
  90435. /**
  90436. * Does exist one action manager that handles actions of a given trigger
  90437. * @param trigger defines the trigger to be tested
  90438. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90439. **/
  90440. static HasSpecificTrigger(trigger: number): boolean;
  90441. }
  90442. }
  90443. declare module BABYLON {
  90444. /**
  90445. * Defines how a node can be built from a string name.
  90446. */
  90447. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90448. /**
  90449. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90450. */
  90451. export class Node implements IBehaviorAware<Node> {
  90452. /** @hidden */
  90453. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90454. private static _NodeConstructors;
  90455. /**
  90456. * Add a new node constructor
  90457. * @param type defines the type name of the node to construct
  90458. * @param constructorFunc defines the constructor function
  90459. */
  90460. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90461. /**
  90462. * Returns a node constructor based on type name
  90463. * @param type defines the type name
  90464. * @param name defines the new node name
  90465. * @param scene defines the hosting scene
  90466. * @param options defines optional options to transmit to constructors
  90467. * @returns the new constructor or null
  90468. */
  90469. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90470. /**
  90471. * Gets or sets the name of the node
  90472. */
  90473. name: string;
  90474. /**
  90475. * Gets or sets the id of the node
  90476. */
  90477. id: string;
  90478. /**
  90479. * Gets or sets the unique id of the node
  90480. */
  90481. uniqueId: number;
  90482. /**
  90483. * Gets or sets a string used to store user defined state for the node
  90484. */
  90485. state: string;
  90486. /**
  90487. * Gets or sets an object used to store user defined information for the node
  90488. */
  90489. metadata: any;
  90490. /**
  90491. * For internal use only. Please do not use.
  90492. */
  90493. reservedDataStore: any;
  90494. /**
  90495. * List of inspectable custom properties (used by the Inspector)
  90496. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90497. */
  90498. inspectableCustomProperties: IInspectable[];
  90499. /**
  90500. * Gets or sets a boolean used to define if the node must be serialized
  90501. */
  90502. doNotSerialize: boolean;
  90503. /** @hidden */
  90504. _isDisposed: boolean;
  90505. /**
  90506. * Gets a list of Animations associated with the node
  90507. */
  90508. animations: Animation[];
  90509. protected _ranges: {
  90510. [name: string]: Nullable<AnimationRange>;
  90511. };
  90512. /**
  90513. * Callback raised when the node is ready to be used
  90514. */
  90515. onReady: Nullable<(node: Node) => void>;
  90516. private _isEnabled;
  90517. private _isParentEnabled;
  90518. private _isReady;
  90519. /** @hidden */
  90520. _currentRenderId: number;
  90521. private _parentUpdateId;
  90522. /** @hidden */
  90523. _childUpdateId: number;
  90524. /** @hidden */
  90525. _waitingParentId: Nullable<string>;
  90526. /** @hidden */
  90527. _scene: Scene;
  90528. /** @hidden */
  90529. _cache: any;
  90530. private _parentNode;
  90531. private _children;
  90532. /** @hidden */
  90533. _worldMatrix: Matrix;
  90534. /** @hidden */
  90535. _worldMatrixDeterminant: number;
  90536. /** @hidden */
  90537. _worldMatrixDeterminantIsDirty: boolean;
  90538. /** @hidden */
  90539. private _sceneRootNodesIndex;
  90540. /**
  90541. * Gets a boolean indicating if the node has been disposed
  90542. * @returns true if the node was disposed
  90543. */
  90544. isDisposed(): boolean;
  90545. /**
  90546. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90547. * @see https://doc.babylonjs.com/how_to/parenting
  90548. */
  90549. parent: Nullable<Node>;
  90550. private addToSceneRootNodes;
  90551. private removeFromSceneRootNodes;
  90552. private _animationPropertiesOverride;
  90553. /**
  90554. * Gets or sets the animation properties override
  90555. */
  90556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90557. /**
  90558. * Gets a string idenfifying the name of the class
  90559. * @returns "Node" string
  90560. */
  90561. getClassName(): string;
  90562. /** @hidden */
  90563. readonly _isNode: boolean;
  90564. /**
  90565. * An event triggered when the mesh is disposed
  90566. */
  90567. onDisposeObservable: Observable<Node>;
  90568. private _onDisposeObserver;
  90569. /**
  90570. * Sets a callback that will be raised when the node will be disposed
  90571. */
  90572. onDispose: () => void;
  90573. /**
  90574. * Creates a new Node
  90575. * @param name the name and id to be given to this node
  90576. * @param scene the scene this node will be added to
  90577. * @param addToRootNodes the node will be added to scene.rootNodes
  90578. */
  90579. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90580. /**
  90581. * Gets the scene of the node
  90582. * @returns a scene
  90583. */
  90584. getScene(): Scene;
  90585. /**
  90586. * Gets the engine of the node
  90587. * @returns a Engine
  90588. */
  90589. getEngine(): Engine;
  90590. private _behaviors;
  90591. /**
  90592. * Attach a behavior to the node
  90593. * @see http://doc.babylonjs.com/features/behaviour
  90594. * @param behavior defines the behavior to attach
  90595. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90596. * @returns the current Node
  90597. */
  90598. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90599. /**
  90600. * Remove an attached behavior
  90601. * @see http://doc.babylonjs.com/features/behaviour
  90602. * @param behavior defines the behavior to attach
  90603. * @returns the current Node
  90604. */
  90605. removeBehavior(behavior: Behavior<Node>): Node;
  90606. /**
  90607. * Gets the list of attached behaviors
  90608. * @see http://doc.babylonjs.com/features/behaviour
  90609. */
  90610. readonly behaviors: Behavior<Node>[];
  90611. /**
  90612. * Gets an attached behavior by name
  90613. * @param name defines the name of the behavior to look for
  90614. * @see http://doc.babylonjs.com/features/behaviour
  90615. * @returns null if behavior was not found else the requested behavior
  90616. */
  90617. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90618. /**
  90619. * Returns the latest update of the World matrix
  90620. * @returns a Matrix
  90621. */
  90622. getWorldMatrix(): Matrix;
  90623. /** @hidden */
  90624. _getWorldMatrixDeterminant(): number;
  90625. /**
  90626. * Returns directly the latest state of the mesh World matrix.
  90627. * A Matrix is returned.
  90628. */
  90629. readonly worldMatrixFromCache: Matrix;
  90630. /** @hidden */
  90631. _initCache(): void;
  90632. /** @hidden */
  90633. updateCache(force?: boolean): void;
  90634. /** @hidden */
  90635. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90636. /** @hidden */
  90637. _updateCache(ignoreParentClass?: boolean): void;
  90638. /** @hidden */
  90639. _isSynchronized(): boolean;
  90640. /** @hidden */
  90641. _markSyncedWithParent(): void;
  90642. /** @hidden */
  90643. isSynchronizedWithParent(): boolean;
  90644. /** @hidden */
  90645. isSynchronized(): boolean;
  90646. /**
  90647. * Is this node ready to be used/rendered
  90648. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90649. * @return true if the node is ready
  90650. */
  90651. isReady(completeCheck?: boolean): boolean;
  90652. /**
  90653. * Is this node enabled?
  90654. * 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
  90655. * @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
  90656. * @return whether this node (and its parent) is enabled
  90657. */
  90658. isEnabled(checkAncestors?: boolean): boolean;
  90659. /** @hidden */
  90660. protected _syncParentEnabledState(): void;
  90661. /**
  90662. * Set the enabled state of this node
  90663. * @param value defines the new enabled state
  90664. */
  90665. setEnabled(value: boolean): void;
  90666. /**
  90667. * Is this node a descendant of the given node?
  90668. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90669. * @param ancestor defines the parent node to inspect
  90670. * @returns a boolean indicating if this node is a descendant of the given node
  90671. */
  90672. isDescendantOf(ancestor: Node): boolean;
  90673. /** @hidden */
  90674. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90675. /**
  90676. * Will return all nodes that have this node as ascendant
  90677. * @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
  90678. * @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
  90679. * @return all children nodes of all types
  90680. */
  90681. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90682. /**
  90683. * Get all child-meshes of this node
  90684. * @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)
  90685. * @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
  90686. * @returns an array of AbstractMesh
  90687. */
  90688. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90689. /**
  90690. * Get all direct children of this node
  90691. * @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
  90692. * @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)
  90693. * @returns an array of Node
  90694. */
  90695. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90696. /** @hidden */
  90697. _setReady(state: boolean): void;
  90698. /**
  90699. * Get an animation by name
  90700. * @param name defines the name of the animation to look for
  90701. * @returns null if not found else the requested animation
  90702. */
  90703. getAnimationByName(name: string): Nullable<Animation>;
  90704. /**
  90705. * Creates an animation range for this node
  90706. * @param name defines the name of the range
  90707. * @param from defines the starting key
  90708. * @param to defines the end key
  90709. */
  90710. createAnimationRange(name: string, from: number, to: number): void;
  90711. /**
  90712. * Delete a specific animation range
  90713. * @param name defines the name of the range to delete
  90714. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90715. */
  90716. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90717. /**
  90718. * Get an animation range by name
  90719. * @param name defines the name of the animation range to look for
  90720. * @returns null if not found else the requested animation range
  90721. */
  90722. getAnimationRange(name: string): Nullable<AnimationRange>;
  90723. /**
  90724. * Gets the list of all animation ranges defined on this node
  90725. * @returns an array
  90726. */
  90727. getAnimationRanges(): Nullable<AnimationRange>[];
  90728. /**
  90729. * Will start the animation sequence
  90730. * @param name defines the range frames for animation sequence
  90731. * @param loop defines if the animation should loop (false by default)
  90732. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90733. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90734. * @returns the object created for this animation. If range does not exist, it will return null
  90735. */
  90736. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90737. /**
  90738. * Serialize animation ranges into a JSON compatible object
  90739. * @returns serialization object
  90740. */
  90741. serializeAnimationRanges(): any;
  90742. /**
  90743. * Computes the world matrix of the node
  90744. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90745. * @returns the world matrix
  90746. */
  90747. computeWorldMatrix(force?: boolean): Matrix;
  90748. /**
  90749. * Releases resources associated with this node.
  90750. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90751. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90752. */
  90753. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90754. /**
  90755. * Parse animation range data from a serialization object and store them into a given node
  90756. * @param node defines where to store the animation ranges
  90757. * @param parsedNode defines the serialization object to read data from
  90758. * @param scene defines the hosting scene
  90759. */
  90760. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  90761. /**
  90762. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  90763. * @param includeDescendants Include bounding info from descendants as well (true by default)
  90764. * @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
  90765. * @returns the new bounding vectors
  90766. */
  90767. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  90768. min: Vector3;
  90769. max: Vector3;
  90770. };
  90771. }
  90772. }
  90773. declare module BABYLON {
  90774. /**
  90775. * @hidden
  90776. */
  90777. export class _IAnimationState {
  90778. key: number;
  90779. repeatCount: number;
  90780. workValue?: any;
  90781. loopMode?: number;
  90782. offsetValue?: any;
  90783. highLimitValue?: any;
  90784. }
  90785. /**
  90786. * Class used to store any kind of animation
  90787. */
  90788. export class Animation {
  90789. /**Name of the animation */
  90790. name: string;
  90791. /**Property to animate */
  90792. targetProperty: string;
  90793. /**The frames per second of the animation */
  90794. framePerSecond: number;
  90795. /**The data type of the animation */
  90796. dataType: number;
  90797. /**The loop mode of the animation */
  90798. loopMode?: number | undefined;
  90799. /**Specifies if blending should be enabled */
  90800. enableBlending?: boolean | undefined;
  90801. /**
  90802. * Use matrix interpolation instead of using direct key value when animating matrices
  90803. */
  90804. static AllowMatricesInterpolation: boolean;
  90805. /**
  90806. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  90807. */
  90808. static AllowMatrixDecomposeForInterpolation: boolean;
  90809. /**
  90810. * Stores the key frames of the animation
  90811. */
  90812. private _keys;
  90813. /**
  90814. * Stores the easing function of the animation
  90815. */
  90816. private _easingFunction;
  90817. /**
  90818. * @hidden Internal use only
  90819. */
  90820. _runtimeAnimations: RuntimeAnimation[];
  90821. /**
  90822. * The set of event that will be linked to this animation
  90823. */
  90824. private _events;
  90825. /**
  90826. * Stores an array of target property paths
  90827. */
  90828. targetPropertyPath: string[];
  90829. /**
  90830. * Stores the blending speed of the animation
  90831. */
  90832. blendingSpeed: number;
  90833. /**
  90834. * Stores the animation ranges for the animation
  90835. */
  90836. private _ranges;
  90837. /**
  90838. * @hidden Internal use
  90839. */
  90840. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90841. /**
  90842. * Sets up an animation
  90843. * @param property The property to animate
  90844. * @param animationType The animation type to apply
  90845. * @param framePerSecond The frames per second of the animation
  90846. * @param easingFunction The easing function used in the animation
  90847. * @returns The created animation
  90848. */
  90849. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90850. /**
  90851. * Create and start an animation on a node
  90852. * @param name defines the name of the global animation that will be run on all nodes
  90853. * @param node defines the root node where the animation will take place
  90854. * @param targetProperty defines property to animate
  90855. * @param framePerSecond defines the number of frame per second yo use
  90856. * @param totalFrame defines the number of frames in total
  90857. * @param from defines the initial value
  90858. * @param to defines the final value
  90859. * @param loopMode defines which loop mode you want to use (off by default)
  90860. * @param easingFunction defines the easing function to use (linear by default)
  90861. * @param onAnimationEnd defines the callback to call when animation end
  90862. * @returns the animatable created for this animation
  90863. */
  90864. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90865. /**
  90866. * Create and start an animation on a node and its descendants
  90867. * @param name defines the name of the global animation that will be run on all nodes
  90868. * @param node defines the root node where the animation will take place
  90869. * @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
  90870. * @param targetProperty defines property to animate
  90871. * @param framePerSecond defines the number of frame per second to use
  90872. * @param totalFrame defines the number of frames in total
  90873. * @param from defines the initial value
  90874. * @param to defines the final value
  90875. * @param loopMode defines which loop mode you want to use (off by default)
  90876. * @param easingFunction defines the easing function to use (linear by default)
  90877. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90878. * @returns the list of animatables created for all nodes
  90879. * @example https://www.babylonjs-playground.com/#MH0VLI
  90880. */
  90881. 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[]>;
  90882. /**
  90883. * Creates a new animation, merges it with the existing animations and starts it
  90884. * @param name Name of the animation
  90885. * @param node Node which contains the scene that begins the animations
  90886. * @param targetProperty Specifies which property to animate
  90887. * @param framePerSecond The frames per second of the animation
  90888. * @param totalFrame The total number of frames
  90889. * @param from The frame at the beginning of the animation
  90890. * @param to The frame at the end of the animation
  90891. * @param loopMode Specifies the loop mode of the animation
  90892. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90893. * @param onAnimationEnd Callback to run once the animation is complete
  90894. * @returns Nullable animation
  90895. */
  90896. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90897. /**
  90898. * Transition property of an host to the target Value
  90899. * @param property The property to transition
  90900. * @param targetValue The target Value of the property
  90901. * @param host The object where the property to animate belongs
  90902. * @param scene Scene used to run the animation
  90903. * @param frameRate Framerate (in frame/s) to use
  90904. * @param transition The transition type we want to use
  90905. * @param duration The duration of the animation, in milliseconds
  90906. * @param onAnimationEnd Callback trigger at the end of the animation
  90907. * @returns Nullable animation
  90908. */
  90909. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90910. /**
  90911. * Return the array of runtime animations currently using this animation
  90912. */
  90913. readonly runtimeAnimations: RuntimeAnimation[];
  90914. /**
  90915. * Specifies if any of the runtime animations are currently running
  90916. */
  90917. readonly hasRunningRuntimeAnimations: boolean;
  90918. /**
  90919. * Initializes the animation
  90920. * @param name Name of the animation
  90921. * @param targetProperty Property to animate
  90922. * @param framePerSecond The frames per second of the animation
  90923. * @param dataType The data type of the animation
  90924. * @param loopMode The loop mode of the animation
  90925. * @param enableBlending Specifies if blending should be enabled
  90926. */
  90927. constructor(
  90928. /**Name of the animation */
  90929. name: string,
  90930. /**Property to animate */
  90931. targetProperty: string,
  90932. /**The frames per second of the animation */
  90933. framePerSecond: number,
  90934. /**The data type of the animation */
  90935. dataType: number,
  90936. /**The loop mode of the animation */
  90937. loopMode?: number | undefined,
  90938. /**Specifies if blending should be enabled */
  90939. enableBlending?: boolean | undefined);
  90940. /**
  90941. * Converts the animation to a string
  90942. * @param fullDetails support for multiple levels of logging within scene loading
  90943. * @returns String form of the animation
  90944. */
  90945. toString(fullDetails?: boolean): string;
  90946. /**
  90947. * Add an event to this animation
  90948. * @param event Event to add
  90949. */
  90950. addEvent(event: AnimationEvent): void;
  90951. /**
  90952. * Remove all events found at the given frame
  90953. * @param frame The frame to remove events from
  90954. */
  90955. removeEvents(frame: number): void;
  90956. /**
  90957. * Retrieves all the events from the animation
  90958. * @returns Events from the animation
  90959. */
  90960. getEvents(): AnimationEvent[];
  90961. /**
  90962. * Creates an animation range
  90963. * @param name Name of the animation range
  90964. * @param from Starting frame of the animation range
  90965. * @param to Ending frame of the animation
  90966. */
  90967. createRange(name: string, from: number, to: number): void;
  90968. /**
  90969. * Deletes an animation range by name
  90970. * @param name Name of the animation range to delete
  90971. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90972. */
  90973. deleteRange(name: string, deleteFrames?: boolean): void;
  90974. /**
  90975. * Gets the animation range by name, or null if not defined
  90976. * @param name Name of the animation range
  90977. * @returns Nullable animation range
  90978. */
  90979. getRange(name: string): Nullable<AnimationRange>;
  90980. /**
  90981. * Gets the key frames from the animation
  90982. * @returns The key frames of the animation
  90983. */
  90984. getKeys(): Array<IAnimationKey>;
  90985. /**
  90986. * Gets the highest frame rate of the animation
  90987. * @returns Highest frame rate of the animation
  90988. */
  90989. getHighestFrame(): number;
  90990. /**
  90991. * Gets the easing function of the animation
  90992. * @returns Easing function of the animation
  90993. */
  90994. getEasingFunction(): IEasingFunction;
  90995. /**
  90996. * Sets the easing function of the animation
  90997. * @param easingFunction A custom mathematical formula for animation
  90998. */
  90999. setEasingFunction(easingFunction: EasingFunction): void;
  91000. /**
  91001. * Interpolates a scalar linearly
  91002. * @param startValue Start value of the animation curve
  91003. * @param endValue End value of the animation curve
  91004. * @param gradient Scalar amount to interpolate
  91005. * @returns Interpolated scalar value
  91006. */
  91007. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91008. /**
  91009. * Interpolates a scalar cubically
  91010. * @param startValue Start value of the animation curve
  91011. * @param outTangent End tangent of the animation
  91012. * @param endValue End value of the animation curve
  91013. * @param inTangent Start tangent of the animation curve
  91014. * @param gradient Scalar amount to interpolate
  91015. * @returns Interpolated scalar value
  91016. */
  91017. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91018. /**
  91019. * Interpolates a quaternion using a spherical linear interpolation
  91020. * @param startValue Start value of the animation curve
  91021. * @param endValue End value of the animation curve
  91022. * @param gradient Scalar amount to interpolate
  91023. * @returns Interpolated quaternion value
  91024. */
  91025. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91026. /**
  91027. * Interpolates a quaternion cubically
  91028. * @param startValue Start value of the animation curve
  91029. * @param outTangent End tangent of the animation curve
  91030. * @param endValue End value of the animation curve
  91031. * @param inTangent Start tangent of the animation curve
  91032. * @param gradient Scalar amount to interpolate
  91033. * @returns Interpolated quaternion value
  91034. */
  91035. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91036. /**
  91037. * Interpolates a Vector3 linearl
  91038. * @param startValue Start value of the animation curve
  91039. * @param endValue End value of the animation curve
  91040. * @param gradient Scalar amount to interpolate
  91041. * @returns Interpolated scalar value
  91042. */
  91043. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91044. /**
  91045. * Interpolates a Vector3 cubically
  91046. * @param startValue Start value of the animation curve
  91047. * @param outTangent End tangent of the animation
  91048. * @param endValue End value of the animation curve
  91049. * @param inTangent Start tangent of the animation curve
  91050. * @param gradient Scalar amount to interpolate
  91051. * @returns InterpolatedVector3 value
  91052. */
  91053. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91054. /**
  91055. * Interpolates a Vector2 linearly
  91056. * @param startValue Start value of the animation curve
  91057. * @param endValue End value of the animation curve
  91058. * @param gradient Scalar amount to interpolate
  91059. * @returns Interpolated Vector2 value
  91060. */
  91061. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91062. /**
  91063. * Interpolates a Vector2 cubically
  91064. * @param startValue Start value of the animation curve
  91065. * @param outTangent End tangent of the animation
  91066. * @param endValue End value of the animation curve
  91067. * @param inTangent Start tangent of the animation curve
  91068. * @param gradient Scalar amount to interpolate
  91069. * @returns Interpolated Vector2 value
  91070. */
  91071. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91072. /**
  91073. * Interpolates a size linearly
  91074. * @param startValue Start value of the animation curve
  91075. * @param endValue End value of the animation curve
  91076. * @param gradient Scalar amount to interpolate
  91077. * @returns Interpolated Size value
  91078. */
  91079. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91080. /**
  91081. * Interpolates a Color3 linearly
  91082. * @param startValue Start value of the animation curve
  91083. * @param endValue End value of the animation curve
  91084. * @param gradient Scalar amount to interpolate
  91085. * @returns Interpolated Color3 value
  91086. */
  91087. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91088. /**
  91089. * @hidden Internal use only
  91090. */
  91091. _getKeyValue(value: any): any;
  91092. /**
  91093. * @hidden Internal use only
  91094. */
  91095. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91096. /**
  91097. * Defines the function to use to interpolate matrices
  91098. * @param startValue defines the start matrix
  91099. * @param endValue defines the end matrix
  91100. * @param gradient defines the gradient between both matrices
  91101. * @param result defines an optional target matrix where to store the interpolation
  91102. * @returns the interpolated matrix
  91103. */
  91104. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91105. /**
  91106. * Makes a copy of the animation
  91107. * @returns Cloned animation
  91108. */
  91109. clone(): Animation;
  91110. /**
  91111. * Sets the key frames of the animation
  91112. * @param values The animation key frames to set
  91113. */
  91114. setKeys(values: Array<IAnimationKey>): void;
  91115. /**
  91116. * Serializes the animation to an object
  91117. * @returns Serialized object
  91118. */
  91119. serialize(): any;
  91120. /**
  91121. * Float animation type
  91122. */
  91123. private static _ANIMATIONTYPE_FLOAT;
  91124. /**
  91125. * Vector3 animation type
  91126. */
  91127. private static _ANIMATIONTYPE_VECTOR3;
  91128. /**
  91129. * Quaternion animation type
  91130. */
  91131. private static _ANIMATIONTYPE_QUATERNION;
  91132. /**
  91133. * Matrix animation type
  91134. */
  91135. private static _ANIMATIONTYPE_MATRIX;
  91136. /**
  91137. * Color3 animation type
  91138. */
  91139. private static _ANIMATIONTYPE_COLOR3;
  91140. /**
  91141. * Vector2 animation type
  91142. */
  91143. private static _ANIMATIONTYPE_VECTOR2;
  91144. /**
  91145. * Size animation type
  91146. */
  91147. private static _ANIMATIONTYPE_SIZE;
  91148. /**
  91149. * Relative Loop Mode
  91150. */
  91151. private static _ANIMATIONLOOPMODE_RELATIVE;
  91152. /**
  91153. * Cycle Loop Mode
  91154. */
  91155. private static _ANIMATIONLOOPMODE_CYCLE;
  91156. /**
  91157. * Constant Loop Mode
  91158. */
  91159. private static _ANIMATIONLOOPMODE_CONSTANT;
  91160. /**
  91161. * Get the float animation type
  91162. */
  91163. static readonly ANIMATIONTYPE_FLOAT: number;
  91164. /**
  91165. * Get the Vector3 animation type
  91166. */
  91167. static readonly ANIMATIONTYPE_VECTOR3: number;
  91168. /**
  91169. * Get the Vector2 animation type
  91170. */
  91171. static readonly ANIMATIONTYPE_VECTOR2: number;
  91172. /**
  91173. * Get the Size animation type
  91174. */
  91175. static readonly ANIMATIONTYPE_SIZE: number;
  91176. /**
  91177. * Get the Quaternion animation type
  91178. */
  91179. static readonly ANIMATIONTYPE_QUATERNION: number;
  91180. /**
  91181. * Get the Matrix animation type
  91182. */
  91183. static readonly ANIMATIONTYPE_MATRIX: number;
  91184. /**
  91185. * Get the Color3 animation type
  91186. */
  91187. static readonly ANIMATIONTYPE_COLOR3: number;
  91188. /**
  91189. * Get the Relative Loop Mode
  91190. */
  91191. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91192. /**
  91193. * Get the Cycle Loop Mode
  91194. */
  91195. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91196. /**
  91197. * Get the Constant Loop Mode
  91198. */
  91199. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91200. /** @hidden */
  91201. static _UniversalLerp(left: any, right: any, amount: number): any;
  91202. /**
  91203. * Parses an animation object and creates an animation
  91204. * @param parsedAnimation Parsed animation object
  91205. * @returns Animation object
  91206. */
  91207. static Parse(parsedAnimation: any): Animation;
  91208. /**
  91209. * Appends the serialized animations from the source animations
  91210. * @param source Source containing the animations
  91211. * @param destination Target to store the animations
  91212. */
  91213. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91214. }
  91215. }
  91216. declare module BABYLON {
  91217. /**
  91218. * Interface containing an array of animations
  91219. */
  91220. export interface IAnimatable {
  91221. /**
  91222. * Array of animations
  91223. */
  91224. animations: Nullable<Array<Animation>>;
  91225. }
  91226. }
  91227. declare module BABYLON {
  91228. /**
  91229. * This represents all the required information to add a fresnel effect on a material:
  91230. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91231. */
  91232. export class FresnelParameters {
  91233. private _isEnabled;
  91234. /**
  91235. * Define if the fresnel effect is enable or not.
  91236. */
  91237. isEnabled: boolean;
  91238. /**
  91239. * Define the color used on edges (grazing angle)
  91240. */
  91241. leftColor: Color3;
  91242. /**
  91243. * Define the color used on center
  91244. */
  91245. rightColor: Color3;
  91246. /**
  91247. * Define bias applied to computed fresnel term
  91248. */
  91249. bias: number;
  91250. /**
  91251. * Defined the power exponent applied to fresnel term
  91252. */
  91253. power: number;
  91254. /**
  91255. * Clones the current fresnel and its valuues
  91256. * @returns a clone fresnel configuration
  91257. */
  91258. clone(): FresnelParameters;
  91259. /**
  91260. * Serializes the current fresnel parameters to a JSON representation.
  91261. * @return the JSON serialization
  91262. */
  91263. serialize(): any;
  91264. /**
  91265. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91266. * @param parsedFresnelParameters Define the JSON representation
  91267. * @returns the parsed parameters
  91268. */
  91269. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91270. }
  91271. }
  91272. declare module BABYLON {
  91273. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91274. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91275. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91276. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91277. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91278. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91279. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91280. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91281. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91282. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91283. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91284. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91285. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91286. /**
  91287. * Decorator used to define property that can be serialized as reference to a camera
  91288. * @param sourceName defines the name of the property to decorate
  91289. */
  91290. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91291. /**
  91292. * Class used to help serialization objects
  91293. */
  91294. export class SerializationHelper {
  91295. /** @hidden */
  91296. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91297. /** @hidden */
  91298. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91299. /** @hidden */
  91300. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91301. /** @hidden */
  91302. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91303. /**
  91304. * Appends the serialized animations from the source animations
  91305. * @param source Source containing the animations
  91306. * @param destination Target to store the animations
  91307. */
  91308. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91309. /**
  91310. * Static function used to serialized a specific entity
  91311. * @param entity defines the entity to serialize
  91312. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91313. * @returns a JSON compatible object representing the serialization of the entity
  91314. */
  91315. static Serialize<T>(entity: T, serializationObject?: any): any;
  91316. /**
  91317. * Creates a new entity from a serialization data object
  91318. * @param creationFunction defines a function used to instanciated the new entity
  91319. * @param source defines the source serialization data
  91320. * @param scene defines the hosting scene
  91321. * @param rootUrl defines the root url for resources
  91322. * @returns a new entity
  91323. */
  91324. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91325. /**
  91326. * Clones an object
  91327. * @param creationFunction defines the function used to instanciate the new object
  91328. * @param source defines the source object
  91329. * @returns the cloned object
  91330. */
  91331. static Clone<T>(creationFunction: () => T, source: T): T;
  91332. /**
  91333. * Instanciates a new object based on a source one (some data will be shared between both object)
  91334. * @param creationFunction defines the function used to instanciate the new object
  91335. * @param source defines the source object
  91336. * @returns the new object
  91337. */
  91338. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91339. }
  91340. }
  91341. declare module BABYLON {
  91342. /**
  91343. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91344. */
  91345. export interface CubeMapInfo {
  91346. /**
  91347. * The pixel array for the front face.
  91348. * This is stored in format, left to right, up to down format.
  91349. */
  91350. front: Nullable<ArrayBufferView>;
  91351. /**
  91352. * The pixel array for the back face.
  91353. * This is stored in format, left to right, up to down format.
  91354. */
  91355. back: Nullable<ArrayBufferView>;
  91356. /**
  91357. * The pixel array for the left face.
  91358. * This is stored in format, left to right, up to down format.
  91359. */
  91360. left: Nullable<ArrayBufferView>;
  91361. /**
  91362. * The pixel array for the right face.
  91363. * This is stored in format, left to right, up to down format.
  91364. */
  91365. right: Nullable<ArrayBufferView>;
  91366. /**
  91367. * The pixel array for the up face.
  91368. * This is stored in format, left to right, up to down format.
  91369. */
  91370. up: Nullable<ArrayBufferView>;
  91371. /**
  91372. * The pixel array for the down face.
  91373. * This is stored in format, left to right, up to down format.
  91374. */
  91375. down: Nullable<ArrayBufferView>;
  91376. /**
  91377. * The size of the cubemap stored.
  91378. *
  91379. * Each faces will be size * size pixels.
  91380. */
  91381. size: number;
  91382. /**
  91383. * The format of the texture.
  91384. *
  91385. * RGBA, RGB.
  91386. */
  91387. format: number;
  91388. /**
  91389. * The type of the texture data.
  91390. *
  91391. * UNSIGNED_INT, FLOAT.
  91392. */
  91393. type: number;
  91394. /**
  91395. * Specifies whether the texture is in gamma space.
  91396. */
  91397. gammaSpace: boolean;
  91398. }
  91399. /**
  91400. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91401. */
  91402. export class PanoramaToCubeMapTools {
  91403. private static FACE_FRONT;
  91404. private static FACE_BACK;
  91405. private static FACE_RIGHT;
  91406. private static FACE_LEFT;
  91407. private static FACE_DOWN;
  91408. private static FACE_UP;
  91409. /**
  91410. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91411. *
  91412. * @param float32Array The source data.
  91413. * @param inputWidth The width of the input panorama.
  91414. * @param inputHeight The height of the input panorama.
  91415. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91416. * @return The cubemap data
  91417. */
  91418. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91419. private static CreateCubemapTexture;
  91420. private static CalcProjectionSpherical;
  91421. }
  91422. }
  91423. declare module BABYLON {
  91424. /**
  91425. * Helper class dealing with the extraction of spherical polynomial dataArray
  91426. * from a cube map.
  91427. */
  91428. export class CubeMapToSphericalPolynomialTools {
  91429. private static FileFaces;
  91430. /**
  91431. * Converts a texture to the according Spherical Polynomial data.
  91432. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91433. *
  91434. * @param texture The texture to extract the information from.
  91435. * @return The Spherical Polynomial data.
  91436. */
  91437. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91438. /**
  91439. * Converts a cubemap to the according Spherical Polynomial data.
  91440. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91441. *
  91442. * @param cubeInfo The Cube map to extract the information from.
  91443. * @return The Spherical Polynomial data.
  91444. */
  91445. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91446. }
  91447. }
  91448. declare module BABYLON {
  91449. /**
  91450. * Class used to manipulate GUIDs
  91451. */
  91452. export class GUID {
  91453. /**
  91454. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91455. * Be aware Math.random() could cause collisions, but:
  91456. * "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"
  91457. * @returns a pseudo random id
  91458. */
  91459. static RandomId(): string;
  91460. }
  91461. }
  91462. declare module BABYLON {
  91463. /**
  91464. * Base class of all the textures in babylon.
  91465. * It groups all the common properties the materials, post process, lights... might need
  91466. * in order to make a correct use of the texture.
  91467. */
  91468. export class BaseTexture implements IAnimatable {
  91469. /**
  91470. * Default anisotropic filtering level for the application.
  91471. * It is set to 4 as a good tradeoff between perf and quality.
  91472. */
  91473. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91474. /**
  91475. * Gets or sets the unique id of the texture
  91476. */
  91477. uniqueId: number;
  91478. /**
  91479. * Define the name of the texture.
  91480. */
  91481. name: string;
  91482. /**
  91483. * Gets or sets an object used to store user defined information.
  91484. */
  91485. metadata: any;
  91486. /**
  91487. * For internal use only. Please do not use.
  91488. */
  91489. reservedDataStore: any;
  91490. private _hasAlpha;
  91491. /**
  91492. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91493. */
  91494. hasAlpha: boolean;
  91495. /**
  91496. * Defines if the alpha value should be determined via the rgb values.
  91497. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91498. */
  91499. getAlphaFromRGB: boolean;
  91500. /**
  91501. * Intensity or strength of the texture.
  91502. * It is commonly used by materials to fine tune the intensity of the texture
  91503. */
  91504. level: number;
  91505. /**
  91506. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91507. * This is part of the texture as textures usually maps to one uv set.
  91508. */
  91509. coordinatesIndex: number;
  91510. private _coordinatesMode;
  91511. /**
  91512. * How a texture is mapped.
  91513. *
  91514. * | Value | Type | Description |
  91515. * | ----- | ----------------------------------- | ----------- |
  91516. * | 0 | EXPLICIT_MODE | |
  91517. * | 1 | SPHERICAL_MODE | |
  91518. * | 2 | PLANAR_MODE | |
  91519. * | 3 | CUBIC_MODE | |
  91520. * | 4 | PROJECTION_MODE | |
  91521. * | 5 | SKYBOX_MODE | |
  91522. * | 6 | INVCUBIC_MODE | |
  91523. * | 7 | EQUIRECTANGULAR_MODE | |
  91524. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91525. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91526. */
  91527. coordinatesMode: number;
  91528. /**
  91529. * | Value | Type | Description |
  91530. * | ----- | ------------------ | ----------- |
  91531. * | 0 | CLAMP_ADDRESSMODE | |
  91532. * | 1 | WRAP_ADDRESSMODE | |
  91533. * | 2 | MIRROR_ADDRESSMODE | |
  91534. */
  91535. wrapU: number;
  91536. /**
  91537. * | Value | Type | Description |
  91538. * | ----- | ------------------ | ----------- |
  91539. * | 0 | CLAMP_ADDRESSMODE | |
  91540. * | 1 | WRAP_ADDRESSMODE | |
  91541. * | 2 | MIRROR_ADDRESSMODE | |
  91542. */
  91543. wrapV: number;
  91544. /**
  91545. * | Value | Type | Description |
  91546. * | ----- | ------------------ | ----------- |
  91547. * | 0 | CLAMP_ADDRESSMODE | |
  91548. * | 1 | WRAP_ADDRESSMODE | |
  91549. * | 2 | MIRROR_ADDRESSMODE | |
  91550. */
  91551. wrapR: number;
  91552. /**
  91553. * With compliant hardware and browser (supporting anisotropic filtering)
  91554. * this defines the level of anisotropic filtering in the texture.
  91555. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91556. */
  91557. anisotropicFilteringLevel: number;
  91558. /**
  91559. * Define if the texture is a cube texture or if false a 2d texture.
  91560. */
  91561. isCube: boolean;
  91562. /**
  91563. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91564. */
  91565. is3D: boolean;
  91566. /**
  91567. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91568. * HDR texture are usually stored in linear space.
  91569. * This only impacts the PBR and Background materials
  91570. */
  91571. gammaSpace: boolean;
  91572. /**
  91573. * Gets whether or not the texture contains RGBD data.
  91574. */
  91575. readonly isRGBD: boolean;
  91576. /**
  91577. * Is Z inverted in the texture (useful in a cube texture).
  91578. */
  91579. invertZ: boolean;
  91580. /**
  91581. * Are mip maps generated for this texture or not.
  91582. */
  91583. readonly noMipmap: boolean;
  91584. /**
  91585. * @hidden
  91586. */
  91587. lodLevelInAlpha: boolean;
  91588. /**
  91589. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91590. */
  91591. lodGenerationOffset: number;
  91592. /**
  91593. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91594. */
  91595. lodGenerationScale: number;
  91596. /**
  91597. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91598. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91599. * average roughness values.
  91600. */
  91601. linearSpecularLOD: boolean;
  91602. /**
  91603. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91604. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91605. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91606. */
  91607. irradianceTexture: Nullable<BaseTexture>;
  91608. /**
  91609. * Define if the texture is a render target.
  91610. */
  91611. isRenderTarget: boolean;
  91612. /**
  91613. * Define the unique id of the texture in the scene.
  91614. */
  91615. readonly uid: string;
  91616. /**
  91617. * Return a string representation of the texture.
  91618. * @returns the texture as a string
  91619. */
  91620. toString(): string;
  91621. /**
  91622. * Get the class name of the texture.
  91623. * @returns "BaseTexture"
  91624. */
  91625. getClassName(): string;
  91626. /**
  91627. * Define the list of animation attached to the texture.
  91628. */
  91629. animations: Animation[];
  91630. /**
  91631. * An event triggered when the texture is disposed.
  91632. */
  91633. onDisposeObservable: Observable<BaseTexture>;
  91634. private _onDisposeObserver;
  91635. /**
  91636. * Callback triggered when the texture has been disposed.
  91637. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91638. */
  91639. onDispose: () => void;
  91640. /**
  91641. * Define the current state of the loading sequence when in delayed load mode.
  91642. */
  91643. delayLoadState: number;
  91644. private _scene;
  91645. /** @hidden */
  91646. _texture: Nullable<InternalTexture>;
  91647. private _uid;
  91648. /**
  91649. * Define if the texture is preventinga material to render or not.
  91650. * If not and the texture is not ready, the engine will use a default black texture instead.
  91651. */
  91652. readonly isBlocking: boolean;
  91653. /**
  91654. * Instantiates a new BaseTexture.
  91655. * Base class of all the textures in babylon.
  91656. * It groups all the common properties the materials, post process, lights... might need
  91657. * in order to make a correct use of the texture.
  91658. * @param scene Define the scene the texture blongs to
  91659. */
  91660. constructor(scene: Nullable<Scene>);
  91661. /**
  91662. * Get the scene the texture belongs to.
  91663. * @returns the scene or null if undefined
  91664. */
  91665. getScene(): Nullable<Scene>;
  91666. /**
  91667. * Get the texture transform matrix used to offset tile the texture for istance.
  91668. * @returns the transformation matrix
  91669. */
  91670. getTextureMatrix(): Matrix;
  91671. /**
  91672. * Get the texture reflection matrix used to rotate/transform the reflection.
  91673. * @returns the reflection matrix
  91674. */
  91675. getReflectionTextureMatrix(): Matrix;
  91676. /**
  91677. * Get the underlying lower level texture from Babylon.
  91678. * @returns the insternal texture
  91679. */
  91680. getInternalTexture(): Nullable<InternalTexture>;
  91681. /**
  91682. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91683. * @returns true if ready or not blocking
  91684. */
  91685. isReadyOrNotBlocking(): boolean;
  91686. /**
  91687. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91688. * @returns true if fully ready
  91689. */
  91690. isReady(): boolean;
  91691. private _cachedSize;
  91692. /**
  91693. * Get the size of the texture.
  91694. * @returns the texture size.
  91695. */
  91696. getSize(): ISize;
  91697. /**
  91698. * Get the base size of the texture.
  91699. * It can be different from the size if the texture has been resized for POT for instance
  91700. * @returns the base size
  91701. */
  91702. getBaseSize(): ISize;
  91703. /**
  91704. * Update the sampling mode of the texture.
  91705. * Default is Trilinear mode.
  91706. *
  91707. * | Value | Type | Description |
  91708. * | ----- | ------------------ | ----------- |
  91709. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91710. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91711. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91712. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91713. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91714. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91715. * | 7 | NEAREST_LINEAR | |
  91716. * | 8 | NEAREST_NEAREST | |
  91717. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91718. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91719. * | 11 | LINEAR_LINEAR | |
  91720. * | 12 | LINEAR_NEAREST | |
  91721. *
  91722. * > _mag_: magnification filter (close to the viewer)
  91723. * > _min_: minification filter (far from the viewer)
  91724. * > _mip_: filter used between mip map levels
  91725. *@param samplingMode Define the new sampling mode of the texture
  91726. */
  91727. updateSamplingMode(samplingMode: number): void;
  91728. /**
  91729. * Scales the texture if is `canRescale()`
  91730. * @param ratio the resize factor we want to use to rescale
  91731. */
  91732. scale(ratio: number): void;
  91733. /**
  91734. * Get if the texture can rescale.
  91735. */
  91736. readonly canRescale: boolean;
  91737. /** @hidden */
  91738. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91739. /** @hidden */
  91740. _rebuild(): void;
  91741. /**
  91742. * Triggers the load sequence in delayed load mode.
  91743. */
  91744. delayLoad(): void;
  91745. /**
  91746. * Clones the texture.
  91747. * @returns the cloned texture
  91748. */
  91749. clone(): Nullable<BaseTexture>;
  91750. /**
  91751. * Get the texture underlying type (INT, FLOAT...)
  91752. */
  91753. readonly textureType: number;
  91754. /**
  91755. * Get the texture underlying format (RGB, RGBA...)
  91756. */
  91757. readonly textureFormat: number;
  91758. /**
  91759. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  91760. * This will returns an RGBA array buffer containing either in values (0-255) or
  91761. * float values (0-1) depending of the underlying buffer type.
  91762. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  91763. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  91764. * @param buffer defines a user defined buffer to fill with data (can be null)
  91765. * @returns The Array buffer containing the pixels data.
  91766. */
  91767. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  91768. /**
  91769. * Release and destroy the underlying lower level texture aka internalTexture.
  91770. */
  91771. releaseInternalTexture(): void;
  91772. /**
  91773. * Get the polynomial representation of the texture data.
  91774. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  91775. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  91776. */
  91777. sphericalPolynomial: Nullable<SphericalPolynomial>;
  91778. /** @hidden */
  91779. readonly _lodTextureHigh: Nullable<BaseTexture>;
  91780. /** @hidden */
  91781. readonly _lodTextureMid: Nullable<BaseTexture>;
  91782. /** @hidden */
  91783. readonly _lodTextureLow: Nullable<BaseTexture>;
  91784. /**
  91785. * Dispose the texture and release its associated resources.
  91786. */
  91787. dispose(): void;
  91788. /**
  91789. * Serialize the texture into a JSON representation that can be parsed later on.
  91790. * @returns the JSON representation of the texture
  91791. */
  91792. serialize(): any;
  91793. /**
  91794. * Helper function to be called back once a list of texture contains only ready textures.
  91795. * @param textures Define the list of textures to wait for
  91796. * @param callback Define the callback triggered once the entire list will be ready
  91797. */
  91798. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  91799. }
  91800. }
  91801. declare module BABYLON {
  91802. /**
  91803. * Class used to store data associated with WebGL texture data for the engine
  91804. * This class should not be used directly
  91805. */
  91806. export class InternalTexture {
  91807. /** @hidden */
  91808. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  91809. /**
  91810. * The source of the texture data is unknown
  91811. */
  91812. static DATASOURCE_UNKNOWN: number;
  91813. /**
  91814. * Texture data comes from an URL
  91815. */
  91816. static DATASOURCE_URL: number;
  91817. /**
  91818. * Texture data is only used for temporary storage
  91819. */
  91820. static DATASOURCE_TEMP: number;
  91821. /**
  91822. * Texture data comes from raw data (ArrayBuffer)
  91823. */
  91824. static DATASOURCE_RAW: number;
  91825. /**
  91826. * Texture content is dynamic (video or dynamic texture)
  91827. */
  91828. static DATASOURCE_DYNAMIC: number;
  91829. /**
  91830. * Texture content is generated by rendering to it
  91831. */
  91832. static DATASOURCE_RENDERTARGET: number;
  91833. /**
  91834. * Texture content is part of a multi render target process
  91835. */
  91836. static DATASOURCE_MULTIRENDERTARGET: number;
  91837. /**
  91838. * Texture data comes from a cube data file
  91839. */
  91840. static DATASOURCE_CUBE: number;
  91841. /**
  91842. * Texture data comes from a raw cube data
  91843. */
  91844. static DATASOURCE_CUBERAW: number;
  91845. /**
  91846. * Texture data come from a prefiltered cube data file
  91847. */
  91848. static DATASOURCE_CUBEPREFILTERED: number;
  91849. /**
  91850. * Texture content is raw 3D data
  91851. */
  91852. static DATASOURCE_RAW3D: number;
  91853. /**
  91854. * Texture content is a depth texture
  91855. */
  91856. static DATASOURCE_DEPTHTEXTURE: number;
  91857. /**
  91858. * Texture data comes from a raw cube data encoded with RGBD
  91859. */
  91860. static DATASOURCE_CUBERAW_RGBD: number;
  91861. /**
  91862. * Defines if the texture is ready
  91863. */
  91864. isReady: boolean;
  91865. /**
  91866. * Defines if the texture is a cube texture
  91867. */
  91868. isCube: boolean;
  91869. /**
  91870. * Defines if the texture contains 3D data
  91871. */
  91872. is3D: boolean;
  91873. /**
  91874. * Defines if the texture contains multiview data
  91875. */
  91876. isMultiview: boolean;
  91877. /**
  91878. * Gets the URL used to load this texture
  91879. */
  91880. url: string;
  91881. /**
  91882. * Gets the sampling mode of the texture
  91883. */
  91884. samplingMode: number;
  91885. /**
  91886. * Gets a boolean indicating if the texture needs mipmaps generation
  91887. */
  91888. generateMipMaps: boolean;
  91889. /**
  91890. * Gets the number of samples used by the texture (WebGL2+ only)
  91891. */
  91892. samples: number;
  91893. /**
  91894. * Gets the type of the texture (int, float...)
  91895. */
  91896. type: number;
  91897. /**
  91898. * Gets the format of the texture (RGB, RGBA...)
  91899. */
  91900. format: number;
  91901. /**
  91902. * Observable called when the texture is loaded
  91903. */
  91904. onLoadedObservable: Observable<InternalTexture>;
  91905. /**
  91906. * Gets the width of the texture
  91907. */
  91908. width: number;
  91909. /**
  91910. * Gets the height of the texture
  91911. */
  91912. height: number;
  91913. /**
  91914. * Gets the depth of the texture
  91915. */
  91916. depth: number;
  91917. /**
  91918. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91919. */
  91920. baseWidth: number;
  91921. /**
  91922. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91923. */
  91924. baseHeight: number;
  91925. /**
  91926. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91927. */
  91928. baseDepth: number;
  91929. /**
  91930. * Gets a boolean indicating if the texture is inverted on Y axis
  91931. */
  91932. invertY: boolean;
  91933. /** @hidden */
  91934. _invertVScale: boolean;
  91935. /** @hidden */
  91936. _associatedChannel: number;
  91937. /** @hidden */
  91938. _dataSource: number;
  91939. /** @hidden */
  91940. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91941. /** @hidden */
  91942. _bufferView: Nullable<ArrayBufferView>;
  91943. /** @hidden */
  91944. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91945. /** @hidden */
  91946. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91947. /** @hidden */
  91948. _size: number;
  91949. /** @hidden */
  91950. _extension: string;
  91951. /** @hidden */
  91952. _files: Nullable<string[]>;
  91953. /** @hidden */
  91954. _workingCanvas: Nullable<HTMLCanvasElement>;
  91955. /** @hidden */
  91956. _workingContext: Nullable<CanvasRenderingContext2D>;
  91957. /** @hidden */
  91958. _framebuffer: Nullable<WebGLFramebuffer>;
  91959. /** @hidden */
  91960. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91961. /** @hidden */
  91962. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91963. /** @hidden */
  91964. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91965. /** @hidden */
  91966. _attachments: Nullable<number[]>;
  91967. /** @hidden */
  91968. _cachedCoordinatesMode: Nullable<number>;
  91969. /** @hidden */
  91970. _cachedWrapU: Nullable<number>;
  91971. /** @hidden */
  91972. _cachedWrapV: Nullable<number>;
  91973. /** @hidden */
  91974. _cachedWrapR: Nullable<number>;
  91975. /** @hidden */
  91976. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91977. /** @hidden */
  91978. _isDisabled: boolean;
  91979. /** @hidden */
  91980. _compression: Nullable<string>;
  91981. /** @hidden */
  91982. _generateStencilBuffer: boolean;
  91983. /** @hidden */
  91984. _generateDepthBuffer: boolean;
  91985. /** @hidden */
  91986. _comparisonFunction: number;
  91987. /** @hidden */
  91988. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91989. /** @hidden */
  91990. _lodGenerationScale: number;
  91991. /** @hidden */
  91992. _lodGenerationOffset: number;
  91993. /** @hidden */
  91994. _colorTextureArray: Nullable<WebGLTexture>;
  91995. /** @hidden */
  91996. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91997. /** @hidden */
  91998. _lodTextureHigh: Nullable<BaseTexture>;
  91999. /** @hidden */
  92000. _lodTextureMid: Nullable<BaseTexture>;
  92001. /** @hidden */
  92002. _lodTextureLow: Nullable<BaseTexture>;
  92003. /** @hidden */
  92004. _isRGBD: boolean;
  92005. /** @hidden */
  92006. _linearSpecularLOD: boolean;
  92007. /** @hidden */
  92008. _irradianceTexture: Nullable<BaseTexture>;
  92009. /** @hidden */
  92010. _webGLTexture: Nullable<WebGLTexture>;
  92011. /** @hidden */
  92012. _references: number;
  92013. private _engine;
  92014. /**
  92015. * Gets the Engine the texture belongs to.
  92016. * @returns The babylon engine
  92017. */
  92018. getEngine(): Engine;
  92019. /**
  92020. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92021. */
  92022. readonly dataSource: number;
  92023. /**
  92024. * Creates a new InternalTexture
  92025. * @param engine defines the engine to use
  92026. * @param dataSource defines the type of data that will be used
  92027. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92028. */
  92029. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92030. /**
  92031. * Increments the number of references (ie. the number of Texture that point to it)
  92032. */
  92033. incrementReferences(): void;
  92034. /**
  92035. * Change the size of the texture (not the size of the content)
  92036. * @param width defines the new width
  92037. * @param height defines the new height
  92038. * @param depth defines the new depth (1 by default)
  92039. */
  92040. updateSize(width: int, height: int, depth?: int): void;
  92041. /** @hidden */
  92042. _rebuild(): void;
  92043. /** @hidden */
  92044. _swapAndDie(target: InternalTexture): void;
  92045. /**
  92046. * Dispose the current allocated resources
  92047. */
  92048. dispose(): void;
  92049. }
  92050. }
  92051. declare module BABYLON {
  92052. /**
  92053. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92054. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92055. */
  92056. export class EffectFallbacks {
  92057. private _defines;
  92058. private _currentRank;
  92059. private _maxRank;
  92060. private _mesh;
  92061. /**
  92062. * Removes the fallback from the bound mesh.
  92063. */
  92064. unBindMesh(): void;
  92065. /**
  92066. * Adds a fallback on the specified property.
  92067. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92068. * @param define The name of the define in the shader
  92069. */
  92070. addFallback(rank: number, define: string): void;
  92071. /**
  92072. * Sets the mesh to use CPU skinning when needing to fallback.
  92073. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92074. * @param mesh The mesh to use the fallbacks.
  92075. */
  92076. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92077. /**
  92078. * Checks to see if more fallbacks are still availible.
  92079. */
  92080. readonly isMoreFallbacks: boolean;
  92081. /**
  92082. * Removes the defines that should be removed when falling back.
  92083. * @param currentDefines defines the current define statements for the shader.
  92084. * @param effect defines the current effect we try to compile
  92085. * @returns The resulting defines with defines of the current rank removed.
  92086. */
  92087. reduce(currentDefines: string, effect: Effect): string;
  92088. }
  92089. /**
  92090. * Options to be used when creating an effect.
  92091. */
  92092. export class EffectCreationOptions {
  92093. /**
  92094. * Atrributes that will be used in the shader.
  92095. */
  92096. attributes: string[];
  92097. /**
  92098. * Uniform varible names that will be set in the shader.
  92099. */
  92100. uniformsNames: string[];
  92101. /**
  92102. * Uniform buffer varible names that will be set in the shader.
  92103. */
  92104. uniformBuffersNames: string[];
  92105. /**
  92106. * Sampler texture variable names that will be set in the shader.
  92107. */
  92108. samplers: string[];
  92109. /**
  92110. * Define statements that will be set in the shader.
  92111. */
  92112. defines: any;
  92113. /**
  92114. * Possible fallbacks for this effect to improve performance when needed.
  92115. */
  92116. fallbacks: Nullable<EffectFallbacks>;
  92117. /**
  92118. * Callback that will be called when the shader is compiled.
  92119. */
  92120. onCompiled: Nullable<(effect: Effect) => void>;
  92121. /**
  92122. * Callback that will be called if an error occurs during shader compilation.
  92123. */
  92124. onError: Nullable<(effect: Effect, errors: string) => void>;
  92125. /**
  92126. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92127. */
  92128. indexParameters: any;
  92129. /**
  92130. * Max number of lights that can be used in the shader.
  92131. */
  92132. maxSimultaneousLights: number;
  92133. /**
  92134. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92135. */
  92136. transformFeedbackVaryings: Nullable<string[]>;
  92137. }
  92138. /**
  92139. * Effect containing vertex and fragment shader that can be executed on an object.
  92140. */
  92141. export class Effect implements IDisposable {
  92142. /**
  92143. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92144. */
  92145. static ShadersRepository: string;
  92146. /**
  92147. * Name of the effect.
  92148. */
  92149. name: any;
  92150. /**
  92151. * String container all the define statements that should be set on the shader.
  92152. */
  92153. defines: string;
  92154. /**
  92155. * Callback that will be called when the shader is compiled.
  92156. */
  92157. onCompiled: Nullable<(effect: Effect) => void>;
  92158. /**
  92159. * Callback that will be called if an error occurs during shader compilation.
  92160. */
  92161. onError: Nullable<(effect: Effect, errors: string) => void>;
  92162. /**
  92163. * Callback that will be called when effect is bound.
  92164. */
  92165. onBind: Nullable<(effect: Effect) => void>;
  92166. /**
  92167. * Unique ID of the effect.
  92168. */
  92169. uniqueId: number;
  92170. /**
  92171. * Observable that will be called when the shader is compiled.
  92172. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92173. */
  92174. onCompileObservable: Observable<Effect>;
  92175. /**
  92176. * Observable that will be called if an error occurs during shader compilation.
  92177. */
  92178. onErrorObservable: Observable<Effect>;
  92179. /** @hidden */
  92180. _onBindObservable: Nullable<Observable<Effect>>;
  92181. /**
  92182. * Observable that will be called when effect is bound.
  92183. */
  92184. readonly onBindObservable: Observable<Effect>;
  92185. /** @hidden */
  92186. _bonesComputationForcedToCPU: boolean;
  92187. private static _uniqueIdSeed;
  92188. private _engine;
  92189. private _uniformBuffersNames;
  92190. private _uniformsNames;
  92191. private _samplerList;
  92192. private _samplers;
  92193. private _isReady;
  92194. private _compilationError;
  92195. private _attributesNames;
  92196. private _attributes;
  92197. private _uniforms;
  92198. /**
  92199. * Key for the effect.
  92200. * @hidden
  92201. */
  92202. _key: string;
  92203. private _indexParameters;
  92204. private _fallbacks;
  92205. private _vertexSourceCode;
  92206. private _fragmentSourceCode;
  92207. private _vertexSourceCodeOverride;
  92208. private _fragmentSourceCodeOverride;
  92209. private _transformFeedbackVaryings;
  92210. /**
  92211. * Compiled shader to webGL program.
  92212. * @hidden
  92213. */
  92214. _pipelineContext: Nullable<IPipelineContext>;
  92215. private _valueCache;
  92216. private static _baseCache;
  92217. /**
  92218. * Instantiates an effect.
  92219. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92220. * @param baseName Name of the effect.
  92221. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92222. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92223. * @param samplers List of sampler variables that will be passed to the shader.
  92224. * @param engine Engine to be used to render the effect
  92225. * @param defines Define statements to be added to the shader.
  92226. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92227. * @param onCompiled Callback that will be called when the shader is compiled.
  92228. * @param onError Callback that will be called if an error occurs during shader compilation.
  92229. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92230. */
  92231. 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);
  92232. private _useFinalCode;
  92233. /**
  92234. * Unique key for this effect
  92235. */
  92236. readonly key: string;
  92237. /**
  92238. * If the effect has been compiled and prepared.
  92239. * @returns if the effect is compiled and prepared.
  92240. */
  92241. isReady(): boolean;
  92242. /**
  92243. * The engine the effect was initialized with.
  92244. * @returns the engine.
  92245. */
  92246. getEngine(): Engine;
  92247. /**
  92248. * The pipeline context for this effect
  92249. * @returns the associated pipeline context
  92250. */
  92251. getPipelineContext(): Nullable<IPipelineContext>;
  92252. /**
  92253. * The set of names of attribute variables for the shader.
  92254. * @returns An array of attribute names.
  92255. */
  92256. getAttributesNames(): string[];
  92257. /**
  92258. * Returns the attribute at the given index.
  92259. * @param index The index of the attribute.
  92260. * @returns The location of the attribute.
  92261. */
  92262. getAttributeLocation(index: number): number;
  92263. /**
  92264. * Returns the attribute based on the name of the variable.
  92265. * @param name of the attribute to look up.
  92266. * @returns the attribute location.
  92267. */
  92268. getAttributeLocationByName(name: string): number;
  92269. /**
  92270. * The number of attributes.
  92271. * @returns the numnber of attributes.
  92272. */
  92273. getAttributesCount(): number;
  92274. /**
  92275. * Gets the index of a uniform variable.
  92276. * @param uniformName of the uniform to look up.
  92277. * @returns the index.
  92278. */
  92279. getUniformIndex(uniformName: string): number;
  92280. /**
  92281. * Returns the attribute based on the name of the variable.
  92282. * @param uniformName of the uniform to look up.
  92283. * @returns the location of the uniform.
  92284. */
  92285. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92286. /**
  92287. * Returns an array of sampler variable names
  92288. * @returns The array of sampler variable neames.
  92289. */
  92290. getSamplers(): string[];
  92291. /**
  92292. * The error from the last compilation.
  92293. * @returns the error string.
  92294. */
  92295. getCompilationError(): string;
  92296. /**
  92297. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92298. * @param func The callback to be used.
  92299. */
  92300. executeWhenCompiled(func: (effect: Effect) => void): void;
  92301. private _checkIsReady;
  92302. /** @hidden */
  92303. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92304. /** @hidden */
  92305. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92306. /** @hidden */
  92307. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92308. /**
  92309. * Recompiles the webGL program
  92310. * @param vertexSourceCode The source code for the vertex shader.
  92311. * @param fragmentSourceCode The source code for the fragment shader.
  92312. * @param onCompiled Callback called when completed.
  92313. * @param onError Callback called on error.
  92314. * @hidden
  92315. */
  92316. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92317. /**
  92318. * Prepares the effect
  92319. * @hidden
  92320. */
  92321. _prepareEffect(): void;
  92322. /**
  92323. * Checks if the effect is supported. (Must be called after compilation)
  92324. */
  92325. readonly isSupported: boolean;
  92326. /**
  92327. * Binds a texture to the engine to be used as output of the shader.
  92328. * @param channel Name of the output variable.
  92329. * @param texture Texture to bind.
  92330. * @hidden
  92331. */
  92332. _bindTexture(channel: string, texture: InternalTexture): void;
  92333. /**
  92334. * Sets a texture on the engine to be used in the shader.
  92335. * @param channel Name of the sampler variable.
  92336. * @param texture Texture to set.
  92337. */
  92338. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92339. /**
  92340. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92341. * @param channel Name of the sampler variable.
  92342. * @param texture Texture to set.
  92343. */
  92344. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92345. /**
  92346. * Sets an array of textures on the engine to be used in the shader.
  92347. * @param channel Name of the variable.
  92348. * @param textures Textures to set.
  92349. */
  92350. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92351. /**
  92352. * 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)
  92353. * @param channel Name of the sampler variable.
  92354. * @param postProcess Post process to get the input texture from.
  92355. */
  92356. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92357. /**
  92358. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92359. * 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)
  92360. * @param channel Name of the sampler variable.
  92361. * @param postProcess Post process to get the output texture from.
  92362. */
  92363. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92364. /** @hidden */
  92365. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92366. /** @hidden */
  92367. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92368. /** @hidden */
  92369. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92370. /** @hidden */
  92371. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92372. /**
  92373. * Binds a buffer to a uniform.
  92374. * @param buffer Buffer to bind.
  92375. * @param name Name of the uniform variable to bind to.
  92376. */
  92377. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92378. /**
  92379. * Binds block to a uniform.
  92380. * @param blockName Name of the block to bind.
  92381. * @param index Index to bind.
  92382. */
  92383. bindUniformBlock(blockName: string, index: number): void;
  92384. /**
  92385. * Sets an interger value on a uniform variable.
  92386. * @param uniformName Name of the variable.
  92387. * @param value Value to be set.
  92388. * @returns this effect.
  92389. */
  92390. setInt(uniformName: string, value: number): Effect;
  92391. /**
  92392. * Sets an int array on a uniform variable.
  92393. * @param uniformName Name of the variable.
  92394. * @param array array to be set.
  92395. * @returns this effect.
  92396. */
  92397. setIntArray(uniformName: string, array: Int32Array): Effect;
  92398. /**
  92399. * 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)
  92400. * @param uniformName Name of the variable.
  92401. * @param array array to be set.
  92402. * @returns this effect.
  92403. */
  92404. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92405. /**
  92406. * 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)
  92407. * @param uniformName Name of the variable.
  92408. * @param array array to be set.
  92409. * @returns this effect.
  92410. */
  92411. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92412. /**
  92413. * 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)
  92414. * @param uniformName Name of the variable.
  92415. * @param array array to be set.
  92416. * @returns this effect.
  92417. */
  92418. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92419. /**
  92420. * Sets an float array on a uniform variable.
  92421. * @param uniformName Name of the variable.
  92422. * @param array array to be set.
  92423. * @returns this effect.
  92424. */
  92425. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92426. /**
  92427. * 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)
  92428. * @param uniformName Name of the variable.
  92429. * @param array array to be set.
  92430. * @returns this effect.
  92431. */
  92432. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92433. /**
  92434. * 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)
  92435. * @param uniformName Name of the variable.
  92436. * @param array array to be set.
  92437. * @returns this effect.
  92438. */
  92439. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92440. /**
  92441. * 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)
  92442. * @param uniformName Name of the variable.
  92443. * @param array array to be set.
  92444. * @returns this effect.
  92445. */
  92446. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92447. /**
  92448. * Sets an array on a uniform variable.
  92449. * @param uniformName Name of the variable.
  92450. * @param array array to be set.
  92451. * @returns this effect.
  92452. */
  92453. setArray(uniformName: string, array: number[]): Effect;
  92454. /**
  92455. * 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)
  92456. * @param uniformName Name of the variable.
  92457. * @param array array to be set.
  92458. * @returns this effect.
  92459. */
  92460. setArray2(uniformName: string, array: number[]): Effect;
  92461. /**
  92462. * 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)
  92463. * @param uniformName Name of the variable.
  92464. * @param array array to be set.
  92465. * @returns this effect.
  92466. */
  92467. setArray3(uniformName: string, array: number[]): Effect;
  92468. /**
  92469. * 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)
  92470. * @param uniformName Name of the variable.
  92471. * @param array array to be set.
  92472. * @returns this effect.
  92473. */
  92474. setArray4(uniformName: string, array: number[]): Effect;
  92475. /**
  92476. * Sets matrices on a uniform variable.
  92477. * @param uniformName Name of the variable.
  92478. * @param matrices matrices to be set.
  92479. * @returns this effect.
  92480. */
  92481. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92482. /**
  92483. * Sets matrix on a uniform variable.
  92484. * @param uniformName Name of the variable.
  92485. * @param matrix matrix to be set.
  92486. * @returns this effect.
  92487. */
  92488. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92489. /**
  92490. * 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)
  92491. * @param uniformName Name of the variable.
  92492. * @param matrix matrix to be set.
  92493. * @returns this effect.
  92494. */
  92495. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92496. /**
  92497. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92498. * @param uniformName Name of the variable.
  92499. * @param matrix matrix to be set.
  92500. * @returns this effect.
  92501. */
  92502. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92503. /**
  92504. * Sets a float on a uniform variable.
  92505. * @param uniformName Name of the variable.
  92506. * @param value value to be set.
  92507. * @returns this effect.
  92508. */
  92509. setFloat(uniformName: string, value: number): Effect;
  92510. /**
  92511. * Sets a boolean on a uniform variable.
  92512. * @param uniformName Name of the variable.
  92513. * @param bool value to be set.
  92514. * @returns this effect.
  92515. */
  92516. setBool(uniformName: string, bool: boolean): Effect;
  92517. /**
  92518. * Sets a Vector2 on a uniform variable.
  92519. * @param uniformName Name of the variable.
  92520. * @param vector2 vector2 to be set.
  92521. * @returns this effect.
  92522. */
  92523. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92524. /**
  92525. * Sets a float2 on a uniform variable.
  92526. * @param uniformName Name of the variable.
  92527. * @param x First float in float2.
  92528. * @param y Second float in float2.
  92529. * @returns this effect.
  92530. */
  92531. setFloat2(uniformName: string, x: number, y: number): Effect;
  92532. /**
  92533. * Sets a Vector3 on a uniform variable.
  92534. * @param uniformName Name of the variable.
  92535. * @param vector3 Value to be set.
  92536. * @returns this effect.
  92537. */
  92538. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92539. /**
  92540. * Sets a float3 on a uniform variable.
  92541. * @param uniformName Name of the variable.
  92542. * @param x First float in float3.
  92543. * @param y Second float in float3.
  92544. * @param z Third float in float3.
  92545. * @returns this effect.
  92546. */
  92547. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92548. /**
  92549. * Sets a Vector4 on a uniform variable.
  92550. * @param uniformName Name of the variable.
  92551. * @param vector4 Value to be set.
  92552. * @returns this effect.
  92553. */
  92554. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92555. /**
  92556. * Sets a float4 on a uniform variable.
  92557. * @param uniformName Name of the variable.
  92558. * @param x First float in float4.
  92559. * @param y Second float in float4.
  92560. * @param z Third float in float4.
  92561. * @param w Fourth float in float4.
  92562. * @returns this effect.
  92563. */
  92564. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92565. /**
  92566. * Sets a Color3 on a uniform variable.
  92567. * @param uniformName Name of the variable.
  92568. * @param color3 Value to be set.
  92569. * @returns this effect.
  92570. */
  92571. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92572. /**
  92573. * Sets a Color4 on a uniform variable.
  92574. * @param uniformName Name of the variable.
  92575. * @param color3 Value to be set.
  92576. * @param alpha Alpha value to be set.
  92577. * @returns this effect.
  92578. */
  92579. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92580. /**
  92581. * Sets a Color4 on a uniform variable
  92582. * @param uniformName defines the name of the variable
  92583. * @param color4 defines the value to be set
  92584. * @returns this effect.
  92585. */
  92586. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92587. /** Release all associated resources */
  92588. dispose(): void;
  92589. /**
  92590. * This function will add a new shader to the shader store
  92591. * @param name the name of the shader
  92592. * @param pixelShader optional pixel shader content
  92593. * @param vertexShader optional vertex shader content
  92594. */
  92595. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92596. /**
  92597. * Store of each shader (The can be looked up using effect.key)
  92598. */
  92599. static ShadersStore: {
  92600. [key: string]: string;
  92601. };
  92602. /**
  92603. * Store of each included file for a shader (The can be looked up using effect.key)
  92604. */
  92605. static IncludesShadersStore: {
  92606. [key: string]: string;
  92607. };
  92608. /**
  92609. * Resets the cache of effects.
  92610. */
  92611. static ResetCache(): void;
  92612. }
  92613. }
  92614. declare module BABYLON {
  92615. /**
  92616. * Uniform buffer objects.
  92617. *
  92618. * Handles blocks of uniform on the GPU.
  92619. *
  92620. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92621. *
  92622. * For more information, please refer to :
  92623. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92624. */
  92625. export class UniformBuffer {
  92626. private _engine;
  92627. private _buffer;
  92628. private _data;
  92629. private _bufferData;
  92630. private _dynamic?;
  92631. private _uniformLocations;
  92632. private _uniformSizes;
  92633. private _uniformLocationPointer;
  92634. private _needSync;
  92635. private _noUBO;
  92636. private _currentEffect;
  92637. private static _MAX_UNIFORM_SIZE;
  92638. private static _tempBuffer;
  92639. /**
  92640. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92641. * This is dynamic to allow compat with webgl 1 and 2.
  92642. * You will need to pass the name of the uniform as well as the value.
  92643. */
  92644. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92645. /**
  92646. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92647. * This is dynamic to allow compat with webgl 1 and 2.
  92648. * You will need to pass the name of the uniform as well as the value.
  92649. */
  92650. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92651. /**
  92652. * Lambda to Update a single float in a uniform buffer.
  92653. * This is dynamic to allow compat with webgl 1 and 2.
  92654. * You will need to pass the name of the uniform as well as the value.
  92655. */
  92656. updateFloat: (name: string, x: number) => void;
  92657. /**
  92658. * Lambda to Update a vec2 of float in a uniform buffer.
  92659. * This is dynamic to allow compat with webgl 1 and 2.
  92660. * You will need to pass the name of the uniform as well as the value.
  92661. */
  92662. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92663. /**
  92664. * Lambda to Update a vec3 of float in a uniform buffer.
  92665. * This is dynamic to allow compat with webgl 1 and 2.
  92666. * You will need to pass the name of the uniform as well as the value.
  92667. */
  92668. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92669. /**
  92670. * Lambda to Update a vec4 of float in a uniform buffer.
  92671. * This is dynamic to allow compat with webgl 1 and 2.
  92672. * You will need to pass the name of the uniform as well as the value.
  92673. */
  92674. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92675. /**
  92676. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92677. * This is dynamic to allow compat with webgl 1 and 2.
  92678. * You will need to pass the name of the uniform as well as the value.
  92679. */
  92680. updateMatrix: (name: string, mat: Matrix) => void;
  92681. /**
  92682. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92683. * This is dynamic to allow compat with webgl 1 and 2.
  92684. * You will need to pass the name of the uniform as well as the value.
  92685. */
  92686. updateVector3: (name: string, vector: Vector3) => void;
  92687. /**
  92688. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92689. * This is dynamic to allow compat with webgl 1 and 2.
  92690. * You will need to pass the name of the uniform as well as the value.
  92691. */
  92692. updateVector4: (name: string, vector: Vector4) => void;
  92693. /**
  92694. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92695. * This is dynamic to allow compat with webgl 1 and 2.
  92696. * You will need to pass the name of the uniform as well as the value.
  92697. */
  92698. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92699. /**
  92700. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92701. * This is dynamic to allow compat with webgl 1 and 2.
  92702. * You will need to pass the name of the uniform as well as the value.
  92703. */
  92704. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92705. /**
  92706. * Instantiates a new Uniform buffer objects.
  92707. *
  92708. * Handles blocks of uniform on the GPU.
  92709. *
  92710. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92711. *
  92712. * For more information, please refer to :
  92713. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92714. * @param engine Define the engine the buffer is associated with
  92715. * @param data Define the data contained in the buffer
  92716. * @param dynamic Define if the buffer is updatable
  92717. */
  92718. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92719. /**
  92720. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92721. * or just falling back on setUniformXXX calls.
  92722. */
  92723. readonly useUbo: boolean;
  92724. /**
  92725. * Indicates if the WebGL underlying uniform buffer is in sync
  92726. * with the javascript cache data.
  92727. */
  92728. readonly isSync: boolean;
  92729. /**
  92730. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92731. * Also, a dynamic UniformBuffer will disable cache verification and always
  92732. * update the underlying WebGL uniform buffer to the GPU.
  92733. * @returns if Dynamic, otherwise false
  92734. */
  92735. isDynamic(): boolean;
  92736. /**
  92737. * The data cache on JS side.
  92738. * @returns the underlying data as a float array
  92739. */
  92740. getData(): Float32Array;
  92741. /**
  92742. * The underlying WebGL Uniform buffer.
  92743. * @returns the webgl buffer
  92744. */
  92745. getBuffer(): Nullable<DataBuffer>;
  92746. /**
  92747. * std140 layout specifies how to align data within an UBO structure.
  92748. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92749. * for specs.
  92750. */
  92751. private _fillAlignment;
  92752. /**
  92753. * Adds an uniform in the buffer.
  92754. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92755. * for the layout to be correct !
  92756. * @param name Name of the uniform, as used in the uniform block in the shader.
  92757. * @param size Data size, or data directly.
  92758. */
  92759. addUniform(name: string, size: number | number[]): void;
  92760. /**
  92761. * Adds a Matrix 4x4 to the uniform buffer.
  92762. * @param name Name of the uniform, as used in the uniform block in the shader.
  92763. * @param mat A 4x4 matrix.
  92764. */
  92765. addMatrix(name: string, mat: Matrix): void;
  92766. /**
  92767. * Adds a vec2 to the uniform buffer.
  92768. * @param name Name of the uniform, as used in the uniform block in the shader.
  92769. * @param x Define the x component value of the vec2
  92770. * @param y Define the y component value of the vec2
  92771. */
  92772. addFloat2(name: string, x: number, y: number): void;
  92773. /**
  92774. * Adds a vec3 to the uniform buffer.
  92775. * @param name Name of the uniform, as used in the uniform block in the shader.
  92776. * @param x Define the x component value of the vec3
  92777. * @param y Define the y component value of the vec3
  92778. * @param z Define the z component value of the vec3
  92779. */
  92780. addFloat3(name: string, x: number, y: number, z: number): void;
  92781. /**
  92782. * Adds a vec3 to the uniform buffer.
  92783. * @param name Name of the uniform, as used in the uniform block in the shader.
  92784. * @param color Define the vec3 from a Color
  92785. */
  92786. addColor3(name: string, color: Color3): void;
  92787. /**
  92788. * Adds a vec4 to the uniform buffer.
  92789. * @param name Name of the uniform, as used in the uniform block in the shader.
  92790. * @param color Define the rgb components from a Color
  92791. * @param alpha Define the a component of the vec4
  92792. */
  92793. addColor4(name: string, color: Color3, alpha: number): void;
  92794. /**
  92795. * Adds a vec3 to the uniform buffer.
  92796. * @param name Name of the uniform, as used in the uniform block in the shader.
  92797. * @param vector Define the vec3 components from a Vector
  92798. */
  92799. addVector3(name: string, vector: Vector3): void;
  92800. /**
  92801. * Adds a Matrix 3x3 to the uniform buffer.
  92802. * @param name Name of the uniform, as used in the uniform block in the shader.
  92803. */
  92804. addMatrix3x3(name: string): void;
  92805. /**
  92806. * Adds a Matrix 2x2 to the uniform buffer.
  92807. * @param name Name of the uniform, as used in the uniform block in the shader.
  92808. */
  92809. addMatrix2x2(name: string): void;
  92810. /**
  92811. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92812. */
  92813. create(): void;
  92814. /** @hidden */
  92815. _rebuild(): void;
  92816. /**
  92817. * Updates the WebGL Uniform Buffer on the GPU.
  92818. * If the `dynamic` flag is set to true, no cache comparison is done.
  92819. * Otherwise, the buffer will be updated only if the cache differs.
  92820. */
  92821. update(): void;
  92822. /**
  92823. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92824. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92825. * @param data Define the flattened data
  92826. * @param size Define the size of the data.
  92827. */
  92828. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92829. private _updateMatrix3x3ForUniform;
  92830. private _updateMatrix3x3ForEffect;
  92831. private _updateMatrix2x2ForEffect;
  92832. private _updateMatrix2x2ForUniform;
  92833. private _updateFloatForEffect;
  92834. private _updateFloatForUniform;
  92835. private _updateFloat2ForEffect;
  92836. private _updateFloat2ForUniform;
  92837. private _updateFloat3ForEffect;
  92838. private _updateFloat3ForUniform;
  92839. private _updateFloat4ForEffect;
  92840. private _updateFloat4ForUniform;
  92841. private _updateMatrixForEffect;
  92842. private _updateMatrixForUniform;
  92843. private _updateVector3ForEffect;
  92844. private _updateVector3ForUniform;
  92845. private _updateVector4ForEffect;
  92846. private _updateVector4ForUniform;
  92847. private _updateColor3ForEffect;
  92848. private _updateColor3ForUniform;
  92849. private _updateColor4ForEffect;
  92850. private _updateColor4ForUniform;
  92851. /**
  92852. * Sets a sampler uniform on the effect.
  92853. * @param name Define the name of the sampler.
  92854. * @param texture Define the texture to set in the sampler
  92855. */
  92856. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92857. /**
  92858. * Directly updates the value of the uniform in the cache AND on the GPU.
  92859. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92860. * @param data Define the flattened data
  92861. */
  92862. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92863. /**
  92864. * Binds this uniform buffer to an effect.
  92865. * @param effect Define the effect to bind the buffer to
  92866. * @param name Name of the uniform block in the shader.
  92867. */
  92868. bindToEffect(effect: Effect, name: string): void;
  92869. /**
  92870. * Disposes the uniform buffer.
  92871. */
  92872. dispose(): void;
  92873. }
  92874. }
  92875. declare module BABYLON {
  92876. /**
  92877. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92879. */
  92880. export class Analyser {
  92881. /**
  92882. * Gets or sets the smoothing
  92883. * @ignorenaming
  92884. */
  92885. SMOOTHING: number;
  92886. /**
  92887. * Gets or sets the FFT table size
  92888. * @ignorenaming
  92889. */
  92890. FFT_SIZE: number;
  92891. /**
  92892. * Gets or sets the bar graph amplitude
  92893. * @ignorenaming
  92894. */
  92895. BARGRAPHAMPLITUDE: number;
  92896. /**
  92897. * Gets or sets the position of the debug canvas
  92898. * @ignorenaming
  92899. */
  92900. DEBUGCANVASPOS: {
  92901. x: number;
  92902. y: number;
  92903. };
  92904. /**
  92905. * Gets or sets the debug canvas size
  92906. * @ignorenaming
  92907. */
  92908. DEBUGCANVASSIZE: {
  92909. width: number;
  92910. height: number;
  92911. };
  92912. private _byteFreqs;
  92913. private _byteTime;
  92914. private _floatFreqs;
  92915. private _webAudioAnalyser;
  92916. private _debugCanvas;
  92917. private _debugCanvasContext;
  92918. private _scene;
  92919. private _registerFunc;
  92920. private _audioEngine;
  92921. /**
  92922. * Creates a new analyser
  92923. * @param scene defines hosting scene
  92924. */
  92925. constructor(scene: Scene);
  92926. /**
  92927. * Get the number of data values you will have to play with for the visualization
  92928. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92929. * @returns a number
  92930. */
  92931. getFrequencyBinCount(): number;
  92932. /**
  92933. * Gets the current frequency data as a byte array
  92934. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92935. * @returns a Uint8Array
  92936. */
  92937. getByteFrequencyData(): Uint8Array;
  92938. /**
  92939. * Gets the current waveform as a byte array
  92940. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92941. * @returns a Uint8Array
  92942. */
  92943. getByteTimeDomainData(): Uint8Array;
  92944. /**
  92945. * Gets the current frequency data as a float array
  92946. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92947. * @returns a Float32Array
  92948. */
  92949. getFloatFrequencyData(): Float32Array;
  92950. /**
  92951. * Renders the debug canvas
  92952. */
  92953. drawDebugCanvas(): void;
  92954. /**
  92955. * Stops rendering the debug canvas and removes it
  92956. */
  92957. stopDebugCanvas(): void;
  92958. /**
  92959. * Connects two audio nodes
  92960. * @param inputAudioNode defines first node to connect
  92961. * @param outputAudioNode defines second node to connect
  92962. */
  92963. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92964. /**
  92965. * Releases all associated resources
  92966. */
  92967. dispose(): void;
  92968. }
  92969. }
  92970. declare module BABYLON {
  92971. /**
  92972. * This represents an audio engine and it is responsible
  92973. * to play, synchronize and analyse sounds throughout the application.
  92974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92975. */
  92976. export interface IAudioEngine extends IDisposable {
  92977. /**
  92978. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92979. */
  92980. readonly canUseWebAudio: boolean;
  92981. /**
  92982. * Gets the current AudioContext if available.
  92983. */
  92984. readonly audioContext: Nullable<AudioContext>;
  92985. /**
  92986. * The master gain node defines the global audio volume of your audio engine.
  92987. */
  92988. readonly masterGain: GainNode;
  92989. /**
  92990. * Gets whether or not mp3 are supported by your browser.
  92991. */
  92992. readonly isMP3supported: boolean;
  92993. /**
  92994. * Gets whether or not ogg are supported by your browser.
  92995. */
  92996. readonly isOGGsupported: boolean;
  92997. /**
  92998. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92999. * @ignoreNaming
  93000. */
  93001. WarnedWebAudioUnsupported: boolean;
  93002. /**
  93003. * Defines if the audio engine relies on a custom unlocked button.
  93004. * In this case, the embedded button will not be displayed.
  93005. */
  93006. useCustomUnlockedButton: boolean;
  93007. /**
  93008. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93009. */
  93010. readonly unlocked: boolean;
  93011. /**
  93012. * Event raised when audio has been unlocked on the browser.
  93013. */
  93014. onAudioUnlockedObservable: Observable<AudioEngine>;
  93015. /**
  93016. * Event raised when audio has been locked on the browser.
  93017. */
  93018. onAudioLockedObservable: Observable<AudioEngine>;
  93019. /**
  93020. * Flags the audio engine in Locked state.
  93021. * This happens due to new browser policies preventing audio to autoplay.
  93022. */
  93023. lock(): void;
  93024. /**
  93025. * Unlocks the audio engine once a user action has been done on the dom.
  93026. * This is helpful to resume play once browser policies have been satisfied.
  93027. */
  93028. unlock(): void;
  93029. }
  93030. /**
  93031. * This represents the default audio engine used in babylon.
  93032. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93034. */
  93035. export class AudioEngine implements IAudioEngine {
  93036. private _audioContext;
  93037. private _audioContextInitialized;
  93038. private _muteButton;
  93039. private _hostElement;
  93040. /**
  93041. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93042. */
  93043. canUseWebAudio: boolean;
  93044. /**
  93045. * The master gain node defines the global audio volume of your audio engine.
  93046. */
  93047. masterGain: GainNode;
  93048. /**
  93049. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93050. * @ignoreNaming
  93051. */
  93052. WarnedWebAudioUnsupported: boolean;
  93053. /**
  93054. * Gets whether or not mp3 are supported by your browser.
  93055. */
  93056. isMP3supported: boolean;
  93057. /**
  93058. * Gets whether or not ogg are supported by your browser.
  93059. */
  93060. isOGGsupported: boolean;
  93061. /**
  93062. * Gets whether audio has been unlocked on the device.
  93063. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93064. * a user interaction has happened.
  93065. */
  93066. unlocked: boolean;
  93067. /**
  93068. * Defines if the audio engine relies on a custom unlocked button.
  93069. * In this case, the embedded button will not be displayed.
  93070. */
  93071. useCustomUnlockedButton: boolean;
  93072. /**
  93073. * Event raised when audio has been unlocked on the browser.
  93074. */
  93075. onAudioUnlockedObservable: Observable<AudioEngine>;
  93076. /**
  93077. * Event raised when audio has been locked on the browser.
  93078. */
  93079. onAudioLockedObservable: Observable<AudioEngine>;
  93080. /**
  93081. * Gets the current AudioContext if available.
  93082. */
  93083. readonly audioContext: Nullable<AudioContext>;
  93084. private _connectedAnalyser;
  93085. /**
  93086. * Instantiates a new audio engine.
  93087. *
  93088. * There should be only one per page as some browsers restrict the number
  93089. * of audio contexts you can create.
  93090. * @param hostElement defines the host element where to display the mute icon if necessary
  93091. */
  93092. constructor(hostElement?: Nullable<HTMLElement>);
  93093. /**
  93094. * Flags the audio engine in Locked state.
  93095. * This happens due to new browser policies preventing audio to autoplay.
  93096. */
  93097. lock(): void;
  93098. /**
  93099. * Unlocks the audio engine once a user action has been done on the dom.
  93100. * This is helpful to resume play once browser policies have been satisfied.
  93101. */
  93102. unlock(): void;
  93103. private _resumeAudioContext;
  93104. private _initializeAudioContext;
  93105. private _tryToRun;
  93106. private _triggerRunningState;
  93107. private _triggerSuspendedState;
  93108. private _displayMuteButton;
  93109. private _moveButtonToTopLeft;
  93110. private _onResize;
  93111. private _hideMuteButton;
  93112. /**
  93113. * Destroy and release the resources associated with the audio ccontext.
  93114. */
  93115. dispose(): void;
  93116. /**
  93117. * Gets the global volume sets on the master gain.
  93118. * @returns the global volume if set or -1 otherwise
  93119. */
  93120. getGlobalVolume(): number;
  93121. /**
  93122. * Sets the global volume of your experience (sets on the master gain).
  93123. * @param newVolume Defines the new global volume of the application
  93124. */
  93125. setGlobalVolume(newVolume: number): void;
  93126. /**
  93127. * Connect the audio engine to an audio analyser allowing some amazing
  93128. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93130. * @param analyser The analyser to connect to the engine
  93131. */
  93132. connectToAnalyser(analyser: Analyser): void;
  93133. }
  93134. }
  93135. declare module BABYLON {
  93136. /**
  93137. * Interface used to present a loading screen while loading a scene
  93138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93139. */
  93140. export interface ILoadingScreen {
  93141. /**
  93142. * Function called to display the loading screen
  93143. */
  93144. displayLoadingUI: () => void;
  93145. /**
  93146. * Function called to hide the loading screen
  93147. */
  93148. hideLoadingUI: () => void;
  93149. /**
  93150. * Gets or sets the color to use for the background
  93151. */
  93152. loadingUIBackgroundColor: string;
  93153. /**
  93154. * Gets or sets the text to display while loading
  93155. */
  93156. loadingUIText: string;
  93157. }
  93158. /**
  93159. * Class used for the default loading screen
  93160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93161. */
  93162. export class DefaultLoadingScreen implements ILoadingScreen {
  93163. private _renderingCanvas;
  93164. private _loadingText;
  93165. private _loadingDivBackgroundColor;
  93166. private _loadingDiv;
  93167. private _loadingTextDiv;
  93168. /** Gets or sets the logo url to use for the default loading screen */
  93169. static DefaultLogoUrl: string;
  93170. /** Gets or sets the spinner url to use for the default loading screen */
  93171. static DefaultSpinnerUrl: string;
  93172. /**
  93173. * Creates a new default loading screen
  93174. * @param _renderingCanvas defines the canvas used to render the scene
  93175. * @param _loadingText defines the default text to display
  93176. * @param _loadingDivBackgroundColor defines the default background color
  93177. */
  93178. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93179. /**
  93180. * Function called to display the loading screen
  93181. */
  93182. displayLoadingUI(): void;
  93183. /**
  93184. * Function called to hide the loading screen
  93185. */
  93186. hideLoadingUI(): void;
  93187. /**
  93188. * Gets or sets the text to display while loading
  93189. */
  93190. loadingUIText: string;
  93191. /**
  93192. * Gets or sets the color to use for the background
  93193. */
  93194. loadingUIBackgroundColor: string;
  93195. private _resizeLoadingUI;
  93196. }
  93197. }
  93198. declare module BABYLON {
  93199. /** @hidden */
  93200. export class WebGLPipelineContext implements IPipelineContext {
  93201. engine: Engine;
  93202. program: Nullable<WebGLProgram>;
  93203. context?: WebGLRenderingContext;
  93204. vertexShader?: WebGLShader;
  93205. fragmentShader?: WebGLShader;
  93206. isParallelCompiled: boolean;
  93207. onCompiled?: () => void;
  93208. transformFeedback?: WebGLTransformFeedback | null;
  93209. readonly isAsync: boolean;
  93210. readonly isReady: boolean;
  93211. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93212. }
  93213. }
  93214. declare module BABYLON {
  93215. /** @hidden */
  93216. export class WebGLDataBuffer extends DataBuffer {
  93217. private _buffer;
  93218. constructor(resource: WebGLBuffer);
  93219. readonly underlyingResource: any;
  93220. }
  93221. }
  93222. declare module BABYLON {
  93223. /** @hidden */
  93224. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93225. attributeProcessor(attribute: string): string;
  93226. varyingProcessor(varying: string, isFragment: boolean): string;
  93227. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93228. }
  93229. }
  93230. declare module BABYLON {
  93231. /**
  93232. * This class is used to track a performance counter which is number based.
  93233. * The user has access to many properties which give statistics of different nature.
  93234. *
  93235. * The implementer can track two kinds of Performance Counter: time and count.
  93236. * 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.
  93237. * 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.
  93238. */
  93239. export class PerfCounter {
  93240. /**
  93241. * Gets or sets a global boolean to turn on and off all the counters
  93242. */
  93243. static Enabled: boolean;
  93244. /**
  93245. * Returns the smallest value ever
  93246. */
  93247. readonly min: number;
  93248. /**
  93249. * Returns the biggest value ever
  93250. */
  93251. readonly max: number;
  93252. /**
  93253. * Returns the average value since the performance counter is running
  93254. */
  93255. readonly average: number;
  93256. /**
  93257. * Returns the average value of the last second the counter was monitored
  93258. */
  93259. readonly lastSecAverage: number;
  93260. /**
  93261. * Returns the current value
  93262. */
  93263. readonly current: number;
  93264. /**
  93265. * Gets the accumulated total
  93266. */
  93267. readonly total: number;
  93268. /**
  93269. * Gets the total value count
  93270. */
  93271. readonly count: number;
  93272. /**
  93273. * Creates a new counter
  93274. */
  93275. constructor();
  93276. /**
  93277. * Call this method to start monitoring a new frame.
  93278. * 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.
  93279. */
  93280. fetchNewFrame(): void;
  93281. /**
  93282. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93283. * @param newCount the count value to add to the monitored count
  93284. * @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.
  93285. */
  93286. addCount(newCount: number, fetchResult: boolean): void;
  93287. /**
  93288. * Start monitoring this performance counter
  93289. */
  93290. beginMonitoring(): void;
  93291. /**
  93292. * Compute the time lapsed since the previous beginMonitoring() call.
  93293. * @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
  93294. */
  93295. endMonitoring(newFrame?: boolean): void;
  93296. private _fetchResult;
  93297. private _startMonitoringTime;
  93298. private _min;
  93299. private _max;
  93300. private _average;
  93301. private _current;
  93302. private _totalValueCount;
  93303. private _totalAccumulated;
  93304. private _lastSecAverage;
  93305. private _lastSecAccumulated;
  93306. private _lastSecTime;
  93307. private _lastSecValueCount;
  93308. }
  93309. }
  93310. declare module BABYLON {
  93311. /**
  93312. * Interface for any object that can request an animation frame
  93313. */
  93314. export interface ICustomAnimationFrameRequester {
  93315. /**
  93316. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93317. */
  93318. renderFunction?: Function;
  93319. /**
  93320. * Called to request the next frame to render to
  93321. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93322. */
  93323. requestAnimationFrame: Function;
  93324. /**
  93325. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93326. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93327. */
  93328. requestID?: number;
  93329. }
  93330. }
  93331. declare module BABYLON {
  93332. /**
  93333. * Settings for finer control over video usage
  93334. */
  93335. export interface VideoTextureSettings {
  93336. /**
  93337. * Applies `autoplay` to video, if specified
  93338. */
  93339. autoPlay?: boolean;
  93340. /**
  93341. * Applies `loop` to video, if specified
  93342. */
  93343. loop?: boolean;
  93344. /**
  93345. * Automatically updates internal texture from video at every frame in the render loop
  93346. */
  93347. autoUpdateTexture: boolean;
  93348. /**
  93349. * Image src displayed during the video loading or until the user interacts with the video.
  93350. */
  93351. poster?: string;
  93352. }
  93353. /**
  93354. * If you want to display a video in your scene, this is the special texture for that.
  93355. * This special texture works similar to other textures, with the exception of a few parameters.
  93356. * @see https://doc.babylonjs.com/how_to/video_texture
  93357. */
  93358. export class VideoTexture extends Texture {
  93359. /**
  93360. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93361. */
  93362. readonly autoUpdateTexture: boolean;
  93363. /**
  93364. * The video instance used by the texture internally
  93365. */
  93366. readonly video: HTMLVideoElement;
  93367. private _onUserActionRequestedObservable;
  93368. /**
  93369. * Event triggerd when a dom action is required by the user to play the video.
  93370. * This happens due to recent changes in browser policies preventing video to auto start.
  93371. */
  93372. readonly onUserActionRequestedObservable: Observable<Texture>;
  93373. private _generateMipMaps;
  93374. private _engine;
  93375. private _stillImageCaptured;
  93376. private _displayingPosterTexture;
  93377. private _settings;
  93378. private _createInternalTextureOnEvent;
  93379. /**
  93380. * Creates a video texture.
  93381. * If you want to display a video in your scene, this is the special texture for that.
  93382. * This special texture works similar to other textures, with the exception of a few parameters.
  93383. * @see https://doc.babylonjs.com/how_to/video_texture
  93384. * @param name optional name, will detect from video source, if not defined
  93385. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93386. * @param scene is obviously the current scene.
  93387. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93388. * @param invertY is false by default but can be used to invert video on Y axis
  93389. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93390. * @param settings allows finer control over video usage
  93391. */
  93392. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93393. private _getName;
  93394. private _getVideo;
  93395. private _createInternalTexture;
  93396. private reset;
  93397. /**
  93398. * @hidden Internal method to initiate `update`.
  93399. */
  93400. _rebuild(): void;
  93401. /**
  93402. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93403. */
  93404. update(): void;
  93405. /**
  93406. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93407. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93408. */
  93409. updateTexture(isVisible: boolean): void;
  93410. protected _updateInternalTexture: () => void;
  93411. /**
  93412. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93413. * @param url New url.
  93414. */
  93415. updateURL(url: string): void;
  93416. /**
  93417. * Dispose the texture and release its associated resources.
  93418. */
  93419. dispose(): void;
  93420. /**
  93421. * Creates a video texture straight from a stream.
  93422. * @param scene Define the scene the texture should be created in
  93423. * @param stream Define the stream the texture should be created from
  93424. * @returns The created video texture as a promise
  93425. */
  93426. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93427. /**
  93428. * Creates a video texture straight from your WebCam video feed.
  93429. * @param scene Define the scene the texture should be created in
  93430. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93431. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93432. * @returns The created video texture as a promise
  93433. */
  93434. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93435. minWidth: number;
  93436. maxWidth: number;
  93437. minHeight: number;
  93438. maxHeight: number;
  93439. deviceId: string;
  93440. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93441. /**
  93442. * Creates a video texture straight from your WebCam video feed.
  93443. * @param scene Define the scene the texture should be created in
  93444. * @param onReady Define a callback to triggered once the texture will be ready
  93445. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93446. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93447. */
  93448. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93449. minWidth: number;
  93450. maxWidth: number;
  93451. minHeight: number;
  93452. maxHeight: number;
  93453. deviceId: string;
  93454. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93455. }
  93456. }
  93457. declare module BABYLON {
  93458. /**
  93459. * Defines the interface used by objects containing a viewport (like a camera)
  93460. */
  93461. interface IViewportOwnerLike {
  93462. /**
  93463. * Gets or sets the viewport
  93464. */
  93465. viewport: IViewportLike;
  93466. }
  93467. /**
  93468. * Interface for attribute information associated with buffer instanciation
  93469. */
  93470. export class InstancingAttributeInfo {
  93471. /**
  93472. * Index/offset of the attribute in the vertex shader
  93473. */
  93474. index: number;
  93475. /**
  93476. * size of the attribute, 1, 2, 3 or 4
  93477. */
  93478. attributeSize: number;
  93479. /**
  93480. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93481. * default is FLOAT
  93482. */
  93483. attribyteType: number;
  93484. /**
  93485. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93486. */
  93487. normalized: boolean;
  93488. /**
  93489. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93490. */
  93491. offset: number;
  93492. /**
  93493. * Name of the GLSL attribute, for debugging purpose only
  93494. */
  93495. attributeName: string;
  93496. }
  93497. /**
  93498. * Define options used to create a depth texture
  93499. */
  93500. export class DepthTextureCreationOptions {
  93501. /** Specifies whether or not a stencil should be allocated in the texture */
  93502. generateStencil?: boolean;
  93503. /** Specifies whether or not bilinear filtering is enable on the texture */
  93504. bilinearFiltering?: boolean;
  93505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93506. comparisonFunction?: number;
  93507. /** Specifies if the created texture is a cube texture */
  93508. isCube?: boolean;
  93509. }
  93510. /**
  93511. * Class used to describe the capabilities of the engine relatively to the current browser
  93512. */
  93513. export class EngineCapabilities {
  93514. /** Maximum textures units per fragment shader */
  93515. maxTexturesImageUnits: number;
  93516. /** Maximum texture units per vertex shader */
  93517. maxVertexTextureImageUnits: number;
  93518. /** Maximum textures units in the entire pipeline */
  93519. maxCombinedTexturesImageUnits: number;
  93520. /** Maximum texture size */
  93521. maxTextureSize: number;
  93522. /** Maximum cube texture size */
  93523. maxCubemapTextureSize: number;
  93524. /** Maximum render texture size */
  93525. maxRenderTextureSize: number;
  93526. /** Maximum number of vertex attributes */
  93527. maxVertexAttribs: number;
  93528. /** Maximum number of varyings */
  93529. maxVaryingVectors: number;
  93530. /** Maximum number of uniforms per vertex shader */
  93531. maxVertexUniformVectors: number;
  93532. /** Maximum number of uniforms per fragment shader */
  93533. maxFragmentUniformVectors: number;
  93534. /** Defines if standard derivates (dx/dy) are supported */
  93535. standardDerivatives: boolean;
  93536. /** Defines if s3tc texture compression is supported */
  93537. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93538. /** Defines if pvrtc texture compression is supported */
  93539. pvrtc: any;
  93540. /** Defines if etc1 texture compression is supported */
  93541. etc1: any;
  93542. /** Defines if etc2 texture compression is supported */
  93543. etc2: any;
  93544. /** Defines if astc texture compression is supported */
  93545. astc: any;
  93546. /** Defines if float textures are supported */
  93547. textureFloat: boolean;
  93548. /** Defines if vertex array objects are supported */
  93549. vertexArrayObject: boolean;
  93550. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93551. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93552. /** Gets the maximum level of anisotropy supported */
  93553. maxAnisotropy: number;
  93554. /** Defines if instancing is supported */
  93555. instancedArrays: boolean;
  93556. /** Defines if 32 bits indices are supported */
  93557. uintIndices: boolean;
  93558. /** Defines if high precision shaders are supported */
  93559. highPrecisionShaderSupported: boolean;
  93560. /** Defines if depth reading in the fragment shader is supported */
  93561. fragmentDepthSupported: boolean;
  93562. /** Defines if float texture linear filtering is supported*/
  93563. textureFloatLinearFiltering: boolean;
  93564. /** Defines if rendering to float textures is supported */
  93565. textureFloatRender: boolean;
  93566. /** Defines if half float textures are supported*/
  93567. textureHalfFloat: boolean;
  93568. /** Defines if half float texture linear filtering is supported*/
  93569. textureHalfFloatLinearFiltering: boolean;
  93570. /** Defines if rendering to half float textures is supported */
  93571. textureHalfFloatRender: boolean;
  93572. /** Defines if textureLOD shader command is supported */
  93573. textureLOD: boolean;
  93574. /** Defines if draw buffers extension is supported */
  93575. drawBuffersExtension: boolean;
  93576. /** Defines if depth textures are supported */
  93577. depthTextureExtension: boolean;
  93578. /** Defines if float color buffer are supported */
  93579. colorBufferFloat: boolean;
  93580. /** Gets disjoint timer query extension (null if not supported) */
  93581. timerQuery: EXT_disjoint_timer_query;
  93582. /** Defines if timestamp can be used with timer query */
  93583. canUseTimestampForTimerQuery: boolean;
  93584. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93585. multiview: any;
  93586. /** Function used to let the system compiles shaders in background */
  93587. parallelShaderCompile: {
  93588. COMPLETION_STATUS_KHR: number;
  93589. };
  93590. /** Max number of texture samples for MSAA */
  93591. maxMSAASamples: number;
  93592. }
  93593. /** Interface defining initialization parameters for Engine class */
  93594. export interface EngineOptions extends WebGLContextAttributes {
  93595. /**
  93596. * Defines if the engine should no exceed a specified device ratio
  93597. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93598. */
  93599. limitDeviceRatio?: number;
  93600. /**
  93601. * Defines if webvr should be enabled automatically
  93602. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93603. */
  93604. autoEnableWebVR?: boolean;
  93605. /**
  93606. * Defines if webgl2 should be turned off even if supported
  93607. * @see http://doc.babylonjs.com/features/webgl2
  93608. */
  93609. disableWebGL2Support?: boolean;
  93610. /**
  93611. * Defines if webaudio should be initialized as well
  93612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93613. */
  93614. audioEngine?: boolean;
  93615. /**
  93616. * Defines if animations should run using a deterministic lock step
  93617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93618. */
  93619. deterministicLockstep?: boolean;
  93620. /** Defines the maximum steps to use with deterministic lock step mode */
  93621. lockstepMaxSteps?: number;
  93622. /**
  93623. * Defines that engine should ignore context lost events
  93624. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93625. */
  93626. doNotHandleContextLost?: boolean;
  93627. /**
  93628. * Defines that engine should ignore modifying touch action attribute and style
  93629. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93630. */
  93631. doNotHandleTouchAction?: boolean;
  93632. /**
  93633. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93634. */
  93635. useHighPrecisionFloats?: boolean;
  93636. }
  93637. /**
  93638. * Defines the interface used by display changed events
  93639. */
  93640. export interface IDisplayChangedEventArgs {
  93641. /** Gets the vrDisplay object (if any) */
  93642. vrDisplay: Nullable<any>;
  93643. /** Gets a boolean indicating if webVR is supported */
  93644. vrSupported: boolean;
  93645. }
  93646. /**
  93647. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93648. */
  93649. export class Engine {
  93650. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93651. static ExceptionList: ({
  93652. key: string;
  93653. capture: string;
  93654. captureConstraint: number;
  93655. targets: string[];
  93656. } | {
  93657. key: string;
  93658. capture: null;
  93659. captureConstraint: null;
  93660. targets: string[];
  93661. })[];
  93662. /** Gets the list of created engines */
  93663. static readonly Instances: Engine[];
  93664. /**
  93665. * Gets the latest created engine
  93666. */
  93667. static readonly LastCreatedEngine: Nullable<Engine>;
  93668. /**
  93669. * Gets the latest created scene
  93670. */
  93671. static readonly LastCreatedScene: Nullable<Scene>;
  93672. /**
  93673. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93674. * @param flag defines which part of the materials must be marked as dirty
  93675. * @param predicate defines a predicate used to filter which materials should be affected
  93676. */
  93677. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93678. /** @hidden */
  93679. static _TextureLoaders: IInternalTextureLoader[];
  93680. /** Defines that alpha blending is disabled */
  93681. static readonly ALPHA_DISABLE: number;
  93682. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93683. static readonly ALPHA_ADD: number;
  93684. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93685. static readonly ALPHA_COMBINE: number;
  93686. /** Defines that alpha blending to DEST - SRC * DEST */
  93687. static readonly ALPHA_SUBTRACT: number;
  93688. /** Defines that alpha blending to SRC * DEST */
  93689. static readonly ALPHA_MULTIPLY: number;
  93690. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93691. static readonly ALPHA_MAXIMIZED: number;
  93692. /** Defines that alpha blending to SRC + DEST */
  93693. static readonly ALPHA_ONEONE: number;
  93694. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93695. static readonly ALPHA_PREMULTIPLIED: number;
  93696. /**
  93697. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93698. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93699. */
  93700. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93701. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93702. static readonly ALPHA_INTERPOLATE: number;
  93703. /**
  93704. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93705. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93706. */
  93707. static readonly ALPHA_SCREENMODE: number;
  93708. /** Defines that the ressource is not delayed*/
  93709. static readonly DELAYLOADSTATE_NONE: number;
  93710. /** Defines that the ressource was successfully delay loaded */
  93711. static readonly DELAYLOADSTATE_LOADED: number;
  93712. /** Defines that the ressource is currently delay loading */
  93713. static readonly DELAYLOADSTATE_LOADING: number;
  93714. /** Defines that the ressource is delayed and has not started loading */
  93715. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93716. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93717. static readonly NEVER: number;
  93718. /** 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 */
  93719. static readonly ALWAYS: number;
  93720. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93721. static readonly LESS: number;
  93722. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93723. static readonly EQUAL: number;
  93724. /** 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 */
  93725. static readonly LEQUAL: number;
  93726. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93727. static readonly GREATER: number;
  93728. /** 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 */
  93729. static readonly GEQUAL: number;
  93730. /** 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 */
  93731. static readonly NOTEQUAL: number;
  93732. /** Passed to stencilOperation to specify that stencil value must be kept */
  93733. static readonly KEEP: number;
  93734. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93735. static readonly REPLACE: number;
  93736. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93737. static readonly INCR: number;
  93738. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93739. static readonly DECR: number;
  93740. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93741. static readonly INVERT: number;
  93742. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93743. static readonly INCR_WRAP: number;
  93744. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93745. static readonly DECR_WRAP: number;
  93746. /** Texture is not repeating outside of 0..1 UVs */
  93747. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93748. /** Texture is repeating outside of 0..1 UVs */
  93749. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93750. /** Texture is repeating and mirrored */
  93751. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93752. /** ALPHA */
  93753. static readonly TEXTUREFORMAT_ALPHA: number;
  93754. /** LUMINANCE */
  93755. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93756. /** LUMINANCE_ALPHA */
  93757. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  93758. /** RGB */
  93759. static readonly TEXTUREFORMAT_RGB: number;
  93760. /** RGBA */
  93761. static readonly TEXTUREFORMAT_RGBA: number;
  93762. /** RED */
  93763. static readonly TEXTUREFORMAT_RED: number;
  93764. /** RED (2nd reference) */
  93765. static readonly TEXTUREFORMAT_R: number;
  93766. /** RG */
  93767. static readonly TEXTUREFORMAT_RG: number;
  93768. /** RED_INTEGER */
  93769. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  93770. /** RED_INTEGER (2nd reference) */
  93771. static readonly TEXTUREFORMAT_R_INTEGER: number;
  93772. /** RG_INTEGER */
  93773. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  93774. /** RGB_INTEGER */
  93775. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  93776. /** RGBA_INTEGER */
  93777. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  93778. /** UNSIGNED_BYTE */
  93779. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  93780. /** UNSIGNED_BYTE (2nd reference) */
  93781. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  93782. /** FLOAT */
  93783. static readonly TEXTURETYPE_FLOAT: number;
  93784. /** HALF_FLOAT */
  93785. static readonly TEXTURETYPE_HALF_FLOAT: number;
  93786. /** BYTE */
  93787. static readonly TEXTURETYPE_BYTE: number;
  93788. /** SHORT */
  93789. static readonly TEXTURETYPE_SHORT: number;
  93790. /** UNSIGNED_SHORT */
  93791. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  93792. /** INT */
  93793. static readonly TEXTURETYPE_INT: number;
  93794. /** UNSIGNED_INT */
  93795. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  93796. /** UNSIGNED_SHORT_4_4_4_4 */
  93797. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  93798. /** UNSIGNED_SHORT_5_5_5_1 */
  93799. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  93800. /** UNSIGNED_SHORT_5_6_5 */
  93801. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  93802. /** UNSIGNED_INT_2_10_10_10_REV */
  93803. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  93804. /** UNSIGNED_INT_24_8 */
  93805. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  93806. /** UNSIGNED_INT_10F_11F_11F_REV */
  93807. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  93808. /** UNSIGNED_INT_5_9_9_9_REV */
  93809. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  93810. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  93811. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93812. /** nearest is mag = nearest and min = nearest and mip = linear */
  93813. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93814. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93815. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93816. /** Trilinear is mag = linear and min = linear and mip = linear */
  93817. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93818. /** nearest is mag = nearest and min = nearest and mip = linear */
  93819. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93820. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93821. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93822. /** Trilinear is mag = linear and min = linear and mip = linear */
  93823. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93824. /** mag = nearest and min = nearest and mip = nearest */
  93825. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93826. /** mag = nearest and min = linear and mip = nearest */
  93827. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93828. /** mag = nearest and min = linear and mip = linear */
  93829. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93830. /** mag = nearest and min = linear and mip = none */
  93831. static readonly TEXTURE_NEAREST_LINEAR: number;
  93832. /** mag = nearest and min = nearest and mip = none */
  93833. static readonly TEXTURE_NEAREST_NEAREST: number;
  93834. /** mag = linear and min = nearest and mip = nearest */
  93835. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93836. /** mag = linear and min = nearest and mip = linear */
  93837. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93838. /** mag = linear and min = linear and mip = none */
  93839. static readonly TEXTURE_LINEAR_LINEAR: number;
  93840. /** mag = linear and min = nearest and mip = none */
  93841. static readonly TEXTURE_LINEAR_NEAREST: number;
  93842. /** Explicit coordinates mode */
  93843. static readonly TEXTURE_EXPLICIT_MODE: number;
  93844. /** Spherical coordinates mode */
  93845. static readonly TEXTURE_SPHERICAL_MODE: number;
  93846. /** Planar coordinates mode */
  93847. static readonly TEXTURE_PLANAR_MODE: number;
  93848. /** Cubic coordinates mode */
  93849. static readonly TEXTURE_CUBIC_MODE: number;
  93850. /** Projection coordinates mode */
  93851. static readonly TEXTURE_PROJECTION_MODE: number;
  93852. /** Skybox coordinates mode */
  93853. static readonly TEXTURE_SKYBOX_MODE: number;
  93854. /** Inverse Cubic coordinates mode */
  93855. static readonly TEXTURE_INVCUBIC_MODE: number;
  93856. /** Equirectangular coordinates mode */
  93857. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93858. /** Equirectangular Fixed coordinates mode */
  93859. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93860. /** Equirectangular Fixed Mirrored coordinates mode */
  93861. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93862. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93863. static readonly SCALEMODE_FLOOR: number;
  93864. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93865. static readonly SCALEMODE_NEAREST: number;
  93866. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93867. static readonly SCALEMODE_CEILING: number;
  93868. /**
  93869. * Returns the current npm package of the sdk
  93870. */
  93871. static readonly NpmPackage: string;
  93872. /**
  93873. * Returns the current version of the framework
  93874. */
  93875. static readonly Version: string;
  93876. /**
  93877. * Returns a string describing the current engine
  93878. */
  93879. readonly description: string;
  93880. /**
  93881. * Gets or sets the epsilon value used by collision engine
  93882. */
  93883. static CollisionsEpsilon: number;
  93884. /**
  93885. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93886. */
  93887. static ShadersRepository: string;
  93888. /**
  93889. * Method called to create the default loading screen.
  93890. * This can be overriden in your own app.
  93891. * @param canvas The rendering canvas element
  93892. * @returns The loading screen
  93893. */
  93894. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93895. /**
  93896. * Method called to create the default rescale post process on each engine.
  93897. */
  93898. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93899. /** @hidden */
  93900. _shaderProcessor: IShaderProcessor;
  93901. /**
  93902. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93903. */
  93904. forcePOTTextures: boolean;
  93905. /**
  93906. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93907. */
  93908. isFullscreen: boolean;
  93909. /**
  93910. * Gets a boolean indicating if the pointer is currently locked
  93911. */
  93912. isPointerLock: boolean;
  93913. /**
  93914. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93915. */
  93916. cullBackFaces: boolean;
  93917. /**
  93918. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93919. */
  93920. renderEvenInBackground: boolean;
  93921. /**
  93922. * Gets or sets a boolean indicating that cache can be kept between frames
  93923. */
  93924. preventCacheWipeBetweenFrames: boolean;
  93925. /**
  93926. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93927. **/
  93928. enableOfflineSupport: boolean;
  93929. /**
  93930. * 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)
  93931. **/
  93932. disableManifestCheck: boolean;
  93933. /**
  93934. * Gets the list of created scenes
  93935. */
  93936. scenes: Scene[];
  93937. /**
  93938. * Event raised when a new scene is created
  93939. */
  93940. onNewSceneAddedObservable: Observable<Scene>;
  93941. /**
  93942. * Gets the list of created postprocesses
  93943. */
  93944. postProcesses: PostProcess[];
  93945. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93946. validateShaderPrograms: boolean;
  93947. /**
  93948. * Observable event triggered each time the rendering canvas is resized
  93949. */
  93950. onResizeObservable: Observable<Engine>;
  93951. /**
  93952. * Observable event triggered each time the canvas loses focus
  93953. */
  93954. onCanvasBlurObservable: Observable<Engine>;
  93955. /**
  93956. * Observable event triggered each time the canvas gains focus
  93957. */
  93958. onCanvasFocusObservable: Observable<Engine>;
  93959. /**
  93960. * Observable event triggered each time the canvas receives pointerout event
  93961. */
  93962. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93963. /**
  93964. * Observable event triggered before each texture is initialized
  93965. */
  93966. onBeforeTextureInitObservable: Observable<Texture>;
  93967. /**
  93968. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93969. */
  93970. disableUniformBuffers: boolean;
  93971. /** @hidden */
  93972. _uniformBuffers: UniformBuffer[];
  93973. /**
  93974. * Gets a boolean indicating that the engine supports uniform buffers
  93975. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93976. */
  93977. readonly supportsUniformBuffers: boolean;
  93978. /**
  93979. * Observable raised when the engine begins a new frame
  93980. */
  93981. onBeginFrameObservable: Observable<Engine>;
  93982. /**
  93983. * If set, will be used to request the next animation frame for the render loop
  93984. */
  93985. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93986. /**
  93987. * Observable raised when the engine ends the current frame
  93988. */
  93989. onEndFrameObservable: Observable<Engine>;
  93990. /**
  93991. * Observable raised when the engine is about to compile a shader
  93992. */
  93993. onBeforeShaderCompilationObservable: Observable<Engine>;
  93994. /**
  93995. * Observable raised when the engine has jsut compiled a shader
  93996. */
  93997. onAfterShaderCompilationObservable: Observable<Engine>;
  93998. /** @hidden */
  93999. _gl: WebGLRenderingContext;
  94000. private _renderingCanvas;
  94001. private _windowIsBackground;
  94002. private _webGLVersion;
  94003. protected _highPrecisionShadersAllowed: boolean;
  94004. /** @hidden */
  94005. readonly _shouldUseHighPrecisionShader: boolean;
  94006. /**
  94007. * Gets a boolean indicating that only power of 2 textures are supported
  94008. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94009. */
  94010. readonly needPOTTextures: boolean;
  94011. /** @hidden */
  94012. _badOS: boolean;
  94013. /** @hidden */
  94014. _badDesktopOS: boolean;
  94015. /**
  94016. * Gets the audio engine
  94017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94018. * @ignorenaming
  94019. */
  94020. static audioEngine: IAudioEngine;
  94021. /**
  94022. * Default AudioEngine factory responsible of creating the Audio Engine.
  94023. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94024. */
  94025. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94026. /**
  94027. * Default offline support factory responsible of creating a tool used to store data locally.
  94028. * By default, this will create a Database object if the workload has been embedded.
  94029. */
  94030. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94031. private _onFocus;
  94032. private _onBlur;
  94033. private _onCanvasPointerOut;
  94034. private _onCanvasBlur;
  94035. private _onCanvasFocus;
  94036. private _onFullscreenChange;
  94037. private _onPointerLockChange;
  94038. private _hardwareScalingLevel;
  94039. /** @hidden */
  94040. _caps: EngineCapabilities;
  94041. private _pointerLockRequested;
  94042. private _isStencilEnable;
  94043. private _colorWrite;
  94044. private _loadingScreen;
  94045. /** @hidden */
  94046. _drawCalls: PerfCounter;
  94047. private _glVersion;
  94048. private _glRenderer;
  94049. private _glVendor;
  94050. private _videoTextureSupported;
  94051. private _renderingQueueLaunched;
  94052. private _activeRenderLoops;
  94053. private _deterministicLockstep;
  94054. private _lockstepMaxSteps;
  94055. /**
  94056. * Observable signaled when a context lost event is raised
  94057. */
  94058. onContextLostObservable: Observable<Engine>;
  94059. /**
  94060. * Observable signaled when a context restored event is raised
  94061. */
  94062. onContextRestoredObservable: Observable<Engine>;
  94063. private _onContextLost;
  94064. private _onContextRestored;
  94065. private _contextWasLost;
  94066. /** @hidden */
  94067. _doNotHandleContextLost: boolean;
  94068. /**
  94069. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94071. */
  94072. doNotHandleContextLost: boolean;
  94073. private _performanceMonitor;
  94074. private _fps;
  94075. private _deltaTime;
  94076. /**
  94077. * Turn this value on if you want to pause FPS computation when in background
  94078. */
  94079. disablePerformanceMonitorInBackground: boolean;
  94080. /**
  94081. * Gets the performance monitor attached to this engine
  94082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94083. */
  94084. readonly performanceMonitor: PerformanceMonitor;
  94085. /**
  94086. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94087. */
  94088. disableVertexArrayObjects: boolean;
  94089. /** @hidden */
  94090. protected _depthCullingState: _DepthCullingState;
  94091. /** @hidden */
  94092. protected _stencilState: _StencilState;
  94093. /** @hidden */
  94094. protected _alphaState: _AlphaState;
  94095. /** @hidden */
  94096. protected _alphaMode: number;
  94097. /** @hidden */
  94098. _internalTexturesCache: InternalTexture[];
  94099. /** @hidden */
  94100. protected _activeChannel: number;
  94101. private _currentTextureChannel;
  94102. /** @hidden */
  94103. protected _boundTexturesCache: {
  94104. [key: string]: Nullable<InternalTexture>;
  94105. };
  94106. /** @hidden */
  94107. protected _currentEffect: Nullable<Effect>;
  94108. /** @hidden */
  94109. protected _currentProgram: Nullable<WebGLProgram>;
  94110. private _compiledEffects;
  94111. private _vertexAttribArraysEnabled;
  94112. /** @hidden */
  94113. protected _cachedViewport: Nullable<IViewportLike>;
  94114. private _cachedVertexArrayObject;
  94115. /** @hidden */
  94116. protected _cachedVertexBuffers: any;
  94117. /** @hidden */
  94118. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94119. /** @hidden */
  94120. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94121. /** @hidden */
  94122. _currentRenderTarget: Nullable<InternalTexture>;
  94123. private _uintIndicesCurrentlySet;
  94124. private _currentBoundBuffer;
  94125. /** @hidden */
  94126. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94127. private _currentBufferPointers;
  94128. private _currentInstanceLocations;
  94129. private _currentInstanceBuffers;
  94130. private _textureUnits;
  94131. /** @hidden */
  94132. _workingCanvas: Nullable<HTMLCanvasElement>;
  94133. /** @hidden */
  94134. _workingContext: Nullable<CanvasRenderingContext2D>;
  94135. private _rescalePostProcess;
  94136. private _dummyFramebuffer;
  94137. private _externalData;
  94138. /** @hidden */
  94139. _bindedRenderFunction: any;
  94140. private _vaoRecordInProgress;
  94141. private _mustWipeVertexAttributes;
  94142. private _emptyTexture;
  94143. private _emptyCubeTexture;
  94144. private _emptyTexture3D;
  94145. /** @hidden */
  94146. _frameHandler: number;
  94147. private _nextFreeTextureSlots;
  94148. private _maxSimultaneousTextures;
  94149. private _activeRequests;
  94150. private _texturesSupported;
  94151. /** @hidden */
  94152. _textureFormatInUse: Nullable<string>;
  94153. /**
  94154. * Gets the list of texture formats supported
  94155. */
  94156. readonly texturesSupported: Array<string>;
  94157. /**
  94158. * Gets the list of texture formats in use
  94159. */
  94160. readonly textureFormatInUse: Nullable<string>;
  94161. /**
  94162. * Gets the current viewport
  94163. */
  94164. readonly currentViewport: Nullable<IViewportLike>;
  94165. /**
  94166. * Gets the default empty texture
  94167. */
  94168. readonly emptyTexture: InternalTexture;
  94169. /**
  94170. * Gets the default empty 3D texture
  94171. */
  94172. readonly emptyTexture3D: InternalTexture;
  94173. /**
  94174. * Gets the default empty cube texture
  94175. */
  94176. readonly emptyCubeTexture: InternalTexture;
  94177. /**
  94178. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94179. */
  94180. readonly premultipliedAlpha: boolean;
  94181. /**
  94182. * Creates a new engine
  94183. * @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
  94184. * @param antialias defines enable antialiasing (default: false)
  94185. * @param options defines further options to be sent to the getContext() function
  94186. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94187. */
  94188. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94189. /**
  94190. * Initializes a webVR display and starts listening to display change events
  94191. * The onVRDisplayChangedObservable will be notified upon these changes
  94192. * @returns The onVRDisplayChangedObservable
  94193. */
  94194. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94195. /** @hidden */
  94196. _prepareVRComponent(): void;
  94197. /** @hidden */
  94198. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94199. /** @hidden */
  94200. _submitVRFrame(): void;
  94201. /**
  94202. * Call this function to leave webVR mode
  94203. * Will do nothing if webVR is not supported or if there is no webVR device
  94204. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94205. */
  94206. disableVR(): void;
  94207. /**
  94208. * Gets a boolean indicating that the system is in VR mode and is presenting
  94209. * @returns true if VR mode is engaged
  94210. */
  94211. isVRPresenting(): boolean;
  94212. /** @hidden */
  94213. _requestVRFrame(): void;
  94214. private _disableTouchAction;
  94215. private _rebuildInternalTextures;
  94216. private _rebuildEffects;
  94217. /**
  94218. * Gets a boolean indicating if all created effects are ready
  94219. * @returns true if all effects are ready
  94220. */
  94221. areAllEffectsReady(): boolean;
  94222. private _rebuildBuffers;
  94223. private _initGLContext;
  94224. /**
  94225. * Gets version of the current webGL context
  94226. */
  94227. readonly webGLVersion: number;
  94228. /**
  94229. * Gets a string idenfifying the name of the class
  94230. * @returns "Engine" string
  94231. */
  94232. getClassName(): string;
  94233. /**
  94234. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94235. */
  94236. readonly isStencilEnable: boolean;
  94237. /** @hidden */
  94238. _prepareWorkingCanvas(): void;
  94239. /**
  94240. * Reset the texture cache to empty state
  94241. */
  94242. resetTextureCache(): void;
  94243. /**
  94244. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94246. * @returns true if engine is in deterministic lock step mode
  94247. */
  94248. isDeterministicLockStep(): boolean;
  94249. /**
  94250. * Gets the max steps when engine is running in deterministic lock step
  94251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94252. * @returns the max steps
  94253. */
  94254. getLockstepMaxSteps(): number;
  94255. /**
  94256. * Gets an object containing information about the current webGL context
  94257. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94258. */
  94259. getGlInfo(): {
  94260. vendor: string;
  94261. renderer: string;
  94262. version: string;
  94263. };
  94264. /**
  94265. * Gets current aspect ratio
  94266. * @param viewportOwner defines the camera to use to get the aspect ratio
  94267. * @param useScreen defines if screen size must be used (or the current render target if any)
  94268. * @returns a number defining the aspect ratio
  94269. */
  94270. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94271. /**
  94272. * Gets current screen aspect ratio
  94273. * @returns a number defining the aspect ratio
  94274. */
  94275. getScreenAspectRatio(): number;
  94276. /**
  94277. * Gets the current render width
  94278. * @param useScreen defines if screen size must be used (or the current render target if any)
  94279. * @returns a number defining the current render width
  94280. */
  94281. getRenderWidth(useScreen?: boolean): number;
  94282. /**
  94283. * Gets the current render height
  94284. * @param useScreen defines if screen size must be used (or the current render target if any)
  94285. * @returns a number defining the current render height
  94286. */
  94287. getRenderHeight(useScreen?: boolean): number;
  94288. /**
  94289. * Gets the HTML canvas attached with the current webGL context
  94290. * @returns a HTML canvas
  94291. */
  94292. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94293. /**
  94294. * Gets host window
  94295. * @returns the host window object
  94296. */
  94297. getHostWindow(): Window;
  94298. /**
  94299. * Gets host document
  94300. * @returns the host document object
  94301. */
  94302. getHostDocument(): Document;
  94303. /**
  94304. * Gets the client rect of the HTML canvas attached with the current webGL context
  94305. * @returns a client rectanglee
  94306. */
  94307. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94308. /**
  94309. * Defines the hardware scaling level.
  94310. * By default the hardware scaling level is computed from the window device ratio.
  94311. * 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.
  94312. * @param level defines the level to use
  94313. */
  94314. setHardwareScalingLevel(level: number): void;
  94315. /**
  94316. * Gets the current hardware scaling level.
  94317. * By default the hardware scaling level is computed from the window device ratio.
  94318. * 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.
  94319. * @returns a number indicating the current hardware scaling level
  94320. */
  94321. getHardwareScalingLevel(): number;
  94322. /**
  94323. * Gets the list of loaded textures
  94324. * @returns an array containing all loaded textures
  94325. */
  94326. getLoadedTexturesCache(): InternalTexture[];
  94327. /**
  94328. * Gets the object containing all engine capabilities
  94329. * @returns the EngineCapabilities object
  94330. */
  94331. getCaps(): EngineCapabilities;
  94332. /**
  94333. * Gets the current depth function
  94334. * @returns a number defining the depth function
  94335. */
  94336. getDepthFunction(): Nullable<number>;
  94337. /**
  94338. * Sets the current depth function
  94339. * @param depthFunc defines the function to use
  94340. */
  94341. setDepthFunction(depthFunc: number): void;
  94342. /**
  94343. * Sets the current depth function to GREATER
  94344. */
  94345. setDepthFunctionToGreater(): void;
  94346. /**
  94347. * Sets the current depth function to GEQUAL
  94348. */
  94349. setDepthFunctionToGreaterOrEqual(): void;
  94350. /**
  94351. * Sets the current depth function to LESS
  94352. */
  94353. setDepthFunctionToLess(): void;
  94354. private _cachedStencilBuffer;
  94355. private _cachedStencilFunction;
  94356. private _cachedStencilMask;
  94357. private _cachedStencilOperationPass;
  94358. private _cachedStencilOperationFail;
  94359. private _cachedStencilOperationDepthFail;
  94360. private _cachedStencilReference;
  94361. /**
  94362. * Caches the the state of the stencil buffer
  94363. */
  94364. cacheStencilState(): void;
  94365. /**
  94366. * Restores the state of the stencil buffer
  94367. */
  94368. restoreStencilState(): void;
  94369. /**
  94370. * Sets the current depth function to LEQUAL
  94371. */
  94372. setDepthFunctionToLessOrEqual(): void;
  94373. /**
  94374. * Gets a boolean indicating if stencil buffer is enabled
  94375. * @returns the current stencil buffer state
  94376. */
  94377. getStencilBuffer(): boolean;
  94378. /**
  94379. * Enable or disable the stencil buffer
  94380. * @param enable defines if the stencil buffer must be enabled or disabled
  94381. */
  94382. setStencilBuffer(enable: boolean): void;
  94383. /**
  94384. * Gets the current stencil mask
  94385. * @returns a number defining the new stencil mask to use
  94386. */
  94387. getStencilMask(): number;
  94388. /**
  94389. * Sets the current stencil mask
  94390. * @param mask defines the new stencil mask to use
  94391. */
  94392. setStencilMask(mask: number): void;
  94393. /**
  94394. * Gets the current stencil function
  94395. * @returns a number defining the stencil function to use
  94396. */
  94397. getStencilFunction(): number;
  94398. /**
  94399. * Gets the current stencil reference value
  94400. * @returns a number defining the stencil reference value to use
  94401. */
  94402. getStencilFunctionReference(): number;
  94403. /**
  94404. * Gets the current stencil mask
  94405. * @returns a number defining the stencil mask to use
  94406. */
  94407. getStencilFunctionMask(): number;
  94408. /**
  94409. * Sets the current stencil function
  94410. * @param stencilFunc defines the new stencil function to use
  94411. */
  94412. setStencilFunction(stencilFunc: number): void;
  94413. /**
  94414. * Sets the current stencil reference
  94415. * @param reference defines the new stencil reference to use
  94416. */
  94417. setStencilFunctionReference(reference: number): void;
  94418. /**
  94419. * Sets the current stencil mask
  94420. * @param mask defines the new stencil mask to use
  94421. */
  94422. setStencilFunctionMask(mask: number): void;
  94423. /**
  94424. * Gets the current stencil operation when stencil fails
  94425. * @returns a number defining stencil operation to use when stencil fails
  94426. */
  94427. getStencilOperationFail(): number;
  94428. /**
  94429. * Gets the current stencil operation when depth fails
  94430. * @returns a number defining stencil operation to use when depth fails
  94431. */
  94432. getStencilOperationDepthFail(): number;
  94433. /**
  94434. * Gets the current stencil operation when stencil passes
  94435. * @returns a number defining stencil operation to use when stencil passes
  94436. */
  94437. getStencilOperationPass(): number;
  94438. /**
  94439. * Sets the stencil operation to use when stencil fails
  94440. * @param operation defines the stencil operation to use when stencil fails
  94441. */
  94442. setStencilOperationFail(operation: number): void;
  94443. /**
  94444. * Sets the stencil operation to use when depth fails
  94445. * @param operation defines the stencil operation to use when depth fails
  94446. */
  94447. setStencilOperationDepthFail(operation: number): void;
  94448. /**
  94449. * Sets the stencil operation to use when stencil passes
  94450. * @param operation defines the stencil operation to use when stencil passes
  94451. */
  94452. setStencilOperationPass(operation: number): void;
  94453. /**
  94454. * Sets a boolean indicating if the dithering state is enabled or disabled
  94455. * @param value defines the dithering state
  94456. */
  94457. setDitheringState(value: boolean): void;
  94458. /**
  94459. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94460. * @param value defines the rasterizer state
  94461. */
  94462. setRasterizerState(value: boolean): void;
  94463. /**
  94464. * stop executing a render loop function and remove it from the execution array
  94465. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94466. */
  94467. stopRenderLoop(renderFunction?: () => void): void;
  94468. /** @hidden */
  94469. _renderLoop(): void;
  94470. /**
  94471. * Register and execute a render loop. The engine can have more than one render function
  94472. * @param renderFunction defines the function to continuously execute
  94473. */
  94474. runRenderLoop(renderFunction: () => void): void;
  94475. /**
  94476. * Toggle full screen mode
  94477. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94478. */
  94479. switchFullscreen(requestPointerLock: boolean): void;
  94480. /**
  94481. * Enters full screen mode
  94482. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94483. */
  94484. enterFullscreen(requestPointerLock: boolean): void;
  94485. /**
  94486. * Exits full screen mode
  94487. */
  94488. exitFullscreen(): void;
  94489. /**
  94490. * Enters Pointerlock mode
  94491. */
  94492. enterPointerlock(): void;
  94493. /**
  94494. * Exits Pointerlock mode
  94495. */
  94496. exitPointerlock(): void;
  94497. /**
  94498. * Clear the current render buffer or the current render target (if any is set up)
  94499. * @param color defines the color to use
  94500. * @param backBuffer defines if the back buffer must be cleared
  94501. * @param depth defines if the depth buffer must be cleared
  94502. * @param stencil defines if the stencil buffer must be cleared
  94503. */
  94504. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94505. /**
  94506. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94507. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94508. * @param y defines the y-coordinate of the corner of the clear rectangle
  94509. * @param width defines the width of the clear rectangle
  94510. * @param height defines the height of the clear rectangle
  94511. * @param clearColor defines the clear color
  94512. */
  94513. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94514. /**
  94515. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94516. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94517. * @param y defines the y-coordinate of the corner of the clear rectangle
  94518. * @param width defines the width of the clear rectangle
  94519. * @param height defines the height of the clear rectangle
  94520. */
  94521. enableScissor(x: number, y: number, width: number, height: number): void;
  94522. /**
  94523. * Disable previously set scissor test rectangle
  94524. */
  94525. disableScissor(): void;
  94526. private _viewportCached;
  94527. /** @hidden */
  94528. _viewport(x: number, y: number, width: number, height: number): void;
  94529. /**
  94530. * Set the WebGL's viewport
  94531. * @param viewport defines the viewport element to be used
  94532. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94533. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94534. */
  94535. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94536. /**
  94537. * Directly set the WebGL Viewport
  94538. * @param x defines the x coordinate of the viewport (in screen space)
  94539. * @param y defines the y coordinate of the viewport (in screen space)
  94540. * @param width defines the width of the viewport (in screen space)
  94541. * @param height defines the height of the viewport (in screen space)
  94542. * @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
  94543. */
  94544. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94545. /**
  94546. * Begin a new frame
  94547. */
  94548. beginFrame(): void;
  94549. /**
  94550. * Enf the current frame
  94551. */
  94552. endFrame(): void;
  94553. /**
  94554. * Resize the view according to the canvas' size
  94555. */
  94556. resize(): void;
  94557. /**
  94558. * Force a specific size of the canvas
  94559. * @param width defines the new canvas' width
  94560. * @param height defines the new canvas' height
  94561. */
  94562. setSize(width: number, height: number): void;
  94563. /**
  94564. * Binds the frame buffer to the specified texture.
  94565. * @param texture The texture to render to or null for the default canvas
  94566. * @param faceIndex The face of the texture to render to in case of cube texture
  94567. * @param requiredWidth The width of the target to render to
  94568. * @param requiredHeight The height of the target to render to
  94569. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94570. * @param depthStencilTexture The depth stencil texture to use to render
  94571. * @param lodLevel defines le lod level to bind to the frame buffer
  94572. */
  94573. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94574. /** @hidden */
  94575. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94576. /**
  94577. * Unbind the current render target texture from the webGL context
  94578. * @param texture defines the render target texture to unbind
  94579. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94580. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94581. */
  94582. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94583. /**
  94584. * Force the mipmap generation for the given render target texture
  94585. * @param texture defines the render target texture to use
  94586. */
  94587. generateMipMapsForCubemap(texture: InternalTexture): void;
  94588. /**
  94589. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94590. */
  94591. flushFramebuffer(): void;
  94592. /**
  94593. * Unbind the current render target and bind the default framebuffer
  94594. */
  94595. restoreDefaultFramebuffer(): void;
  94596. /**
  94597. * Create an uniform buffer
  94598. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94599. * @param elements defines the content of the uniform buffer
  94600. * @returns the webGL uniform buffer
  94601. */
  94602. createUniformBuffer(elements: FloatArray): DataBuffer;
  94603. /**
  94604. * Create a dynamic uniform buffer
  94605. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94606. * @param elements defines the content of the uniform buffer
  94607. * @returns the webGL uniform buffer
  94608. */
  94609. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94610. /**
  94611. * Update an existing uniform buffer
  94612. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94613. * @param uniformBuffer defines the target uniform buffer
  94614. * @param elements defines the content to update
  94615. * @param offset defines the offset in the uniform buffer where update should start
  94616. * @param count defines the size of the data to update
  94617. */
  94618. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94619. private _resetVertexBufferBinding;
  94620. /**
  94621. * Creates a vertex buffer
  94622. * @param data the data for the vertex buffer
  94623. * @returns the new WebGL static buffer
  94624. */
  94625. createVertexBuffer(data: DataArray): DataBuffer;
  94626. /**
  94627. * Creates a dynamic vertex buffer
  94628. * @param data the data for the dynamic vertex buffer
  94629. * @returns the new WebGL dynamic buffer
  94630. */
  94631. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94632. /**
  94633. * Update a dynamic index buffer
  94634. * @param indexBuffer defines the target index buffer
  94635. * @param indices defines the data to update
  94636. * @param offset defines the offset in the target index buffer where update should start
  94637. */
  94638. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94639. /**
  94640. * Updates a dynamic vertex buffer.
  94641. * @param vertexBuffer the vertex buffer to update
  94642. * @param data the data used to update the vertex buffer
  94643. * @param byteOffset the byte offset of the data
  94644. * @param byteLength the byte length of the data
  94645. */
  94646. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94647. private _resetIndexBufferBinding;
  94648. /**
  94649. * Creates a new index buffer
  94650. * @param indices defines the content of the index buffer
  94651. * @param updatable defines if the index buffer must be updatable
  94652. * @returns a new webGL buffer
  94653. */
  94654. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94655. /**
  94656. * Bind a webGL buffer to the webGL context
  94657. * @param buffer defines the buffer to bind
  94658. */
  94659. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94660. /**
  94661. * Bind an uniform buffer to the current webGL context
  94662. * @param buffer defines the buffer to bind
  94663. */
  94664. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94665. /**
  94666. * Bind a buffer to the current webGL context at a given location
  94667. * @param buffer defines the buffer to bind
  94668. * @param location defines the index where to bind the buffer
  94669. */
  94670. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94671. /**
  94672. * Bind a specific block at a given index in a specific shader program
  94673. * @param pipelineContext defines the pipeline context to use
  94674. * @param blockName defines the block name
  94675. * @param index defines the index where to bind the block
  94676. */
  94677. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94678. private bindIndexBuffer;
  94679. private bindBuffer;
  94680. /**
  94681. * update the bound buffer with the given data
  94682. * @param data defines the data to update
  94683. */
  94684. updateArrayBuffer(data: Float32Array): void;
  94685. private _vertexAttribPointer;
  94686. private _bindIndexBufferWithCache;
  94687. private _bindVertexBuffersAttributes;
  94688. /**
  94689. * Records a vertex array object
  94690. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94691. * @param vertexBuffers defines the list of vertex buffers to store
  94692. * @param indexBuffer defines the index buffer to store
  94693. * @param effect defines the effect to store
  94694. * @returns the new vertex array object
  94695. */
  94696. recordVertexArrayObject(vertexBuffers: {
  94697. [key: string]: VertexBuffer;
  94698. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94699. /**
  94700. * Bind a specific vertex array object
  94701. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94702. * @param vertexArrayObject defines the vertex array object to bind
  94703. * @param indexBuffer defines the index buffer to bind
  94704. */
  94705. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94706. /**
  94707. * Bind webGl buffers directly to the webGL context
  94708. * @param vertexBuffer defines the vertex buffer to bind
  94709. * @param indexBuffer defines the index buffer to bind
  94710. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94711. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94712. * @param effect defines the effect associated with the vertex buffer
  94713. */
  94714. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94715. private _unbindVertexArrayObject;
  94716. /**
  94717. * Bind a list of vertex buffers to the webGL context
  94718. * @param vertexBuffers defines the list of vertex buffers to bind
  94719. * @param indexBuffer defines the index buffer to bind
  94720. * @param effect defines the effect associated with the vertex buffers
  94721. */
  94722. bindBuffers(vertexBuffers: {
  94723. [key: string]: Nullable<VertexBuffer>;
  94724. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94725. /**
  94726. * Unbind all instance attributes
  94727. */
  94728. unbindInstanceAttributes(): void;
  94729. /**
  94730. * Release and free the memory of a vertex array object
  94731. * @param vao defines the vertex array object to delete
  94732. */
  94733. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94734. /** @hidden */
  94735. _releaseBuffer(buffer: DataBuffer): boolean;
  94736. /**
  94737. * Creates a webGL buffer to use with instanciation
  94738. * @param capacity defines the size of the buffer
  94739. * @returns the webGL buffer
  94740. */
  94741. createInstancesBuffer(capacity: number): DataBuffer;
  94742. /**
  94743. * Delete a webGL buffer used with instanciation
  94744. * @param buffer defines the webGL buffer to delete
  94745. */
  94746. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94747. /**
  94748. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94749. * @param instancesBuffer defines the webGL buffer to update and bind
  94750. * @param data defines the data to store in the buffer
  94751. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94752. */
  94753. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94754. /**
  94755. * Apply all cached states (depth, culling, stencil and alpha)
  94756. */
  94757. applyStates(): void;
  94758. /**
  94759. * Send a draw order
  94760. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94761. * @param indexStart defines the starting index
  94762. * @param indexCount defines the number of index to draw
  94763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94764. */
  94765. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  94766. /**
  94767. * Draw a list of points
  94768. * @param verticesStart defines the index of first vertex to draw
  94769. * @param verticesCount defines the count of vertices to draw
  94770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94771. */
  94772. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94773. /**
  94774. * Draw a list of unindexed primitives
  94775. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94776. * @param verticesStart defines the index of first vertex to draw
  94777. * @param verticesCount defines the count of vertices to draw
  94778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94779. */
  94780. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94781. /**
  94782. * Draw a list of indexed primitives
  94783. * @param fillMode defines the primitive to use
  94784. * @param indexStart defines the starting index
  94785. * @param indexCount defines the number of index to draw
  94786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94787. */
  94788. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  94789. /**
  94790. * Draw a list of unindexed primitives
  94791. * @param fillMode defines the primitive to use
  94792. * @param verticesStart defines the index of first vertex to draw
  94793. * @param verticesCount defines the count of vertices to draw
  94794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94795. */
  94796. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94797. private _drawMode;
  94798. /** @hidden */
  94799. _releaseEffect(effect: Effect): void;
  94800. /** @hidden */
  94801. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  94802. /**
  94803. * Create a new effect (used to store vertex/fragment shaders)
  94804. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  94805. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  94806. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  94807. * @param samplers defines an array of string used to represent textures
  94808. * @param defines defines the string containing the defines to use to compile the shaders
  94809. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  94810. * @param onCompiled defines a function to call when the effect creation is successful
  94811. * @param onError defines a function to call when the effect creation has failed
  94812. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  94813. * @returns the new Effect
  94814. */
  94815. 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;
  94816. private _compileShader;
  94817. private _compileRawShader;
  94818. /**
  94819. * Directly creates a webGL program
  94820. * @param pipelineContext defines the pipeline context to attach to
  94821. * @param vertexCode defines the vertex shader code to use
  94822. * @param fragmentCode defines the fragment shader code to use
  94823. * @param context defines the webGL context to use (if not set, the current one will be used)
  94824. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94825. * @returns the new webGL program
  94826. */
  94827. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94828. /**
  94829. * Creates a webGL program
  94830. * @param pipelineContext defines the pipeline context to attach to
  94831. * @param vertexCode defines the vertex shader code to use
  94832. * @param fragmentCode defines the fragment shader code to use
  94833. * @param defines defines the string containing the defines to use to compile the shaders
  94834. * @param context defines the webGL context to use (if not set, the current one will be used)
  94835. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94836. * @returns the new webGL program
  94837. */
  94838. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94839. /**
  94840. * Creates a new pipeline context
  94841. * @returns the new pipeline
  94842. */
  94843. createPipelineContext(): WebGLPipelineContext;
  94844. private _createShaderProgram;
  94845. private _finalizePipelineContext;
  94846. /** @hidden */
  94847. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94848. /** @hidden */
  94849. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94850. /** @hidden */
  94851. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94852. /**
  94853. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94854. * @param pipelineContext defines the pipeline context to use
  94855. * @param uniformsNames defines the list of uniform names
  94856. * @returns an array of webGL uniform locations
  94857. */
  94858. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94859. /**
  94860. * Gets the lsit of active attributes for a given webGL program
  94861. * @param pipelineContext defines the pipeline context to use
  94862. * @param attributesNames defines the list of attribute names to get
  94863. * @returns an array of indices indicating the offset of each attribute
  94864. */
  94865. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94866. /**
  94867. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94868. * @param effect defines the effect to activate
  94869. */
  94870. enableEffect(effect: Nullable<Effect>): void;
  94871. /**
  94872. * Set the value of an uniform to an array of int32
  94873. * @param uniform defines the webGL uniform location where to store the value
  94874. * @param array defines the array of int32 to store
  94875. */
  94876. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94877. /**
  94878. * Set the value of an uniform to an array of int32 (stored as vec2)
  94879. * @param uniform defines the webGL uniform location where to store the value
  94880. * @param array defines the array of int32 to store
  94881. */
  94882. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94883. /**
  94884. * Set the value of an uniform to an array of int32 (stored as vec3)
  94885. * @param uniform defines the webGL uniform location where to store the value
  94886. * @param array defines the array of int32 to store
  94887. */
  94888. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94889. /**
  94890. * Set the value of an uniform to an array of int32 (stored as vec4)
  94891. * @param uniform defines the webGL uniform location where to store the value
  94892. * @param array defines the array of int32 to store
  94893. */
  94894. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94895. /**
  94896. * Set the value of an uniform to an array of float32
  94897. * @param uniform defines the webGL uniform location where to store the value
  94898. * @param array defines the array of float32 to store
  94899. */
  94900. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94901. /**
  94902. * Set the value of an uniform to an array of float32 (stored as vec2)
  94903. * @param uniform defines the webGL uniform location where to store the value
  94904. * @param array defines the array of float32 to store
  94905. */
  94906. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94907. /**
  94908. * Set the value of an uniform to an array of float32 (stored as vec3)
  94909. * @param uniform defines the webGL uniform location where to store the value
  94910. * @param array defines the array of float32 to store
  94911. */
  94912. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94913. /**
  94914. * Set the value of an uniform to an array of float32 (stored as vec4)
  94915. * @param uniform defines the webGL uniform location where to store the value
  94916. * @param array defines the array of float32 to store
  94917. */
  94918. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94919. /**
  94920. * Set the value of an uniform to an array of number
  94921. * @param uniform defines the webGL uniform location where to store the value
  94922. * @param array defines the array of number to store
  94923. */
  94924. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94925. /**
  94926. * Set the value of an uniform to an array of number (stored as vec2)
  94927. * @param uniform defines the webGL uniform location where to store the value
  94928. * @param array defines the array of number to store
  94929. */
  94930. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94931. /**
  94932. * Set the value of an uniform to an array of number (stored as vec3)
  94933. * @param uniform defines the webGL uniform location where to store the value
  94934. * @param array defines the array of number to store
  94935. */
  94936. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94937. /**
  94938. * Set the value of an uniform to an array of number (stored as vec4)
  94939. * @param uniform defines the webGL uniform location where to store the value
  94940. * @param array defines the array of number to store
  94941. */
  94942. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94943. /**
  94944. * Set the value of an uniform to an array of float32 (stored as matrices)
  94945. * @param uniform defines the webGL uniform location where to store the value
  94946. * @param matrices defines the array of float32 to store
  94947. */
  94948. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94949. /**
  94950. * Set the value of an uniform to a matrix (3x3)
  94951. * @param uniform defines the webGL uniform location where to store the value
  94952. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94953. */
  94954. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94955. /**
  94956. * Set the value of an uniform to a matrix (2x2)
  94957. * @param uniform defines the webGL uniform location where to store the value
  94958. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94959. */
  94960. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94961. /**
  94962. * Set the value of an uniform to a number (int)
  94963. * @param uniform defines the webGL uniform location where to store the value
  94964. * @param value defines the int number to store
  94965. */
  94966. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94967. /**
  94968. * Set the value of an uniform to a number (float)
  94969. * @param uniform defines the webGL uniform location where to store the value
  94970. * @param value defines the float number to store
  94971. */
  94972. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94973. /**
  94974. * Set the value of an uniform to a vec2
  94975. * @param uniform defines the webGL uniform location where to store the value
  94976. * @param x defines the 1st component of the value
  94977. * @param y defines the 2nd component of the value
  94978. */
  94979. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94980. /**
  94981. * Set the value of an uniform to a vec3
  94982. * @param uniform defines the webGL uniform location where to store the value
  94983. * @param x defines the 1st component of the value
  94984. * @param y defines the 2nd component of the value
  94985. * @param z defines the 3rd component of the value
  94986. */
  94987. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94988. /**
  94989. * Set the value of an uniform to a boolean
  94990. * @param uniform defines the webGL uniform location where to store the value
  94991. * @param bool defines the boolean to store
  94992. */
  94993. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94994. /**
  94995. * Set the value of an uniform to a vec4
  94996. * @param uniform defines the webGL uniform location where to store the value
  94997. * @param x defines the 1st component of the value
  94998. * @param y defines the 2nd component of the value
  94999. * @param z defines the 3rd component of the value
  95000. * @param w defines the 4th component of the value
  95001. */
  95002. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95003. /**
  95004. * Sets a Color4 on a uniform variable
  95005. * @param uniform defines the uniform location
  95006. * @param color4 defines the value to be set
  95007. */
  95008. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95009. /**
  95010. * Set various states to the webGL context
  95011. * @param culling defines backface culling state
  95012. * @param zOffset defines the value to apply to zOffset (0 by default)
  95013. * @param force defines if states must be applied even if cache is up to date
  95014. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95015. */
  95016. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95017. /**
  95018. * Set the z offset to apply to current rendering
  95019. * @param value defines the offset to apply
  95020. */
  95021. setZOffset(value: number): void;
  95022. /**
  95023. * Gets the current value of the zOffset
  95024. * @returns the current zOffset state
  95025. */
  95026. getZOffset(): number;
  95027. /**
  95028. * Enable or disable depth buffering
  95029. * @param enable defines the state to set
  95030. */
  95031. setDepthBuffer(enable: boolean): void;
  95032. /**
  95033. * Gets a boolean indicating if depth writing is enabled
  95034. * @returns the current depth writing state
  95035. */
  95036. getDepthWrite(): boolean;
  95037. /**
  95038. * Enable or disable depth writing
  95039. * @param enable defines the state to set
  95040. */
  95041. setDepthWrite(enable: boolean): void;
  95042. /**
  95043. * Enable or disable color writing
  95044. * @param enable defines the state to set
  95045. */
  95046. setColorWrite(enable: boolean): void;
  95047. /**
  95048. * Gets a boolean indicating if color writing is enabled
  95049. * @returns the current color writing state
  95050. */
  95051. getColorWrite(): boolean;
  95052. /**
  95053. * Sets alpha constants used by some alpha blending modes
  95054. * @param r defines the red component
  95055. * @param g defines the green component
  95056. * @param b defines the blue component
  95057. * @param a defines the alpha component
  95058. */
  95059. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95060. /**
  95061. * Sets the current alpha mode
  95062. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95063. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95065. */
  95066. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95067. /**
  95068. * Gets the current alpha mode
  95069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95070. * @returns the current alpha mode
  95071. */
  95072. getAlphaMode(): number;
  95073. /**
  95074. * Clears the list of texture accessible through engine.
  95075. * This can help preventing texture load conflict due to name collision.
  95076. */
  95077. clearInternalTexturesCache(): void;
  95078. /**
  95079. * Force the entire cache to be cleared
  95080. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95081. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95082. */
  95083. wipeCaches(bruteForce?: boolean): void;
  95084. /**
  95085. * Set the compressed texture format to use, based on the formats you have, and the formats
  95086. * supported by the hardware / browser.
  95087. *
  95088. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95089. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95090. * to API arguments needed to compressed textures. This puts the burden on the container
  95091. * generator to house the arcane code for determining these for current & future formats.
  95092. *
  95093. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95094. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95095. *
  95096. * Note: The result of this call is not taken into account when a texture is base64.
  95097. *
  95098. * @param formatsAvailable defines the list of those format families you have created
  95099. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95100. *
  95101. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95102. * @returns The extension selected.
  95103. */
  95104. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95105. /** @hidden */
  95106. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95107. min: number;
  95108. mag: number;
  95109. };
  95110. /** @hidden */
  95111. _createTexture(): WebGLTexture;
  95112. /**
  95113. * Usually called from Texture.ts.
  95114. * Passed information to create a WebGLTexture
  95115. * @param urlArg defines a value which contains one of the following:
  95116. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95117. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95118. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95119. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95120. * @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)
  95121. * @param scene needed for loading to the correct scene
  95122. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95123. * @param onLoad optional callback to be called upon successful completion
  95124. * @param onError optional callback to be called upon failure
  95125. * @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
  95126. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95127. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95128. * @param forcedExtension defines the extension to use to pick the right loader
  95129. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95130. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95131. */
  95132. 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;
  95133. /**
  95134. * @hidden
  95135. * Rescales a texture
  95136. * @param source input texutre
  95137. * @param destination destination texture
  95138. * @param scene scene to use to render the resize
  95139. * @param internalFormat format to use when resizing
  95140. * @param onComplete callback to be called when resize has completed
  95141. */
  95142. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95143. private _unpackFlipYCached;
  95144. /**
  95145. * In case you are sharing the context with other applications, it might
  95146. * be interested to not cache the unpack flip y state to ensure a consistent
  95147. * value would be set.
  95148. */
  95149. enableUnpackFlipYCached: boolean;
  95150. /** @hidden */
  95151. _unpackFlipY(value: boolean): void;
  95152. /** @hidden */
  95153. _getUnpackAlignement(): number;
  95154. /**
  95155. * Creates a dynamic texture
  95156. * @param width defines the width of the texture
  95157. * @param height defines the height of the texture
  95158. * @param generateMipMaps defines if the engine should generate the mip levels
  95159. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95160. * @returns the dynamic texture inside an InternalTexture
  95161. */
  95162. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95163. /**
  95164. * Update the sampling mode of a given texture
  95165. * @param samplingMode defines the required sampling mode
  95166. * @param texture defines the texture to update
  95167. */
  95168. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95169. /**
  95170. * Update the content of a dynamic texture
  95171. * @param texture defines the texture to update
  95172. * @param canvas defines the canvas containing the source
  95173. * @param invertY defines if data must be stored with Y axis inverted
  95174. * @param premulAlpha defines if alpha is stored as premultiplied
  95175. * @param format defines the format of the data
  95176. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95177. */
  95178. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95179. /**
  95180. * Update a video texture
  95181. * @param texture defines the texture to update
  95182. * @param video defines the video element to use
  95183. * @param invertY defines if data must be stored with Y axis inverted
  95184. */
  95185. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95186. /**
  95187. * Updates a depth texture Comparison Mode and Function.
  95188. * If the comparison Function is equal to 0, the mode will be set to none.
  95189. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95190. * @param texture The texture to set the comparison function for
  95191. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95192. */
  95193. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95194. /** @hidden */
  95195. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95196. width: number;
  95197. height: number;
  95198. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95199. /**
  95200. * Creates a depth stencil texture.
  95201. * This is only available in WebGL 2 or with the depth texture extension available.
  95202. * @param size The size of face edge in the texture.
  95203. * @param options The options defining the texture.
  95204. * @returns The texture
  95205. */
  95206. createDepthStencilTexture(size: number | {
  95207. width: number;
  95208. height: number;
  95209. }, options: DepthTextureCreationOptions): InternalTexture;
  95210. /**
  95211. * Creates a depth stencil texture.
  95212. * This is only available in WebGL 2 or with the depth texture extension available.
  95213. * @param size The size of face edge in the texture.
  95214. * @param options The options defining the texture.
  95215. * @returns The texture
  95216. */
  95217. private _createDepthStencilTexture;
  95218. /**
  95219. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95220. * @param renderTarget The render target to set the frame buffer for
  95221. */
  95222. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95223. /**
  95224. * Creates a new render target texture
  95225. * @param size defines the size of the texture
  95226. * @param options defines the options used to create the texture
  95227. * @returns a new render target texture stored in an InternalTexture
  95228. */
  95229. createRenderTargetTexture(size: number | {
  95230. width: number;
  95231. height: number;
  95232. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95233. /** @hidden */
  95234. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95235. /**
  95236. * Updates the sample count of a render target texture
  95237. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95238. * @param texture defines the texture to update
  95239. * @param samples defines the sample count to set
  95240. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95241. */
  95242. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95243. /** @hidden */
  95244. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95245. /** @hidden */
  95246. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95247. /** @hidden */
  95248. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95249. /** @hidden */
  95250. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95251. /**
  95252. * @hidden
  95253. */
  95254. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95255. private _prepareWebGLTextureContinuation;
  95256. private _prepareWebGLTexture;
  95257. /** @hidden */
  95258. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95259. /** @hidden */
  95260. _releaseFramebufferObjects(texture: InternalTexture): void;
  95261. /** @hidden */
  95262. _releaseTexture(texture: InternalTexture): void;
  95263. private setProgram;
  95264. private _boundUniforms;
  95265. /**
  95266. * Binds an effect to the webGL context
  95267. * @param effect defines the effect to bind
  95268. */
  95269. bindSamplers(effect: Effect): void;
  95270. private _activateCurrentTexture;
  95271. /** @hidden */
  95272. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95273. /** @hidden */
  95274. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95275. /**
  95276. * Sets a texture to the webGL context from a postprocess
  95277. * @param channel defines the channel to use
  95278. * @param postProcess defines the source postprocess
  95279. */
  95280. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95281. /**
  95282. * Binds the output of the passed in post process to the texture channel specified
  95283. * @param channel The channel the texture should be bound to
  95284. * @param postProcess The post process which's output should be bound
  95285. */
  95286. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95287. /**
  95288. * Unbind all textures from the webGL context
  95289. */
  95290. unbindAllTextures(): void;
  95291. /**
  95292. * Sets a texture to the according uniform.
  95293. * @param channel The texture channel
  95294. * @param uniform The uniform to set
  95295. * @param texture The texture to apply
  95296. */
  95297. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95298. /**
  95299. * Sets a depth stencil texture from a render target to the according uniform.
  95300. * @param channel The texture channel
  95301. * @param uniform The uniform to set
  95302. * @param texture The render target texture containing the depth stencil texture to apply
  95303. */
  95304. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95305. private _bindSamplerUniformToChannel;
  95306. private _getTextureWrapMode;
  95307. private _setTexture;
  95308. /**
  95309. * Sets an array of texture to the webGL context
  95310. * @param channel defines the channel where the texture array must be set
  95311. * @param uniform defines the associated uniform location
  95312. * @param textures defines the array of textures to bind
  95313. */
  95314. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95315. /** @hidden */
  95316. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95317. private _setTextureParameterFloat;
  95318. private _setTextureParameterInteger;
  95319. /**
  95320. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95321. * @param x defines the x coordinate of the rectangle where pixels must be read
  95322. * @param y defines the y coordinate of the rectangle where pixels must be read
  95323. * @param width defines the width of the rectangle where pixels must be read
  95324. * @param height defines the height of the rectangle where pixels must be read
  95325. * @returns a Uint8Array containing RGBA colors
  95326. */
  95327. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95328. /**
  95329. * Add an externaly attached data from its key.
  95330. * This method call will fail and return false, if such key already exists.
  95331. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95332. * @param key the unique key that identifies the data
  95333. * @param data the data object to associate to the key for this Engine instance
  95334. * @return true if no such key were already present and the data was added successfully, false otherwise
  95335. */
  95336. addExternalData<T>(key: string, data: T): boolean;
  95337. /**
  95338. * Get an externaly attached data from its key
  95339. * @param key the unique key that identifies the data
  95340. * @return the associated data, if present (can be null), or undefined if not present
  95341. */
  95342. getExternalData<T>(key: string): T;
  95343. /**
  95344. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95345. * @param key the unique key that identifies the data
  95346. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95347. * @return the associated data, can be null if the factory returned null.
  95348. */
  95349. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95350. /**
  95351. * Remove an externaly attached data from the Engine instance
  95352. * @param key the unique key that identifies the data
  95353. * @return true if the data was successfully removed, false if it doesn't exist
  95354. */
  95355. removeExternalData(key: string): boolean;
  95356. /**
  95357. * Unbind all vertex attributes from the webGL context
  95358. */
  95359. unbindAllAttributes(): void;
  95360. /**
  95361. * 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
  95362. */
  95363. releaseEffects(): void;
  95364. /**
  95365. * Dispose and release all associated resources
  95366. */
  95367. dispose(): void;
  95368. /**
  95369. * Display the loading screen
  95370. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95371. */
  95372. displayLoadingUI(): void;
  95373. /**
  95374. * Hide the loading screen
  95375. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95376. */
  95377. hideLoadingUI(): void;
  95378. /**
  95379. * Gets the current loading screen object
  95380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95381. */
  95382. /**
  95383. * Sets the current loading screen object
  95384. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95385. */
  95386. loadingScreen: ILoadingScreen;
  95387. /**
  95388. * Sets the current loading screen text
  95389. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95390. */
  95391. loadingUIText: string;
  95392. /**
  95393. * Sets the current loading screen background color
  95394. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95395. */
  95396. loadingUIBackgroundColor: string;
  95397. /**
  95398. * Attach a new callback raised when context lost event is fired
  95399. * @param callback defines the callback to call
  95400. */
  95401. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95402. /**
  95403. * Attach a new callback raised when context restored event is fired
  95404. * @param callback defines the callback to call
  95405. */
  95406. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95407. /**
  95408. * Gets the source code of the vertex shader associated with a specific webGL program
  95409. * @param program defines the program to use
  95410. * @returns a string containing the source code of the vertex shader associated with the program
  95411. */
  95412. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95413. /**
  95414. * Gets the source code of the fragment shader associated with a specific webGL program
  95415. * @param program defines the program to use
  95416. * @returns a string containing the source code of the fragment shader associated with the program
  95417. */
  95418. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95419. /**
  95420. * Get the current error code of the webGL context
  95421. * @returns the error code
  95422. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95423. */
  95424. getError(): number;
  95425. /**
  95426. * Gets the current framerate
  95427. * @returns a number representing the framerate
  95428. */
  95429. getFps(): number;
  95430. /**
  95431. * Gets the time spent between current and previous frame
  95432. * @returns a number representing the delta time in ms
  95433. */
  95434. getDeltaTime(): number;
  95435. private _measureFps;
  95436. /** @hidden */
  95437. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95438. private _canRenderToFloatFramebuffer;
  95439. private _canRenderToHalfFloatFramebuffer;
  95440. private _canRenderToFramebuffer;
  95441. /** @hidden */
  95442. _getWebGLTextureType(type: number): number;
  95443. /** @hidden */
  95444. _getInternalFormat(format: number): number;
  95445. /** @hidden */
  95446. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95447. /** @hidden */
  95448. _getRGBAMultiSampleBufferFormat(type: number): number;
  95449. /** @hidden */
  95450. _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;
  95451. /** @hidden */
  95452. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95453. /**
  95454. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95455. * @returns true if the engine can be created
  95456. * @ignorenaming
  95457. */
  95458. static isSupported(): boolean;
  95459. /**
  95460. * Find the next highest power of two.
  95461. * @param x Number to start search from.
  95462. * @return Next highest power of two.
  95463. */
  95464. static CeilingPOT(x: number): number;
  95465. /**
  95466. * Find the next lowest power of two.
  95467. * @param x Number to start search from.
  95468. * @return Next lowest power of two.
  95469. */
  95470. static FloorPOT(x: number): number;
  95471. /**
  95472. * Find the nearest power of two.
  95473. * @param x Number to start search from.
  95474. * @return Next nearest power of two.
  95475. */
  95476. static NearestPOT(x: number): number;
  95477. /**
  95478. * Get the closest exponent of two
  95479. * @param value defines the value to approximate
  95480. * @param max defines the maximum value to return
  95481. * @param mode defines how to define the closest value
  95482. * @returns closest exponent of two of the given value
  95483. */
  95484. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95485. /**
  95486. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95487. * @param func - the function to be called
  95488. * @param requester - the object that will request the next frame. Falls back to window.
  95489. * @returns frame number
  95490. */
  95491. static QueueNewFrame(func: () => void, requester?: any): number;
  95492. /**
  95493. * Ask the browser to promote the current element to pointerlock mode
  95494. * @param element defines the DOM element to promote
  95495. */
  95496. static _RequestPointerlock(element: HTMLElement): void;
  95497. /**
  95498. * Asks the browser to exit pointerlock mode
  95499. */
  95500. static _ExitPointerlock(): void;
  95501. /**
  95502. * Ask the browser to promote the current element to fullscreen rendering mode
  95503. * @param element defines the DOM element to promote
  95504. */
  95505. static _RequestFullscreen(element: HTMLElement): void;
  95506. /**
  95507. * Asks the browser to exit fullscreen mode
  95508. */
  95509. static _ExitFullscreen(): void;
  95510. }
  95511. }
  95512. declare module BABYLON {
  95513. /**
  95514. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95515. * during the life time of the application.
  95516. */
  95517. export class EngineStore {
  95518. /** Gets the list of created engines */
  95519. static Instances: Engine[];
  95520. /** @hidden */
  95521. static _LastCreatedScene: Nullable<Scene>;
  95522. /**
  95523. * Gets the latest created engine
  95524. */
  95525. static readonly LastCreatedEngine: Nullable<Engine>;
  95526. /**
  95527. * Gets the latest created scene
  95528. */
  95529. static readonly LastCreatedScene: Nullable<Scene>;
  95530. /**
  95531. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95532. * @ignorenaming
  95533. */
  95534. static UseFallbackTexture: boolean;
  95535. /**
  95536. * Texture content used if a texture cannot loaded
  95537. * @ignorenaming
  95538. */
  95539. static FallbackTexture: string;
  95540. }
  95541. }
  95542. declare module BABYLON {
  95543. /**
  95544. * Helper class that provides a small promise polyfill
  95545. */
  95546. export class PromisePolyfill {
  95547. /**
  95548. * Static function used to check if the polyfill is required
  95549. * If this is the case then the function will inject the polyfill to window.Promise
  95550. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95551. */
  95552. static Apply(force?: boolean): void;
  95553. }
  95554. }
  95555. declare module BABYLON {
  95556. /**
  95557. * Interface for screenshot methods with describe argument called `size` as object with options
  95558. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  95559. */
  95560. export interface IScreenshotSize {
  95561. /**
  95562. * number in pixels for canvas height
  95563. */
  95564. height?: number;
  95565. /**
  95566. * multiplier allowing render at a higher or lower resolution
  95567. * If value is defined then height and width will be ignored and taken from camera
  95568. */
  95569. precision?: number;
  95570. /**
  95571. * number in pixels for canvas width
  95572. */
  95573. width?: number;
  95574. }
  95575. }
  95576. declare module BABYLON {
  95577. interface IColor4Like {
  95578. r: float;
  95579. g: float;
  95580. b: float;
  95581. a: float;
  95582. }
  95583. /**
  95584. * Class containing a set of static utilities functions
  95585. */
  95586. export class Tools {
  95587. /**
  95588. * Gets or sets the base URL to use to load assets
  95589. */
  95590. static BaseUrl: string;
  95591. /**
  95592. * Enable/Disable Custom HTTP Request Headers globally.
  95593. * default = false
  95594. * @see CustomRequestHeaders
  95595. */
  95596. static UseCustomRequestHeaders: boolean;
  95597. /**
  95598. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95599. * i.e. when loading files, where the server/service expects an Authorization header
  95600. */
  95601. static CustomRequestHeaders: {
  95602. [key: string]: string;
  95603. };
  95604. /**
  95605. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95606. */
  95607. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95608. /**
  95609. * Default behaviour for cors in the application.
  95610. * It can be a string if the expected behavior is identical in the entire app.
  95611. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95612. */
  95613. static CorsBehavior: string | ((url: string | string[]) => string);
  95614. /**
  95615. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95616. * @ignorenaming
  95617. */
  95618. static UseFallbackTexture: boolean;
  95619. /**
  95620. * Use this object to register external classes like custom textures or material
  95621. * to allow the laoders to instantiate them
  95622. */
  95623. static RegisteredExternalClasses: {
  95624. [key: string]: Object;
  95625. };
  95626. /**
  95627. * Texture content used if a texture cannot loaded
  95628. * @ignorenaming
  95629. */
  95630. static fallbackTexture: string;
  95631. /**
  95632. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95633. * @param u defines the coordinate on X axis
  95634. * @param v defines the coordinate on Y axis
  95635. * @param width defines the width of the source data
  95636. * @param height defines the height of the source data
  95637. * @param pixels defines the source byte array
  95638. * @param color defines the output color
  95639. */
  95640. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95641. /**
  95642. * Interpolates between a and b via alpha
  95643. * @param a The lower value (returned when alpha = 0)
  95644. * @param b The upper value (returned when alpha = 1)
  95645. * @param alpha The interpolation-factor
  95646. * @return The mixed value
  95647. */
  95648. static Mix(a: number, b: number, alpha: number): number;
  95649. /**
  95650. * Tries to instantiate a new object from a given class name
  95651. * @param className defines the class name to instantiate
  95652. * @returns the new object or null if the system was not able to do the instantiation
  95653. */
  95654. static Instantiate(className: string): any;
  95655. /**
  95656. * Provides a slice function that will work even on IE
  95657. * @param data defines the array to slice
  95658. * @param start defines the start of the data (optional)
  95659. * @param end defines the end of the data (optional)
  95660. * @returns the new sliced array
  95661. */
  95662. static Slice<T>(data: T, start?: number, end?: number): T;
  95663. /**
  95664. * Polyfill for setImmediate
  95665. * @param action defines the action to execute after the current execution block
  95666. */
  95667. static SetImmediate(action: () => void): void;
  95668. /**
  95669. * Function indicating if a number is an exponent of 2
  95670. * @param value defines the value to test
  95671. * @returns true if the value is an exponent of 2
  95672. */
  95673. static IsExponentOfTwo(value: number): boolean;
  95674. private static _tmpFloatArray;
  95675. /**
  95676. * Returns the nearest 32-bit single precision float representation of a Number
  95677. * @param value A Number. If the parameter is of a different type, it will get converted
  95678. * to a number or to NaN if it cannot be converted
  95679. * @returns number
  95680. */
  95681. static FloatRound(value: number): number;
  95682. /**
  95683. * Extracts the filename from a path
  95684. * @param path defines the path to use
  95685. * @returns the filename
  95686. */
  95687. static GetFilename(path: string): string;
  95688. /**
  95689. * Extracts the "folder" part of a path (everything before the filename).
  95690. * @param uri The URI to extract the info from
  95691. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95692. * @returns The "folder" part of the path
  95693. */
  95694. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95695. /**
  95696. * Extracts text content from a DOM element hierarchy
  95697. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95698. */
  95699. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95700. /**
  95701. * Convert an angle in radians to degrees
  95702. * @param angle defines the angle to convert
  95703. * @returns the angle in degrees
  95704. */
  95705. static ToDegrees(angle: number): number;
  95706. /**
  95707. * Convert an angle in degrees to radians
  95708. * @param angle defines the angle to convert
  95709. * @returns the angle in radians
  95710. */
  95711. static ToRadians(angle: number): number;
  95712. /**
  95713. * Encode a buffer to a base64 string
  95714. * @param buffer defines the buffer to encode
  95715. * @returns the encoded string
  95716. */
  95717. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95718. /**
  95719. * Returns an array if obj is not an array
  95720. * @param obj defines the object to evaluate as an array
  95721. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95722. * @returns either obj directly if obj is an array or a new array containing obj
  95723. */
  95724. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95725. /**
  95726. * Gets the pointer prefix to use
  95727. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95728. */
  95729. static GetPointerPrefix(): string;
  95730. /**
  95731. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95732. * @param url define the url we are trying
  95733. * @param element define the dom element where to configure the cors policy
  95734. */
  95735. static SetCorsBehavior(url: string | string[], element: {
  95736. crossOrigin: string | null;
  95737. }): void;
  95738. /**
  95739. * Removes unwanted characters from an url
  95740. * @param url defines the url to clean
  95741. * @returns the cleaned url
  95742. */
  95743. static CleanUrl(url: string): string;
  95744. /**
  95745. * Gets or sets a function used to pre-process url before using them to load assets
  95746. */
  95747. static PreprocessUrl: (url: string) => string;
  95748. /**
  95749. * Loads an image as an HTMLImageElement.
  95750. * @param input url string, ArrayBuffer, or Blob to load
  95751. * @param onLoad callback called when the image successfully loads
  95752. * @param onError callback called when the image fails to load
  95753. * @param offlineProvider offline provider for caching
  95754. * @returns the HTMLImageElement of the loaded image
  95755. */
  95756. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  95757. /**
  95758. * Loads a file
  95759. * @param url url string, ArrayBuffer, or Blob to load
  95760. * @param onSuccess callback called when the file successfully loads
  95761. * @param onProgress callback called while file is loading (if the server supports this mode)
  95762. * @param offlineProvider defines the offline provider for caching
  95763. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  95764. * @param onError callback called when the file fails to load
  95765. * @returns a file request object
  95766. */
  95767. 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;
  95768. /**
  95769. * Loads a file from a url
  95770. * @param url the file url to load
  95771. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  95772. */
  95773. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  95774. /**
  95775. * Load a script (identified by an url). When the url returns, the
  95776. * content of this file is added into a new script element, attached to the DOM (body element)
  95777. * @param scriptUrl defines the url of the script to laod
  95778. * @param onSuccess defines the callback called when the script is loaded
  95779. * @param onError defines the callback to call if an error occurs
  95780. * @param scriptId defines the id of the script element
  95781. */
  95782. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  95783. /**
  95784. * Load an asynchronous script (identified by an url). When the url returns, the
  95785. * content of this file is added into a new script element, attached to the DOM (body element)
  95786. * @param scriptUrl defines the url of the script to laod
  95787. * @param scriptId defines the id of the script element
  95788. * @returns a promise request object
  95789. */
  95790. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  95791. /**
  95792. * Loads a file from a blob
  95793. * @param fileToLoad defines the blob to use
  95794. * @param callback defines the callback to call when data is loaded
  95795. * @param progressCallback defines the callback to call during loading process
  95796. * @returns a file request object
  95797. */
  95798. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  95799. /**
  95800. * Loads a file
  95801. * @param fileToLoad defines the file to load
  95802. * @param callback defines the callback to call when data is loaded
  95803. * @param progressCallBack defines the callback to call during loading process
  95804. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  95805. * @returns a file request object
  95806. */
  95807. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  95808. /**
  95809. * Creates a data url from a given string content
  95810. * @param content defines the content to convert
  95811. * @returns the new data url link
  95812. */
  95813. static FileAsURL(content: string): string;
  95814. /**
  95815. * Format the given number to a specific decimal format
  95816. * @param value defines the number to format
  95817. * @param decimals defines the number of decimals to use
  95818. * @returns the formatted string
  95819. */
  95820. static Format(value: number, decimals?: number): string;
  95821. /**
  95822. * Tries to copy an object by duplicating every property
  95823. * @param source defines the source object
  95824. * @param destination defines the target object
  95825. * @param doNotCopyList defines a list of properties to avoid
  95826. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95827. */
  95828. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  95829. /**
  95830. * Gets a boolean indicating if the given object has no own property
  95831. * @param obj defines the object to test
  95832. * @returns true if object has no own property
  95833. */
  95834. static IsEmpty(obj: any): boolean;
  95835. /**
  95836. * Function used to register events at window level
  95837. * @param windowElement defines the Window object to use
  95838. * @param events defines the events to register
  95839. */
  95840. static RegisterTopRootEvents(windowElement: Window, events: {
  95841. name: string;
  95842. handler: Nullable<(e: FocusEvent) => any>;
  95843. }[]): void;
  95844. /**
  95845. * Function used to unregister events from window level
  95846. * @param windowElement defines the Window object to use
  95847. * @param events defines the events to unregister
  95848. */
  95849. static UnregisterTopRootEvents(windowElement: Window, events: {
  95850. name: string;
  95851. handler: Nullable<(e: FocusEvent) => any>;
  95852. }[]): void;
  95853. /**
  95854. * @ignore
  95855. */
  95856. static _ScreenshotCanvas: HTMLCanvasElement;
  95857. /**
  95858. * Dumps the current bound framebuffer
  95859. * @param width defines the rendering width
  95860. * @param height defines the rendering height
  95861. * @param engine defines the hosting engine
  95862. * @param successCallback defines the callback triggered once the data are available
  95863. * @param mimeType defines the mime type of the result
  95864. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95865. */
  95866. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95867. /**
  95868. * Converts the canvas data to blob.
  95869. * This acts as a polyfill for browsers not supporting the to blob function.
  95870. * @param canvas Defines the canvas to extract the data from
  95871. * @param successCallback Defines the callback triggered once the data are available
  95872. * @param mimeType Defines the mime type of the result
  95873. */
  95874. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95875. /**
  95876. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95877. * @param successCallback defines the callback triggered once the data are available
  95878. * @param mimeType defines the mime type of the result
  95879. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95880. */
  95881. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95882. /**
  95883. * Downloads a blob in the browser
  95884. * @param blob defines the blob to download
  95885. * @param fileName defines the name of the downloaded file
  95886. */
  95887. static Download(blob: Blob, fileName: string): void;
  95888. /**
  95889. * Captures a screenshot of the current rendering
  95890. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95891. * @param engine defines the rendering engine
  95892. * @param camera defines the source camera
  95893. * @param size This parameter can be set to a single number or to an object with the
  95894. * following (optional) properties: precision, width, height. If a single number is passed,
  95895. * it will be used for both width and height. If an object is passed, the screenshot size
  95896. * will be derived from the parameters. The precision property is a multiplier allowing
  95897. * rendering at a higher or lower resolution
  95898. * @param successCallback defines the callback receives a single parameter which contains the
  95899. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95900. * src parameter of an <img> to display it
  95901. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95902. * Check your browser for supported MIME types
  95903. */
  95904. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  95905. /**
  95906. * Captures a screenshot of the current rendering
  95907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95908. * @param engine defines the rendering engine
  95909. * @param camera defines the source camera
  95910. * @param size This parameter can be set to a single number or to an object with the
  95911. * following (optional) properties: precision, width, height. If a single number is passed,
  95912. * it will be used for both width and height. If an object is passed, the screenshot size
  95913. * will be derived from the parameters. The precision property is a multiplier allowing
  95914. * rendering at a higher or lower resolution
  95915. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95916. * Check your browser for supported MIME types
  95917. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95918. * to the src parameter of an <img> to display it
  95919. */
  95920. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  95921. /**
  95922. * Generates an image screenshot from the specified camera.
  95923. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95924. * @param engine The engine to use for rendering
  95925. * @param camera The camera to use for rendering
  95926. * @param size This parameter can be set to a single number or to an object with the
  95927. * following (optional) properties: precision, width, height. If a single number is passed,
  95928. * it will be used for both width and height. If an object is passed, the screenshot size
  95929. * will be derived from the parameters. The precision property is a multiplier allowing
  95930. * rendering at a higher or lower resolution
  95931. * @param successCallback The callback receives a single parameter which contains the
  95932. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95933. * src parameter of an <img> to display it
  95934. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95935. * Check your browser for supported MIME types
  95936. * @param samples Texture samples (default: 1)
  95937. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95938. * @param fileName A name for for the downloaded file.
  95939. */
  95940. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95941. /**
  95942. * Generates an image screenshot from the specified camera.
  95943. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95944. * @param engine The engine to use for rendering
  95945. * @param camera The camera to use for rendering
  95946. * @param size This parameter can be set to a single number or to an object with the
  95947. * following (optional) properties: precision, width, height. If a single number is passed,
  95948. * it will be used for both width and height. If an object is passed, the screenshot size
  95949. * will be derived from the parameters. The precision property is a multiplier allowing
  95950. * rendering at a higher or lower resolution
  95951. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95952. * Check your browser for supported MIME types
  95953. * @param samples Texture samples (default: 1)
  95954. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95955. * @param fileName A name for for the downloaded file.
  95956. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95957. * to the src parameter of an <img> to display it
  95958. */
  95959. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  95960. /**
  95961. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95962. * Be aware Math.random() could cause collisions, but:
  95963. * "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"
  95964. * @returns a pseudo random id
  95965. */
  95966. static RandomId(): string;
  95967. /**
  95968. * Test if the given uri is a base64 string
  95969. * @param uri The uri to test
  95970. * @return True if the uri is a base64 string or false otherwise
  95971. */
  95972. static IsBase64(uri: string): boolean;
  95973. /**
  95974. * Decode the given base64 uri.
  95975. * @param uri The uri to decode
  95976. * @return The decoded base64 data.
  95977. */
  95978. static DecodeBase64(uri: string): ArrayBuffer;
  95979. /**
  95980. * Gets the absolute url.
  95981. * @param url the input url
  95982. * @return the absolute url
  95983. */
  95984. static GetAbsoluteUrl(url: string): string;
  95985. /**
  95986. * No log
  95987. */
  95988. static readonly NoneLogLevel: number;
  95989. /**
  95990. * Only message logs
  95991. */
  95992. static readonly MessageLogLevel: number;
  95993. /**
  95994. * Only warning logs
  95995. */
  95996. static readonly WarningLogLevel: number;
  95997. /**
  95998. * Only error logs
  95999. */
  96000. static readonly ErrorLogLevel: number;
  96001. /**
  96002. * All logs
  96003. */
  96004. static readonly AllLogLevel: number;
  96005. /**
  96006. * Gets a value indicating the number of loading errors
  96007. * @ignorenaming
  96008. */
  96009. static readonly errorsCount: number;
  96010. /**
  96011. * Callback called when a new log is added
  96012. */
  96013. static OnNewCacheEntry: (entry: string) => void;
  96014. /**
  96015. * Log a message to the console
  96016. * @param message defines the message to log
  96017. */
  96018. static Log(message: string): void;
  96019. /**
  96020. * Write a warning message to the console
  96021. * @param message defines the message to log
  96022. */
  96023. static Warn(message: string): void;
  96024. /**
  96025. * Write an error message to the console
  96026. * @param message defines the message to log
  96027. */
  96028. static Error(message: string): void;
  96029. /**
  96030. * Gets current log cache (list of logs)
  96031. */
  96032. static readonly LogCache: string;
  96033. /**
  96034. * Clears the log cache
  96035. */
  96036. static ClearLogCache(): void;
  96037. /**
  96038. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96039. */
  96040. static LogLevels: number;
  96041. /**
  96042. * Checks if the window object exists
  96043. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96044. */
  96045. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96046. /**
  96047. * No performance log
  96048. */
  96049. static readonly PerformanceNoneLogLevel: number;
  96050. /**
  96051. * Use user marks to log performance
  96052. */
  96053. static readonly PerformanceUserMarkLogLevel: number;
  96054. /**
  96055. * Log performance to the console
  96056. */
  96057. static readonly PerformanceConsoleLogLevel: number;
  96058. private static _performance;
  96059. /**
  96060. * Sets the current performance log level
  96061. */
  96062. static PerformanceLogLevel: number;
  96063. private static _StartPerformanceCounterDisabled;
  96064. private static _EndPerformanceCounterDisabled;
  96065. private static _StartUserMark;
  96066. private static _EndUserMark;
  96067. private static _StartPerformanceConsole;
  96068. private static _EndPerformanceConsole;
  96069. /**
  96070. * Starts a performance counter
  96071. */
  96072. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96073. /**
  96074. * Ends a specific performance coutner
  96075. */
  96076. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96077. /**
  96078. * Gets either window.performance.now() if supported or Date.now() else
  96079. */
  96080. static readonly Now: number;
  96081. /**
  96082. * This method will return the name of the class used to create the instance of the given object.
  96083. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96084. * @param object the object to get the class name from
  96085. * @param isType defines if the object is actually a type
  96086. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96087. */
  96088. static GetClassName(object: any, isType?: boolean): string;
  96089. /**
  96090. * Gets the first element of an array satisfying a given predicate
  96091. * @param array defines the array to browse
  96092. * @param predicate defines the predicate to use
  96093. * @returns null if not found or the element
  96094. */
  96095. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96096. /**
  96097. * This method will return the name of the full name of the class, including its owning module (if any).
  96098. * 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).
  96099. * @param object the object to get the class name from
  96100. * @param isType defines if the object is actually a type
  96101. * @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.
  96102. * @ignorenaming
  96103. */
  96104. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96105. /**
  96106. * Returns a promise that resolves after the given amount of time.
  96107. * @param delay Number of milliseconds to delay
  96108. * @returns Promise that resolves after the given amount of time
  96109. */
  96110. static DelayAsync(delay: number): Promise<void>;
  96111. }
  96112. /**
  96113. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96114. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96115. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96116. * @param name The name of the class, case should be preserved
  96117. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96118. */
  96119. export function className(name: string, module?: string): (target: Object) => void;
  96120. /**
  96121. * An implementation of a loop for asynchronous functions.
  96122. */
  96123. export class AsyncLoop {
  96124. /**
  96125. * Defines the number of iterations for the loop
  96126. */
  96127. iterations: number;
  96128. /**
  96129. * Defines the current index of the loop.
  96130. */
  96131. index: number;
  96132. private _done;
  96133. private _fn;
  96134. private _successCallback;
  96135. /**
  96136. * Constructor.
  96137. * @param iterations the number of iterations.
  96138. * @param func the function to run each iteration
  96139. * @param successCallback the callback that will be called upon succesful execution
  96140. * @param offset starting offset.
  96141. */
  96142. constructor(
  96143. /**
  96144. * Defines the number of iterations for the loop
  96145. */
  96146. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96147. /**
  96148. * Execute the next iteration. Must be called after the last iteration was finished.
  96149. */
  96150. executeNext(): void;
  96151. /**
  96152. * Break the loop and run the success callback.
  96153. */
  96154. breakLoop(): void;
  96155. /**
  96156. * Create and run an async loop.
  96157. * @param iterations the number of iterations.
  96158. * @param fn the function to run each iteration
  96159. * @param successCallback the callback that will be called upon succesful execution
  96160. * @param offset starting offset.
  96161. * @returns the created async loop object
  96162. */
  96163. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96164. /**
  96165. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96166. * @param iterations total number of iterations
  96167. * @param syncedIterations number of synchronous iterations in each async iteration.
  96168. * @param fn the function to call each iteration.
  96169. * @param callback a success call back that will be called when iterating stops.
  96170. * @param breakFunction a break condition (optional)
  96171. * @param timeout timeout settings for the setTimeout function. default - 0.
  96172. * @returns the created async loop object
  96173. */
  96174. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96175. }
  96176. }
  96177. declare module BABYLON {
  96178. /** @hidden */
  96179. export interface ICollisionCoordinator {
  96180. createCollider(): Collider;
  96181. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96182. init(scene: Scene): void;
  96183. }
  96184. /** @hidden */
  96185. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96186. private _scene;
  96187. private _scaledPosition;
  96188. private _scaledVelocity;
  96189. private _finalPosition;
  96190. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96191. createCollider(): Collider;
  96192. init(scene: Scene): void;
  96193. private _collideWithWorld;
  96194. }
  96195. }
  96196. declare module BABYLON {
  96197. /**
  96198. * Class used to manage all inputs for the scene.
  96199. */
  96200. export class InputManager {
  96201. /** The distance in pixel that you have to move to prevent some events */
  96202. static DragMovementThreshold: number;
  96203. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96204. static LongPressDelay: number;
  96205. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96206. static DoubleClickDelay: number;
  96207. /** If you need to check double click without raising a single click at first click, enable this flag */
  96208. static ExclusiveDoubleClickMode: boolean;
  96209. private _wheelEventName;
  96210. private _onPointerMove;
  96211. private _onPointerDown;
  96212. private _onPointerUp;
  96213. private _initClickEvent;
  96214. private _initActionManager;
  96215. private _delayedSimpleClick;
  96216. private _delayedSimpleClickTimeout;
  96217. private _previousDelayedSimpleClickTimeout;
  96218. private _meshPickProceed;
  96219. private _previousButtonPressed;
  96220. private _currentPickResult;
  96221. private _previousPickResult;
  96222. private _totalPointersPressed;
  96223. private _doubleClickOccured;
  96224. private _pointerOverMesh;
  96225. private _pickedDownMesh;
  96226. private _pickedUpMesh;
  96227. private _pointerX;
  96228. private _pointerY;
  96229. private _unTranslatedPointerX;
  96230. private _unTranslatedPointerY;
  96231. private _startingPointerPosition;
  96232. private _previousStartingPointerPosition;
  96233. private _startingPointerTime;
  96234. private _previousStartingPointerTime;
  96235. private _pointerCaptures;
  96236. private _onKeyDown;
  96237. private _onKeyUp;
  96238. private _onCanvasFocusObserver;
  96239. private _onCanvasBlurObserver;
  96240. private _scene;
  96241. /**
  96242. * Creates a new InputManager
  96243. * @param scene defines the hosting scene
  96244. */
  96245. constructor(scene: Scene);
  96246. /**
  96247. * Gets the mesh that is currently under the pointer
  96248. */
  96249. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96250. /**
  96251. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96252. */
  96253. readonly unTranslatedPointer: Vector2;
  96254. /**
  96255. * Gets or sets the current on-screen X position of the pointer
  96256. */
  96257. pointerX: number;
  96258. /**
  96259. * Gets or sets the current on-screen Y position of the pointer
  96260. */
  96261. pointerY: number;
  96262. private _updatePointerPosition;
  96263. private _processPointerMove;
  96264. private _setRayOnPointerInfo;
  96265. private _checkPrePointerObservable;
  96266. /**
  96267. * Use this method to simulate a pointer move on a mesh
  96268. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96269. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96270. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96271. */
  96272. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96273. /**
  96274. * Use this method to simulate a pointer down on a mesh
  96275. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96276. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96277. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96278. */
  96279. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96280. private _processPointerDown;
  96281. /** @hidden */
  96282. _isPointerSwiping(): boolean;
  96283. /**
  96284. * Use this method to simulate a pointer up on a mesh
  96285. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96286. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96287. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96288. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96289. */
  96290. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96291. private _processPointerUp;
  96292. /**
  96293. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96294. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96295. * @returns true if the pointer was captured
  96296. */
  96297. isPointerCaptured(pointerId?: number): boolean;
  96298. /**
  96299. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96300. * @param attachUp defines if you want to attach events to pointerup
  96301. * @param attachDown defines if you want to attach events to pointerdown
  96302. * @param attachMove defines if you want to attach events to pointermove
  96303. */
  96304. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96305. /**
  96306. * Detaches all event handlers
  96307. */
  96308. detachControl(): void;
  96309. /**
  96310. * Force the value of meshUnderPointer
  96311. * @param mesh defines the mesh to use
  96312. */
  96313. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96314. /**
  96315. * Gets the mesh under the pointer
  96316. * @returns a Mesh or null if no mesh is under the pointer
  96317. */
  96318. getPointerOverMesh(): Nullable<AbstractMesh>;
  96319. }
  96320. }
  96321. declare module BABYLON {
  96322. /**
  96323. * Helper class used to generate session unique ID
  96324. */
  96325. export class UniqueIdGenerator {
  96326. private static _UniqueIdCounter;
  96327. /**
  96328. * Gets an unique (relatively to the current scene) Id
  96329. */
  96330. static readonly UniqueId: number;
  96331. }
  96332. }
  96333. declare module BABYLON {
  96334. /**
  96335. * This class defines the direct association between an animation and a target
  96336. */
  96337. export class TargetedAnimation {
  96338. /**
  96339. * Animation to perform
  96340. */
  96341. animation: Animation;
  96342. /**
  96343. * Target to animate
  96344. */
  96345. target: any;
  96346. /**
  96347. * Serialize the object
  96348. * @returns the JSON object representing the current entity
  96349. */
  96350. serialize(): any;
  96351. }
  96352. /**
  96353. * Use this class to create coordinated animations on multiple targets
  96354. */
  96355. export class AnimationGroup implements IDisposable {
  96356. /** The name of the animation group */
  96357. name: string;
  96358. private _scene;
  96359. private _targetedAnimations;
  96360. private _animatables;
  96361. private _from;
  96362. private _to;
  96363. private _isStarted;
  96364. private _isPaused;
  96365. private _speedRatio;
  96366. private _loopAnimation;
  96367. /**
  96368. * Gets or sets the unique id of the node
  96369. */
  96370. uniqueId: number;
  96371. /**
  96372. * This observable will notify when one animation have ended
  96373. */
  96374. onAnimationEndObservable: Observable<TargetedAnimation>;
  96375. /**
  96376. * Observer raised when one animation loops
  96377. */
  96378. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96379. /**
  96380. * This observable will notify when all animations have ended.
  96381. */
  96382. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96383. /**
  96384. * This observable will notify when all animations have paused.
  96385. */
  96386. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96387. /**
  96388. * This observable will notify when all animations are playing.
  96389. */
  96390. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96391. /**
  96392. * Gets the first frame
  96393. */
  96394. readonly from: number;
  96395. /**
  96396. * Gets the last frame
  96397. */
  96398. readonly to: number;
  96399. /**
  96400. * Define if the animations are started
  96401. */
  96402. readonly isStarted: boolean;
  96403. /**
  96404. * Gets a value indicating that the current group is playing
  96405. */
  96406. readonly isPlaying: boolean;
  96407. /**
  96408. * Gets or sets the speed ratio to use for all animations
  96409. */
  96410. /**
  96411. * Gets or sets the speed ratio to use for all animations
  96412. */
  96413. speedRatio: number;
  96414. /**
  96415. * Gets or sets if all animations should loop or not
  96416. */
  96417. loopAnimation: boolean;
  96418. /**
  96419. * Gets the targeted animations for this animation group
  96420. */
  96421. readonly targetedAnimations: Array<TargetedAnimation>;
  96422. /**
  96423. * returning the list of animatables controlled by this animation group.
  96424. */
  96425. readonly animatables: Array<Animatable>;
  96426. /**
  96427. * Instantiates a new Animation Group.
  96428. * This helps managing several animations at once.
  96429. * @see http://doc.babylonjs.com/how_to/group
  96430. * @param name Defines the name of the group
  96431. * @param scene Defines the scene the group belongs to
  96432. */
  96433. constructor(
  96434. /** The name of the animation group */
  96435. name: string, scene?: Nullable<Scene>);
  96436. /**
  96437. * Add an animation (with its target) in the group
  96438. * @param animation defines the animation we want to add
  96439. * @param target defines the target of the animation
  96440. * @returns the TargetedAnimation object
  96441. */
  96442. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96443. /**
  96444. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96445. * It can add constant keys at begin or end
  96446. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96447. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96448. * @returns the animation group
  96449. */
  96450. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96451. /**
  96452. * Start all animations on given targets
  96453. * @param loop defines if animations must loop
  96454. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96455. * @param from defines the from key (optional)
  96456. * @param to defines the to key (optional)
  96457. * @returns the current animation group
  96458. */
  96459. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96460. /**
  96461. * Pause all animations
  96462. * @returns the animation group
  96463. */
  96464. pause(): AnimationGroup;
  96465. /**
  96466. * Play all animations to initial state
  96467. * This function will start() the animations if they were not started or will restart() them if they were paused
  96468. * @param loop defines if animations must loop
  96469. * @returns the animation group
  96470. */
  96471. play(loop?: boolean): AnimationGroup;
  96472. /**
  96473. * Reset all animations to initial state
  96474. * @returns the animation group
  96475. */
  96476. reset(): AnimationGroup;
  96477. /**
  96478. * Restart animations from key 0
  96479. * @returns the animation group
  96480. */
  96481. restart(): AnimationGroup;
  96482. /**
  96483. * Stop all animations
  96484. * @returns the animation group
  96485. */
  96486. stop(): AnimationGroup;
  96487. /**
  96488. * Set animation weight for all animatables
  96489. * @param weight defines the weight to use
  96490. * @return the animationGroup
  96491. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96492. */
  96493. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96494. /**
  96495. * Synchronize and normalize all animatables with a source animatable
  96496. * @param root defines the root animatable to synchronize with
  96497. * @return the animationGroup
  96498. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96499. */
  96500. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96501. /**
  96502. * Goes to a specific frame in this animation group
  96503. * @param frame the frame number to go to
  96504. * @return the animationGroup
  96505. */
  96506. goToFrame(frame: number): AnimationGroup;
  96507. /**
  96508. * Dispose all associated resources
  96509. */
  96510. dispose(): void;
  96511. private _checkAnimationGroupEnded;
  96512. /**
  96513. * Clone the current animation group and returns a copy
  96514. * @param newName defines the name of the new group
  96515. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96516. * @returns the new aniamtion group
  96517. */
  96518. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96519. /**
  96520. * Serializes the animationGroup to an object
  96521. * @returns Serialized object
  96522. */
  96523. serialize(): any;
  96524. /**
  96525. * Returns a new AnimationGroup object parsed from the source provided.
  96526. * @param parsedAnimationGroup defines the source
  96527. * @param scene defines the scene that will receive the animationGroup
  96528. * @returns a new AnimationGroup
  96529. */
  96530. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96531. /**
  96532. * Returns the string "AnimationGroup"
  96533. * @returns "AnimationGroup"
  96534. */
  96535. getClassName(): string;
  96536. /**
  96537. * Creates a detailled string about the object
  96538. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96539. * @returns a string representing the object
  96540. */
  96541. toString(fullDetails?: boolean): string;
  96542. }
  96543. }
  96544. declare module BABYLON {
  96545. /**
  96546. * Define an interface for all classes that will hold resources
  96547. */
  96548. export interface IDisposable {
  96549. /**
  96550. * Releases all held resources
  96551. */
  96552. dispose(): void;
  96553. }
  96554. /** Interface defining initialization parameters for Scene class */
  96555. export interface SceneOptions {
  96556. /**
  96557. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96558. * It will improve performance when the number of geometries becomes important.
  96559. */
  96560. useGeometryUniqueIdsMap?: boolean;
  96561. /**
  96562. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96563. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96564. */
  96565. useMaterialMeshMap?: boolean;
  96566. /**
  96567. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96568. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96569. */
  96570. useClonedMeshhMap?: boolean;
  96571. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96572. virtual?: boolean;
  96573. }
  96574. /**
  96575. * Represents a scene to be rendered by the engine.
  96576. * @see http://doc.babylonjs.com/features/scene
  96577. */
  96578. export class Scene extends AbstractScene implements IAnimatable {
  96579. /** The fog is deactivated */
  96580. static readonly FOGMODE_NONE: number;
  96581. /** The fog density is following an exponential function */
  96582. static readonly FOGMODE_EXP: number;
  96583. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96584. static readonly FOGMODE_EXP2: number;
  96585. /** The fog density is following a linear function. */
  96586. static readonly FOGMODE_LINEAR: number;
  96587. /**
  96588. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96589. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96590. */
  96591. static MinDeltaTime: number;
  96592. /**
  96593. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96594. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96595. */
  96596. static MaxDeltaTime: number;
  96597. /**
  96598. * Factory used to create the default material.
  96599. * @param name The name of the material to create
  96600. * @param scene The scene to create the material for
  96601. * @returns The default material
  96602. */
  96603. static DefaultMaterialFactory(scene: Scene): Material;
  96604. /**
  96605. * Factory used to create the a collision coordinator.
  96606. * @returns The collision coordinator
  96607. */
  96608. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96609. /** @hidden */
  96610. _inputManager: InputManager;
  96611. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96612. cameraToUseForPointers: Nullable<Camera>;
  96613. /** @hidden */
  96614. readonly _isScene: boolean;
  96615. /**
  96616. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96617. */
  96618. autoClear: boolean;
  96619. /**
  96620. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96621. */
  96622. autoClearDepthAndStencil: boolean;
  96623. /**
  96624. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96625. */
  96626. clearColor: Color4;
  96627. /**
  96628. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96629. */
  96630. ambientColor: Color3;
  96631. /**
  96632. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96633. * It should only be one of the following (if not the default embedded one):
  96634. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96635. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96636. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96637. * The material properties need to be setup according to the type of texture in use.
  96638. */
  96639. environmentBRDFTexture: BaseTexture;
  96640. /** @hidden */
  96641. protected _environmentTexture: Nullable<BaseTexture>;
  96642. /**
  96643. * Texture used in all pbr material as the reflection texture.
  96644. * As in the majority of the scene they are the same (exception for multi room and so on),
  96645. * this is easier to reference from here than from all the materials.
  96646. */
  96647. /**
  96648. * Texture used in all pbr material as the reflection texture.
  96649. * As in the majority of the scene they are the same (exception for multi room and so on),
  96650. * this is easier to set here than in all the materials.
  96651. */
  96652. environmentTexture: Nullable<BaseTexture>;
  96653. /** @hidden */
  96654. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96655. /**
  96656. * Default image processing configuration used either in the rendering
  96657. * Forward main pass or through the imageProcessingPostProcess if present.
  96658. * As in the majority of the scene they are the same (exception for multi camera),
  96659. * this is easier to reference from here than from all the materials and post process.
  96660. *
  96661. * No setter as we it is a shared configuration, you can set the values instead.
  96662. */
  96663. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96664. private _forceWireframe;
  96665. /**
  96666. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96667. */
  96668. forceWireframe: boolean;
  96669. private _forcePointsCloud;
  96670. /**
  96671. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96672. */
  96673. forcePointsCloud: boolean;
  96674. /**
  96675. * Gets or sets the active clipplane 1
  96676. */
  96677. clipPlane: Nullable<Plane>;
  96678. /**
  96679. * Gets or sets the active clipplane 2
  96680. */
  96681. clipPlane2: Nullable<Plane>;
  96682. /**
  96683. * Gets or sets the active clipplane 3
  96684. */
  96685. clipPlane3: Nullable<Plane>;
  96686. /**
  96687. * Gets or sets the active clipplane 4
  96688. */
  96689. clipPlane4: Nullable<Plane>;
  96690. /**
  96691. * Gets or sets a boolean indicating if animations are enabled
  96692. */
  96693. animationsEnabled: boolean;
  96694. private _animationPropertiesOverride;
  96695. /**
  96696. * Gets or sets the animation properties override
  96697. */
  96698. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96699. /**
  96700. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96701. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96702. */
  96703. useConstantAnimationDeltaTime: boolean;
  96704. /**
  96705. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96706. * Please note that it requires to run a ray cast through the scene on every frame
  96707. */
  96708. constantlyUpdateMeshUnderPointer: boolean;
  96709. /**
  96710. * Defines the HTML cursor to use when hovering over interactive elements
  96711. */
  96712. hoverCursor: string;
  96713. /**
  96714. * Defines the HTML default cursor to use (empty by default)
  96715. */
  96716. defaultCursor: string;
  96717. /**
  96718. * This is used to call preventDefault() on pointer down
  96719. * in order to block unwanted artifacts like system double clicks
  96720. */
  96721. preventDefaultOnPointerDown: boolean;
  96722. /**
  96723. * This is used to call preventDefault() on pointer up
  96724. * in order to block unwanted artifacts like system double clicks
  96725. */
  96726. preventDefaultOnPointerUp: boolean;
  96727. /**
  96728. * Gets or sets user defined metadata
  96729. */
  96730. metadata: any;
  96731. /**
  96732. * For internal use only. Please do not use.
  96733. */
  96734. reservedDataStore: any;
  96735. /**
  96736. * Gets the name of the plugin used to load this scene (null by default)
  96737. */
  96738. loadingPluginName: string;
  96739. /**
  96740. * Use this array to add regular expressions used to disable offline support for specific urls
  96741. */
  96742. disableOfflineSupportExceptionRules: RegExp[];
  96743. /**
  96744. * An event triggered when the scene is disposed.
  96745. */
  96746. onDisposeObservable: Observable<Scene>;
  96747. private _onDisposeObserver;
  96748. /** Sets a function to be executed when this scene is disposed. */
  96749. onDispose: () => void;
  96750. /**
  96751. * An event triggered before rendering the scene (right after animations and physics)
  96752. */
  96753. onBeforeRenderObservable: Observable<Scene>;
  96754. private _onBeforeRenderObserver;
  96755. /** Sets a function to be executed before rendering this scene */
  96756. beforeRender: Nullable<() => void>;
  96757. /**
  96758. * An event triggered after rendering the scene
  96759. */
  96760. onAfterRenderObservable: Observable<Scene>;
  96761. /**
  96762. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  96763. */
  96764. onAfterRenderCameraObservable: Observable<Camera>;
  96765. private _onAfterRenderObserver;
  96766. /** Sets a function to be executed after rendering this scene */
  96767. afterRender: Nullable<() => void>;
  96768. /**
  96769. * An event triggered before animating the scene
  96770. */
  96771. onBeforeAnimationsObservable: Observable<Scene>;
  96772. /**
  96773. * An event triggered after animations processing
  96774. */
  96775. onAfterAnimationsObservable: Observable<Scene>;
  96776. /**
  96777. * An event triggered before draw calls are ready to be sent
  96778. */
  96779. onBeforeDrawPhaseObservable: Observable<Scene>;
  96780. /**
  96781. * An event triggered after draw calls have been sent
  96782. */
  96783. onAfterDrawPhaseObservable: Observable<Scene>;
  96784. /**
  96785. * An event triggered when the scene is ready
  96786. */
  96787. onReadyObservable: Observable<Scene>;
  96788. /**
  96789. * An event triggered before rendering a camera
  96790. */
  96791. onBeforeCameraRenderObservable: Observable<Camera>;
  96792. private _onBeforeCameraRenderObserver;
  96793. /** Sets a function to be executed before rendering a camera*/
  96794. beforeCameraRender: () => void;
  96795. /**
  96796. * An event triggered after rendering a camera
  96797. */
  96798. onAfterCameraRenderObservable: Observable<Camera>;
  96799. private _onAfterCameraRenderObserver;
  96800. /** Sets a function to be executed after rendering a camera*/
  96801. afterCameraRender: () => void;
  96802. /**
  96803. * An event triggered when active meshes evaluation is about to start
  96804. */
  96805. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  96806. /**
  96807. * An event triggered when active meshes evaluation is done
  96808. */
  96809. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  96810. /**
  96811. * An event triggered when particles rendering is about to start
  96812. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96813. */
  96814. onBeforeParticlesRenderingObservable: Observable<Scene>;
  96815. /**
  96816. * An event triggered when particles rendering is done
  96817. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96818. */
  96819. onAfterParticlesRenderingObservable: Observable<Scene>;
  96820. /**
  96821. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  96822. */
  96823. onDataLoadedObservable: Observable<Scene>;
  96824. /**
  96825. * An event triggered when a camera is created
  96826. */
  96827. onNewCameraAddedObservable: Observable<Camera>;
  96828. /**
  96829. * An event triggered when a camera is removed
  96830. */
  96831. onCameraRemovedObservable: Observable<Camera>;
  96832. /**
  96833. * An event triggered when a light is created
  96834. */
  96835. onNewLightAddedObservable: Observable<Light>;
  96836. /**
  96837. * An event triggered when a light is removed
  96838. */
  96839. onLightRemovedObservable: Observable<Light>;
  96840. /**
  96841. * An event triggered when a geometry is created
  96842. */
  96843. onNewGeometryAddedObservable: Observable<Geometry>;
  96844. /**
  96845. * An event triggered when a geometry is removed
  96846. */
  96847. onGeometryRemovedObservable: Observable<Geometry>;
  96848. /**
  96849. * An event triggered when a transform node is created
  96850. */
  96851. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  96852. /**
  96853. * An event triggered when a transform node is removed
  96854. */
  96855. onTransformNodeRemovedObservable: Observable<TransformNode>;
  96856. /**
  96857. * An event triggered when a mesh is created
  96858. */
  96859. onNewMeshAddedObservable: Observable<AbstractMesh>;
  96860. /**
  96861. * An event triggered when a mesh is removed
  96862. */
  96863. onMeshRemovedObservable: Observable<AbstractMesh>;
  96864. /**
  96865. * An event triggered when a skeleton is created
  96866. */
  96867. onNewSkeletonAddedObservable: Observable<Skeleton>;
  96868. /**
  96869. * An event triggered when a skeleton is removed
  96870. */
  96871. onSkeletonRemovedObservable: Observable<Skeleton>;
  96872. /**
  96873. * An event triggered when a material is created
  96874. */
  96875. onNewMaterialAddedObservable: Observable<Material>;
  96876. /**
  96877. * An event triggered when a material is removed
  96878. */
  96879. onMaterialRemovedObservable: Observable<Material>;
  96880. /**
  96881. * An event triggered when a texture is created
  96882. */
  96883. onNewTextureAddedObservable: Observable<BaseTexture>;
  96884. /**
  96885. * An event triggered when a texture is removed
  96886. */
  96887. onTextureRemovedObservable: Observable<BaseTexture>;
  96888. /**
  96889. * An event triggered when render targets are about to be rendered
  96890. * Can happen multiple times per frame.
  96891. */
  96892. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96893. /**
  96894. * An event triggered when render targets were rendered.
  96895. * Can happen multiple times per frame.
  96896. */
  96897. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96898. /**
  96899. * An event triggered before calculating deterministic simulation step
  96900. */
  96901. onBeforeStepObservable: Observable<Scene>;
  96902. /**
  96903. * An event triggered after calculating deterministic simulation step
  96904. */
  96905. onAfterStepObservable: Observable<Scene>;
  96906. /**
  96907. * An event triggered when the activeCamera property is updated
  96908. */
  96909. onActiveCameraChanged: Observable<Scene>;
  96910. /**
  96911. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96912. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96913. * 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)
  96914. */
  96915. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96916. /**
  96917. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96918. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96919. * 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)
  96920. */
  96921. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96922. /**
  96923. * This Observable will when a mesh has been imported into the scene.
  96924. */
  96925. onMeshImportedObservable: Observable<AbstractMesh>;
  96926. /**
  96927. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96928. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96929. */
  96930. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96931. /** @hidden */
  96932. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96933. /**
  96934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96935. */
  96936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96937. /**
  96938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96939. */
  96940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96941. /**
  96942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96943. */
  96944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96945. /** Callback called when a pointer move is detected */
  96946. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96947. /** Callback called when a pointer down is detected */
  96948. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96949. /** Callback called when a pointer up is detected */
  96950. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96951. /** Callback called when a pointer pick is detected */
  96952. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96953. /**
  96954. * 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).
  96955. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96956. */
  96957. onPrePointerObservable: Observable<PointerInfoPre>;
  96958. /**
  96959. * Observable event triggered each time an input event is received from the rendering canvas
  96960. */
  96961. onPointerObservable: Observable<PointerInfo>;
  96962. /**
  96963. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96964. */
  96965. readonly unTranslatedPointer: Vector2;
  96966. /**
  96967. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96968. */
  96969. static DragMovementThreshold: number;
  96970. /**
  96971. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96972. */
  96973. static LongPressDelay: number;
  96974. /**
  96975. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96976. */
  96977. static DoubleClickDelay: number;
  96978. /** If you need to check double click without raising a single click at first click, enable this flag */
  96979. static ExclusiveDoubleClickMode: boolean;
  96980. /** @hidden */
  96981. _mirroredCameraPosition: Nullable<Vector3>;
  96982. /**
  96983. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96984. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96985. */
  96986. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96987. /**
  96988. * Observable event triggered each time an keyboard event is received from the hosting window
  96989. */
  96990. onKeyboardObservable: Observable<KeyboardInfo>;
  96991. private _useRightHandedSystem;
  96992. /**
  96993. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96994. */
  96995. useRightHandedSystem: boolean;
  96996. private _timeAccumulator;
  96997. private _currentStepId;
  96998. private _currentInternalStep;
  96999. /**
  97000. * Sets the step Id used by deterministic lock step
  97001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97002. * @param newStepId defines the step Id
  97003. */
  97004. setStepId(newStepId: number): void;
  97005. /**
  97006. * Gets the step Id used by deterministic lock step
  97007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97008. * @returns the step Id
  97009. */
  97010. getStepId(): number;
  97011. /**
  97012. * Gets the internal step used by deterministic lock step
  97013. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97014. * @returns the internal step
  97015. */
  97016. getInternalStep(): number;
  97017. private _fogEnabled;
  97018. /**
  97019. * Gets or sets a boolean indicating if fog is enabled on this scene
  97020. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97021. * (Default is true)
  97022. */
  97023. fogEnabled: boolean;
  97024. private _fogMode;
  97025. /**
  97026. * Gets or sets the fog mode to use
  97027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97028. * | mode | value |
  97029. * | --- | --- |
  97030. * | FOGMODE_NONE | 0 |
  97031. * | FOGMODE_EXP | 1 |
  97032. * | FOGMODE_EXP2 | 2 |
  97033. * | FOGMODE_LINEAR | 3 |
  97034. */
  97035. fogMode: number;
  97036. /**
  97037. * Gets or sets the fog color to use
  97038. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97039. * (Default is Color3(0.2, 0.2, 0.3))
  97040. */
  97041. fogColor: Color3;
  97042. /**
  97043. * Gets or sets the fog density to use
  97044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97045. * (Default is 0.1)
  97046. */
  97047. fogDensity: number;
  97048. /**
  97049. * Gets or sets the fog start distance to use
  97050. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97051. * (Default is 0)
  97052. */
  97053. fogStart: number;
  97054. /**
  97055. * Gets or sets the fog end distance to use
  97056. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97057. * (Default is 1000)
  97058. */
  97059. fogEnd: number;
  97060. private _shadowsEnabled;
  97061. /**
  97062. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97063. */
  97064. shadowsEnabled: boolean;
  97065. private _lightsEnabled;
  97066. /**
  97067. * Gets or sets a boolean indicating if lights are enabled on this scene
  97068. */
  97069. lightsEnabled: boolean;
  97070. /** All of the active cameras added to this scene. */
  97071. activeCameras: Camera[];
  97072. /** @hidden */
  97073. _activeCamera: Nullable<Camera>;
  97074. /** Gets or sets the current active camera */
  97075. activeCamera: Nullable<Camera>;
  97076. private _defaultMaterial;
  97077. /** The default material used on meshes when no material is affected */
  97078. /** The default material used on meshes when no material is affected */
  97079. defaultMaterial: Material;
  97080. private _texturesEnabled;
  97081. /**
  97082. * Gets or sets a boolean indicating if textures are enabled on this scene
  97083. */
  97084. texturesEnabled: boolean;
  97085. /**
  97086. * Gets or sets a boolean indicating if particles are enabled on this scene
  97087. */
  97088. particlesEnabled: boolean;
  97089. /**
  97090. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97091. */
  97092. spritesEnabled: boolean;
  97093. private _skeletonsEnabled;
  97094. /**
  97095. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97096. */
  97097. skeletonsEnabled: boolean;
  97098. /**
  97099. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97100. */
  97101. lensFlaresEnabled: boolean;
  97102. /**
  97103. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97105. */
  97106. collisionsEnabled: boolean;
  97107. private _collisionCoordinator;
  97108. /** @hidden */
  97109. readonly collisionCoordinator: ICollisionCoordinator;
  97110. /**
  97111. * Defines the gravity applied to this scene (used only for collisions)
  97112. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97113. */
  97114. gravity: Vector3;
  97115. /**
  97116. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97117. */
  97118. postProcessesEnabled: boolean;
  97119. /**
  97120. * The list of postprocesses added to the scene
  97121. */
  97122. postProcesses: PostProcess[];
  97123. /**
  97124. * Gets the current postprocess manager
  97125. */
  97126. postProcessManager: PostProcessManager;
  97127. /**
  97128. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97129. */
  97130. renderTargetsEnabled: boolean;
  97131. /**
  97132. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97133. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97134. */
  97135. dumpNextRenderTargets: boolean;
  97136. /**
  97137. * The list of user defined render targets added to the scene
  97138. */
  97139. customRenderTargets: RenderTargetTexture[];
  97140. /**
  97141. * Defines if texture loading must be delayed
  97142. * If true, textures will only be loaded when they need to be rendered
  97143. */
  97144. useDelayedTextureLoading: boolean;
  97145. /**
  97146. * Gets the list of meshes imported to the scene through SceneLoader
  97147. */
  97148. importedMeshesFiles: String[];
  97149. /**
  97150. * Gets or sets a boolean indicating if probes are enabled on this scene
  97151. */
  97152. probesEnabled: boolean;
  97153. /**
  97154. * Gets or sets the current offline provider to use to store scene data
  97155. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97156. */
  97157. offlineProvider: IOfflineProvider;
  97158. /**
  97159. * Gets or sets the action manager associated with the scene
  97160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97161. */
  97162. actionManager: AbstractActionManager;
  97163. private _meshesForIntersections;
  97164. /**
  97165. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97166. */
  97167. proceduralTexturesEnabled: boolean;
  97168. private _engine;
  97169. private _totalVertices;
  97170. /** @hidden */
  97171. _activeIndices: PerfCounter;
  97172. /** @hidden */
  97173. _activeParticles: PerfCounter;
  97174. /** @hidden */
  97175. _activeBones: PerfCounter;
  97176. private _animationRatio;
  97177. /** @hidden */
  97178. _animationTimeLast: number;
  97179. /** @hidden */
  97180. _animationTime: number;
  97181. /**
  97182. * Gets or sets a general scale for animation speed
  97183. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97184. */
  97185. animationTimeScale: number;
  97186. /** @hidden */
  97187. _cachedMaterial: Nullable<Material>;
  97188. /** @hidden */
  97189. _cachedEffect: Nullable<Effect>;
  97190. /** @hidden */
  97191. _cachedVisibility: Nullable<number>;
  97192. private _renderId;
  97193. private _frameId;
  97194. private _executeWhenReadyTimeoutId;
  97195. private _intermediateRendering;
  97196. private _viewUpdateFlag;
  97197. private _projectionUpdateFlag;
  97198. /** @hidden */
  97199. _toBeDisposed: Nullable<IDisposable>[];
  97200. private _activeRequests;
  97201. /** @hidden */
  97202. _pendingData: any[];
  97203. private _isDisposed;
  97204. /**
  97205. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97206. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97207. */
  97208. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97209. private _activeMeshes;
  97210. private _processedMaterials;
  97211. private _renderTargets;
  97212. /** @hidden */
  97213. _activeParticleSystems: SmartArray<IParticleSystem>;
  97214. private _activeSkeletons;
  97215. private _softwareSkinnedMeshes;
  97216. private _renderingManager;
  97217. /** @hidden */
  97218. _activeAnimatables: Animatable[];
  97219. private _transformMatrix;
  97220. private _sceneUbo;
  97221. /** @hidden */
  97222. _viewMatrix: Matrix;
  97223. private _projectionMatrix;
  97224. /** @hidden */
  97225. _forcedViewPosition: Nullable<Vector3>;
  97226. /** @hidden */
  97227. _frustumPlanes: Plane[];
  97228. /**
  97229. * Gets the list of frustum planes (built from the active camera)
  97230. */
  97231. readonly frustumPlanes: Plane[];
  97232. /**
  97233. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97234. * This is useful if there are more lights that the maximum simulteanous authorized
  97235. */
  97236. requireLightSorting: boolean;
  97237. /** @hidden */
  97238. readonly useMaterialMeshMap: boolean;
  97239. /** @hidden */
  97240. readonly useClonedMeshhMap: boolean;
  97241. private _externalData;
  97242. private _uid;
  97243. /**
  97244. * @hidden
  97245. * Backing store of defined scene components.
  97246. */
  97247. _components: ISceneComponent[];
  97248. /**
  97249. * @hidden
  97250. * Backing store of defined scene components.
  97251. */
  97252. _serializableComponents: ISceneSerializableComponent[];
  97253. /**
  97254. * List of components to register on the next registration step.
  97255. */
  97256. private _transientComponents;
  97257. /**
  97258. * Registers the transient components if needed.
  97259. */
  97260. private _registerTransientComponents;
  97261. /**
  97262. * @hidden
  97263. * Add a component to the scene.
  97264. * Note that the ccomponent could be registered on th next frame if this is called after
  97265. * the register component stage.
  97266. * @param component Defines the component to add to the scene
  97267. */
  97268. _addComponent(component: ISceneComponent): void;
  97269. /**
  97270. * @hidden
  97271. * Gets a component from the scene.
  97272. * @param name defines the name of the component to retrieve
  97273. * @returns the component or null if not present
  97274. */
  97275. _getComponent(name: string): Nullable<ISceneComponent>;
  97276. /**
  97277. * @hidden
  97278. * Defines the actions happening before camera updates.
  97279. */
  97280. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97281. /**
  97282. * @hidden
  97283. * Defines the actions happening before clear the canvas.
  97284. */
  97285. _beforeClearStage: Stage<SimpleStageAction>;
  97286. /**
  97287. * @hidden
  97288. * Defines the actions when collecting render targets for the frame.
  97289. */
  97290. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97291. /**
  97292. * @hidden
  97293. * Defines the actions happening for one camera in the frame.
  97294. */
  97295. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97296. /**
  97297. * @hidden
  97298. * Defines the actions happening during the per mesh ready checks.
  97299. */
  97300. _isReadyForMeshStage: Stage<MeshStageAction>;
  97301. /**
  97302. * @hidden
  97303. * Defines the actions happening before evaluate active mesh checks.
  97304. */
  97305. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97306. /**
  97307. * @hidden
  97308. * Defines the actions happening during the evaluate sub mesh checks.
  97309. */
  97310. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97311. /**
  97312. * @hidden
  97313. * Defines the actions happening during the active mesh stage.
  97314. */
  97315. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97316. /**
  97317. * @hidden
  97318. * Defines the actions happening during the per camera render target step.
  97319. */
  97320. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97321. /**
  97322. * @hidden
  97323. * Defines the actions happening just before the active camera is drawing.
  97324. */
  97325. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97326. /**
  97327. * @hidden
  97328. * Defines the actions happening just before a render target is drawing.
  97329. */
  97330. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97331. /**
  97332. * @hidden
  97333. * Defines the actions happening just before a rendering group is drawing.
  97334. */
  97335. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97336. /**
  97337. * @hidden
  97338. * Defines the actions happening just before a mesh is drawing.
  97339. */
  97340. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97341. /**
  97342. * @hidden
  97343. * Defines the actions happening just after a mesh has been drawn.
  97344. */
  97345. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97346. /**
  97347. * @hidden
  97348. * Defines the actions happening just after a rendering group has been drawn.
  97349. */
  97350. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97351. /**
  97352. * @hidden
  97353. * Defines the actions happening just after the active camera has been drawn.
  97354. */
  97355. _afterCameraDrawStage: Stage<CameraStageAction>;
  97356. /**
  97357. * @hidden
  97358. * Defines the actions happening just after a render target has been drawn.
  97359. */
  97360. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97361. /**
  97362. * @hidden
  97363. * Defines the actions happening just after rendering all cameras and computing intersections.
  97364. */
  97365. _afterRenderStage: Stage<SimpleStageAction>;
  97366. /**
  97367. * @hidden
  97368. * Defines the actions happening when a pointer move event happens.
  97369. */
  97370. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97371. /**
  97372. * @hidden
  97373. * Defines the actions happening when a pointer down event happens.
  97374. */
  97375. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97376. /**
  97377. * @hidden
  97378. * Defines the actions happening when a pointer up event happens.
  97379. */
  97380. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97381. /**
  97382. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97383. */
  97384. private geometriesByUniqueId;
  97385. /**
  97386. * Creates a new Scene
  97387. * @param engine defines the engine to use to render this scene
  97388. * @param options defines the scene options
  97389. */
  97390. constructor(engine: Engine, options?: SceneOptions);
  97391. /**
  97392. * Gets a string idenfifying the name of the class
  97393. * @returns "Scene" string
  97394. */
  97395. getClassName(): string;
  97396. private _defaultMeshCandidates;
  97397. /**
  97398. * @hidden
  97399. */
  97400. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97401. private _defaultSubMeshCandidates;
  97402. /**
  97403. * @hidden
  97404. */
  97405. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97406. /**
  97407. * Sets the default candidate providers for the scene.
  97408. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97409. * and getCollidingSubMeshCandidates to their default function
  97410. */
  97411. setDefaultCandidateProviders(): void;
  97412. /**
  97413. * Gets the mesh that is currently under the pointer
  97414. */
  97415. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97416. /**
  97417. * Gets or sets the current on-screen X position of the pointer
  97418. */
  97419. pointerX: number;
  97420. /**
  97421. * Gets or sets the current on-screen Y position of the pointer
  97422. */
  97423. pointerY: number;
  97424. /**
  97425. * Gets the cached material (ie. the latest rendered one)
  97426. * @returns the cached material
  97427. */
  97428. getCachedMaterial(): Nullable<Material>;
  97429. /**
  97430. * Gets the cached effect (ie. the latest rendered one)
  97431. * @returns the cached effect
  97432. */
  97433. getCachedEffect(): Nullable<Effect>;
  97434. /**
  97435. * Gets the cached visibility state (ie. the latest rendered one)
  97436. * @returns the cached visibility state
  97437. */
  97438. getCachedVisibility(): Nullable<number>;
  97439. /**
  97440. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97441. * @param material defines the current material
  97442. * @param effect defines the current effect
  97443. * @param visibility defines the current visibility state
  97444. * @returns true if one parameter is not cached
  97445. */
  97446. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97447. /**
  97448. * Gets the engine associated with the scene
  97449. * @returns an Engine
  97450. */
  97451. getEngine(): Engine;
  97452. /**
  97453. * Gets the total number of vertices rendered per frame
  97454. * @returns the total number of vertices rendered per frame
  97455. */
  97456. getTotalVertices(): number;
  97457. /**
  97458. * Gets the performance counter for total vertices
  97459. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97460. */
  97461. readonly totalVerticesPerfCounter: PerfCounter;
  97462. /**
  97463. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97464. * @returns the total number of active indices rendered per frame
  97465. */
  97466. getActiveIndices(): number;
  97467. /**
  97468. * Gets the performance counter for active indices
  97469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97470. */
  97471. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97472. /**
  97473. * Gets the total number of active particles rendered per frame
  97474. * @returns the total number of active particles rendered per frame
  97475. */
  97476. getActiveParticles(): number;
  97477. /**
  97478. * Gets the performance counter for active particles
  97479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97480. */
  97481. readonly activeParticlesPerfCounter: PerfCounter;
  97482. /**
  97483. * Gets the total number of active bones rendered per frame
  97484. * @returns the total number of active bones rendered per frame
  97485. */
  97486. getActiveBones(): number;
  97487. /**
  97488. * Gets the performance counter for active bones
  97489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97490. */
  97491. readonly activeBonesPerfCounter: PerfCounter;
  97492. /**
  97493. * Gets the array of active meshes
  97494. * @returns an array of AbstractMesh
  97495. */
  97496. getActiveMeshes(): SmartArray<AbstractMesh>;
  97497. /**
  97498. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97499. * @returns a number
  97500. */
  97501. getAnimationRatio(): number;
  97502. /**
  97503. * Gets an unique Id for the current render phase
  97504. * @returns a number
  97505. */
  97506. getRenderId(): number;
  97507. /**
  97508. * Gets an unique Id for the current frame
  97509. * @returns a number
  97510. */
  97511. getFrameId(): number;
  97512. /** Call this function if you want to manually increment the render Id*/
  97513. incrementRenderId(): void;
  97514. private _createUbo;
  97515. /**
  97516. * Use this method to simulate a pointer move on a mesh
  97517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97520. * @returns the current scene
  97521. */
  97522. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97523. /**
  97524. * Use this method to simulate a pointer down on a mesh
  97525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97528. * @returns the current scene
  97529. */
  97530. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97531. /**
  97532. * Use this method to simulate a pointer up on a mesh
  97533. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97534. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97535. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97536. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97537. * @returns the current scene
  97538. */
  97539. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97540. /**
  97541. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97542. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97543. * @returns true if the pointer was captured
  97544. */
  97545. isPointerCaptured(pointerId?: number): boolean;
  97546. /**
  97547. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97548. * @param attachUp defines if you want to attach events to pointerup
  97549. * @param attachDown defines if you want to attach events to pointerdown
  97550. * @param attachMove defines if you want to attach events to pointermove
  97551. */
  97552. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97553. /** Detaches all event handlers*/
  97554. detachControl(): void;
  97555. /**
  97556. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97557. * Delay loaded resources are not taking in account
  97558. * @return true if all required resources are ready
  97559. */
  97560. isReady(): boolean;
  97561. /** Resets all cached information relative to material (including effect and visibility) */
  97562. resetCachedMaterial(): void;
  97563. /**
  97564. * Registers a function to be called before every frame render
  97565. * @param func defines the function to register
  97566. */
  97567. registerBeforeRender(func: () => void): void;
  97568. /**
  97569. * Unregisters a function called before every frame render
  97570. * @param func defines the function to unregister
  97571. */
  97572. unregisterBeforeRender(func: () => void): void;
  97573. /**
  97574. * Registers a function to be called after every frame render
  97575. * @param func defines the function to register
  97576. */
  97577. registerAfterRender(func: () => void): void;
  97578. /**
  97579. * Unregisters a function called after every frame render
  97580. * @param func defines the function to unregister
  97581. */
  97582. unregisterAfterRender(func: () => void): void;
  97583. private _executeOnceBeforeRender;
  97584. /**
  97585. * The provided function will run before render once and will be disposed afterwards.
  97586. * A timeout delay can be provided so that the function will be executed in N ms.
  97587. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97588. * @param func The function to be executed.
  97589. * @param timeout optional delay in ms
  97590. */
  97591. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97592. /** @hidden */
  97593. _addPendingData(data: any): void;
  97594. /** @hidden */
  97595. _removePendingData(data: any): void;
  97596. /**
  97597. * Returns the number of items waiting to be loaded
  97598. * @returns the number of items waiting to be loaded
  97599. */
  97600. getWaitingItemsCount(): number;
  97601. /**
  97602. * Returns a boolean indicating if the scene is still loading data
  97603. */
  97604. readonly isLoading: boolean;
  97605. /**
  97606. * Registers a function to be executed when the scene is ready
  97607. * @param {Function} func - the function to be executed
  97608. */
  97609. executeWhenReady(func: () => void): void;
  97610. /**
  97611. * Returns a promise that resolves when the scene is ready
  97612. * @returns A promise that resolves when the scene is ready
  97613. */
  97614. whenReadyAsync(): Promise<void>;
  97615. /** @hidden */
  97616. _checkIsReady(): void;
  97617. /**
  97618. * Gets all animatable attached to the scene
  97619. */
  97620. readonly animatables: Animatable[];
  97621. /**
  97622. * Resets the last animation time frame.
  97623. * Useful to override when animations start running when loading a scene for the first time.
  97624. */
  97625. resetLastAnimationTimeFrame(): void;
  97626. /**
  97627. * Gets the current view matrix
  97628. * @returns a Matrix
  97629. */
  97630. getViewMatrix(): Matrix;
  97631. /**
  97632. * Gets the current projection matrix
  97633. * @returns a Matrix
  97634. */
  97635. getProjectionMatrix(): Matrix;
  97636. /**
  97637. * Gets the current transform matrix
  97638. * @returns a Matrix made of View * Projection
  97639. */
  97640. getTransformMatrix(): Matrix;
  97641. /**
  97642. * Sets the current transform matrix
  97643. * @param viewL defines the View matrix to use
  97644. * @param projectionL defines the Projection matrix to use
  97645. * @param viewR defines the right View matrix to use (if provided)
  97646. * @param projectionR defines the right Projection matrix to use (if provided)
  97647. */
  97648. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97649. /**
  97650. * Gets the uniform buffer used to store scene data
  97651. * @returns a UniformBuffer
  97652. */
  97653. getSceneUniformBuffer(): UniformBuffer;
  97654. /**
  97655. * Gets an unique (relatively to the current scene) Id
  97656. * @returns an unique number for the scene
  97657. */
  97658. getUniqueId(): number;
  97659. /**
  97660. * Add a mesh to the list of scene's meshes
  97661. * @param newMesh defines the mesh to add
  97662. * @param recursive if all child meshes should also be added to the scene
  97663. */
  97664. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97665. /**
  97666. * Remove a mesh for the list of scene's meshes
  97667. * @param toRemove defines the mesh to remove
  97668. * @param recursive if all child meshes should also be removed from the scene
  97669. * @returns the index where the mesh was in the mesh list
  97670. */
  97671. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97672. /**
  97673. * Add a transform node to the list of scene's transform nodes
  97674. * @param newTransformNode defines the transform node to add
  97675. */
  97676. addTransformNode(newTransformNode: TransformNode): void;
  97677. /**
  97678. * Remove a transform node for the list of scene's transform nodes
  97679. * @param toRemove defines the transform node to remove
  97680. * @returns the index where the transform node was in the transform node list
  97681. */
  97682. removeTransformNode(toRemove: TransformNode): number;
  97683. /**
  97684. * Remove a skeleton for the list of scene's skeletons
  97685. * @param toRemove defines the skeleton to remove
  97686. * @returns the index where the skeleton was in the skeleton list
  97687. */
  97688. removeSkeleton(toRemove: Skeleton): number;
  97689. /**
  97690. * Remove a morph target for the list of scene's morph targets
  97691. * @param toRemove defines the morph target to remove
  97692. * @returns the index where the morph target was in the morph target list
  97693. */
  97694. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97695. /**
  97696. * Remove a light for the list of scene's lights
  97697. * @param toRemove defines the light to remove
  97698. * @returns the index where the light was in the light list
  97699. */
  97700. removeLight(toRemove: Light): number;
  97701. /**
  97702. * Remove a camera for the list of scene's cameras
  97703. * @param toRemove defines the camera to remove
  97704. * @returns the index where the camera was in the camera list
  97705. */
  97706. removeCamera(toRemove: Camera): number;
  97707. /**
  97708. * Remove a particle system for the list of scene's particle systems
  97709. * @param toRemove defines the particle system to remove
  97710. * @returns the index where the particle system was in the particle system list
  97711. */
  97712. removeParticleSystem(toRemove: IParticleSystem): number;
  97713. /**
  97714. * Remove a animation for the list of scene's animations
  97715. * @param toRemove defines the animation to remove
  97716. * @returns the index where the animation was in the animation list
  97717. */
  97718. removeAnimation(toRemove: Animation): number;
  97719. /**
  97720. * Will stop the animation of the given target
  97721. * @param target - the target
  97722. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97723. * @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)
  97724. */
  97725. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97726. /**
  97727. * Removes the given animation group from this scene.
  97728. * @param toRemove The animation group to remove
  97729. * @returns The index of the removed animation group
  97730. */
  97731. removeAnimationGroup(toRemove: AnimationGroup): number;
  97732. /**
  97733. * Removes the given multi-material from this scene.
  97734. * @param toRemove The multi-material to remove
  97735. * @returns The index of the removed multi-material
  97736. */
  97737. removeMultiMaterial(toRemove: MultiMaterial): number;
  97738. /**
  97739. * Removes the given material from this scene.
  97740. * @param toRemove The material to remove
  97741. * @returns The index of the removed material
  97742. */
  97743. removeMaterial(toRemove: Material): number;
  97744. /**
  97745. * Removes the given action manager from this scene.
  97746. * @param toRemove The action manager to remove
  97747. * @returns The index of the removed action manager
  97748. */
  97749. removeActionManager(toRemove: AbstractActionManager): number;
  97750. /**
  97751. * Removes the given texture from this scene.
  97752. * @param toRemove The texture to remove
  97753. * @returns The index of the removed texture
  97754. */
  97755. removeTexture(toRemove: BaseTexture): number;
  97756. /**
  97757. * Adds the given light to this scene
  97758. * @param newLight The light to add
  97759. */
  97760. addLight(newLight: Light): void;
  97761. /**
  97762. * Sorts the list list based on light priorities
  97763. */
  97764. sortLightsByPriority(): void;
  97765. /**
  97766. * Adds the given camera to this scene
  97767. * @param newCamera The camera to add
  97768. */
  97769. addCamera(newCamera: Camera): void;
  97770. /**
  97771. * Adds the given skeleton to this scene
  97772. * @param newSkeleton The skeleton to add
  97773. */
  97774. addSkeleton(newSkeleton: Skeleton): void;
  97775. /**
  97776. * Adds the given particle system to this scene
  97777. * @param newParticleSystem The particle system to add
  97778. */
  97779. addParticleSystem(newParticleSystem: IParticleSystem): void;
  97780. /**
  97781. * Adds the given animation to this scene
  97782. * @param newAnimation The animation to add
  97783. */
  97784. addAnimation(newAnimation: Animation): void;
  97785. /**
  97786. * Adds the given animation group to this scene.
  97787. * @param newAnimationGroup The animation group to add
  97788. */
  97789. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  97790. /**
  97791. * Adds the given multi-material to this scene
  97792. * @param newMultiMaterial The multi-material to add
  97793. */
  97794. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  97795. /**
  97796. * Adds the given material to this scene
  97797. * @param newMaterial The material to add
  97798. */
  97799. addMaterial(newMaterial: Material): void;
  97800. /**
  97801. * Adds the given morph target to this scene
  97802. * @param newMorphTargetManager The morph target to add
  97803. */
  97804. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  97805. /**
  97806. * Adds the given geometry to this scene
  97807. * @param newGeometry The geometry to add
  97808. */
  97809. addGeometry(newGeometry: Geometry): void;
  97810. /**
  97811. * Adds the given action manager to this scene
  97812. * @param newActionManager The action manager to add
  97813. */
  97814. addActionManager(newActionManager: AbstractActionManager): void;
  97815. /**
  97816. * Adds the given texture to this scene.
  97817. * @param newTexture The texture to add
  97818. */
  97819. addTexture(newTexture: BaseTexture): void;
  97820. /**
  97821. * Switch active camera
  97822. * @param newCamera defines the new active camera
  97823. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  97824. */
  97825. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  97826. /**
  97827. * sets the active camera of the scene using its ID
  97828. * @param id defines the camera's ID
  97829. * @return the new active camera or null if none found.
  97830. */
  97831. setActiveCameraByID(id: string): Nullable<Camera>;
  97832. /**
  97833. * sets the active camera of the scene using its name
  97834. * @param name defines the camera's name
  97835. * @returns the new active camera or null if none found.
  97836. */
  97837. setActiveCameraByName(name: string): Nullable<Camera>;
  97838. /**
  97839. * get an animation group using its name
  97840. * @param name defines the material's name
  97841. * @return the animation group or null if none found.
  97842. */
  97843. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  97844. /**
  97845. * Get a material using its unique id
  97846. * @param uniqueId defines the material's unique id
  97847. * @return the material or null if none found.
  97848. */
  97849. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  97850. /**
  97851. * get a material using its id
  97852. * @param id defines the material's ID
  97853. * @return the material or null if none found.
  97854. */
  97855. getMaterialByID(id: string): Nullable<Material>;
  97856. /**
  97857. * Gets a the last added material using a given id
  97858. * @param id defines the material's ID
  97859. * @return the last material with the given id or null if none found.
  97860. */
  97861. getLastMaterialByID(id: string): Nullable<Material>;
  97862. /**
  97863. * Gets a material using its name
  97864. * @param name defines the material's name
  97865. * @return the material or null if none found.
  97866. */
  97867. getMaterialByName(name: string): Nullable<Material>;
  97868. /**
  97869. * Get a texture using its unique id
  97870. * @param uniqueId defines the texture's unique id
  97871. * @return the texture or null if none found.
  97872. */
  97873. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  97874. /**
  97875. * Gets a camera using its id
  97876. * @param id defines the id to look for
  97877. * @returns the camera or null if not found
  97878. */
  97879. getCameraByID(id: string): Nullable<Camera>;
  97880. /**
  97881. * Gets a camera using its unique id
  97882. * @param uniqueId defines the unique id to look for
  97883. * @returns the camera or null if not found
  97884. */
  97885. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  97886. /**
  97887. * Gets a camera using its name
  97888. * @param name defines the camera's name
  97889. * @return the camera or null if none found.
  97890. */
  97891. getCameraByName(name: string): Nullable<Camera>;
  97892. /**
  97893. * Gets a bone using its id
  97894. * @param id defines the bone's id
  97895. * @return the bone or null if not found
  97896. */
  97897. getBoneByID(id: string): Nullable<Bone>;
  97898. /**
  97899. * Gets a bone using its id
  97900. * @param name defines the bone's name
  97901. * @return the bone or null if not found
  97902. */
  97903. getBoneByName(name: string): Nullable<Bone>;
  97904. /**
  97905. * Gets a light node using its name
  97906. * @param name defines the the light's name
  97907. * @return the light or null if none found.
  97908. */
  97909. getLightByName(name: string): Nullable<Light>;
  97910. /**
  97911. * Gets a light node using its id
  97912. * @param id defines the light's id
  97913. * @return the light or null if none found.
  97914. */
  97915. getLightByID(id: string): Nullable<Light>;
  97916. /**
  97917. * Gets a light node using its scene-generated unique ID
  97918. * @param uniqueId defines the light's unique id
  97919. * @return the light or null if none found.
  97920. */
  97921. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97922. /**
  97923. * Gets a particle system by id
  97924. * @param id defines the particle system id
  97925. * @return the corresponding system or null if none found
  97926. */
  97927. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97928. /**
  97929. * Gets a geometry using its ID
  97930. * @param id defines the geometry's id
  97931. * @return the geometry or null if none found.
  97932. */
  97933. getGeometryByID(id: string): Nullable<Geometry>;
  97934. private _getGeometryByUniqueID;
  97935. /**
  97936. * Add a new geometry to this scene
  97937. * @param geometry defines the geometry to be added to the scene.
  97938. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97939. * @return a boolean defining if the geometry was added or not
  97940. */
  97941. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97942. /**
  97943. * Removes an existing geometry
  97944. * @param geometry defines the geometry to be removed from the scene
  97945. * @return a boolean defining if the geometry was removed or not
  97946. */
  97947. removeGeometry(geometry: Geometry): boolean;
  97948. /**
  97949. * Gets the list of geometries attached to the scene
  97950. * @returns an array of Geometry
  97951. */
  97952. getGeometries(): Geometry[];
  97953. /**
  97954. * Gets the first added mesh found of a given ID
  97955. * @param id defines the id to search for
  97956. * @return the mesh found or null if not found at all
  97957. */
  97958. getMeshByID(id: string): Nullable<AbstractMesh>;
  97959. /**
  97960. * Gets a list of meshes using their id
  97961. * @param id defines the id to search for
  97962. * @returns a list of meshes
  97963. */
  97964. getMeshesByID(id: string): Array<AbstractMesh>;
  97965. /**
  97966. * Gets the first added transform node found of a given ID
  97967. * @param id defines the id to search for
  97968. * @return the found transform node or null if not found at all.
  97969. */
  97970. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97971. /**
  97972. * Gets a transform node with its auto-generated unique id
  97973. * @param uniqueId efines the unique id to search for
  97974. * @return the found transform node or null if not found at all.
  97975. */
  97976. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97977. /**
  97978. * Gets a list of transform nodes using their id
  97979. * @param id defines the id to search for
  97980. * @returns a list of transform nodes
  97981. */
  97982. getTransformNodesByID(id: string): Array<TransformNode>;
  97983. /**
  97984. * Gets a mesh with its auto-generated unique id
  97985. * @param uniqueId defines the unique id to search for
  97986. * @return the found mesh or null if not found at all.
  97987. */
  97988. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97989. /**
  97990. * Gets a the last added mesh using a given id
  97991. * @param id defines the id to search for
  97992. * @return the found mesh or null if not found at all.
  97993. */
  97994. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97995. /**
  97996. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97997. * @param id defines the id to search for
  97998. * @return the found node or null if not found at all
  97999. */
  98000. getLastEntryByID(id: string): Nullable<Node>;
  98001. /**
  98002. * Gets a node (Mesh, Camera, Light) using a given id
  98003. * @param id defines the id to search for
  98004. * @return the found node or null if not found at all
  98005. */
  98006. getNodeByID(id: string): Nullable<Node>;
  98007. /**
  98008. * Gets a node (Mesh, Camera, Light) using a given name
  98009. * @param name defines the name to search for
  98010. * @return the found node or null if not found at all.
  98011. */
  98012. getNodeByName(name: string): Nullable<Node>;
  98013. /**
  98014. * Gets a mesh using a given name
  98015. * @param name defines the name to search for
  98016. * @return the found mesh or null if not found at all.
  98017. */
  98018. getMeshByName(name: string): Nullable<AbstractMesh>;
  98019. /**
  98020. * Gets a transform node using a given name
  98021. * @param name defines the name to search for
  98022. * @return the found transform node or null if not found at all.
  98023. */
  98024. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98025. /**
  98026. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98027. * @param id defines the id to search for
  98028. * @return the found skeleton or null if not found at all.
  98029. */
  98030. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98031. /**
  98032. * Gets a skeleton using a given auto generated unique id
  98033. * @param uniqueId defines the unique id to search for
  98034. * @return the found skeleton or null if not found at all.
  98035. */
  98036. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98037. /**
  98038. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98039. * @param id defines the id to search for
  98040. * @return the found skeleton or null if not found at all.
  98041. */
  98042. getSkeletonById(id: string): Nullable<Skeleton>;
  98043. /**
  98044. * Gets a skeleton using a given name
  98045. * @param name defines the name to search for
  98046. * @return the found skeleton or null if not found at all.
  98047. */
  98048. getSkeletonByName(name: string): Nullable<Skeleton>;
  98049. /**
  98050. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98051. * @param id defines the id to search for
  98052. * @return the found morph target manager or null if not found at all.
  98053. */
  98054. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98055. /**
  98056. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98057. * @param id defines the id to search for
  98058. * @return the found morph target or null if not found at all.
  98059. */
  98060. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98061. /**
  98062. * Gets a boolean indicating if the given mesh is active
  98063. * @param mesh defines the mesh to look for
  98064. * @returns true if the mesh is in the active list
  98065. */
  98066. isActiveMesh(mesh: AbstractMesh): boolean;
  98067. /**
  98068. * Return a unique id as a string which can serve as an identifier for the scene
  98069. */
  98070. readonly uid: string;
  98071. /**
  98072. * Add an externaly attached data from its key.
  98073. * This method call will fail and return false, if such key already exists.
  98074. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98075. * @param key the unique key that identifies the data
  98076. * @param data the data object to associate to the key for this Engine instance
  98077. * @return true if no such key were already present and the data was added successfully, false otherwise
  98078. */
  98079. addExternalData<T>(key: string, data: T): boolean;
  98080. /**
  98081. * Get an externaly attached data from its key
  98082. * @param key the unique key that identifies the data
  98083. * @return the associated data, if present (can be null), or undefined if not present
  98084. */
  98085. getExternalData<T>(key: string): Nullable<T>;
  98086. /**
  98087. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98088. * @param key the unique key that identifies the data
  98089. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98090. * @return the associated data, can be null if the factory returned null.
  98091. */
  98092. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98093. /**
  98094. * Remove an externaly attached data from the Engine instance
  98095. * @param key the unique key that identifies the data
  98096. * @return true if the data was successfully removed, false if it doesn't exist
  98097. */
  98098. removeExternalData(key: string): boolean;
  98099. private _evaluateSubMesh;
  98100. /**
  98101. * Clear the processed materials smart array preventing retention point in material dispose.
  98102. */
  98103. freeProcessedMaterials(): void;
  98104. private _preventFreeActiveMeshesAndRenderingGroups;
  98105. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98106. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98107. * when disposing several meshes in a row or a hierarchy of meshes.
  98108. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98109. */
  98110. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98111. /**
  98112. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98113. */
  98114. freeActiveMeshes(): void;
  98115. /**
  98116. * Clear the info related to rendering groups preventing retention points during dispose.
  98117. */
  98118. freeRenderingGroups(): void;
  98119. /** @hidden */
  98120. _isInIntermediateRendering(): boolean;
  98121. /**
  98122. * Lambda returning the list of potentially active meshes.
  98123. */
  98124. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98125. /**
  98126. * Lambda returning the list of potentially active sub meshes.
  98127. */
  98128. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98129. /**
  98130. * Lambda returning the list of potentially intersecting sub meshes.
  98131. */
  98132. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98133. /**
  98134. * Lambda returning the list of potentially colliding sub meshes.
  98135. */
  98136. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98137. private _activeMeshesFrozen;
  98138. /**
  98139. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98140. * @returns the current scene
  98141. */
  98142. freezeActiveMeshes(): Scene;
  98143. /**
  98144. * Use this function to restart evaluating active meshes on every frame
  98145. * @returns the current scene
  98146. */
  98147. unfreezeActiveMeshes(): Scene;
  98148. private _evaluateActiveMeshes;
  98149. private _activeMesh;
  98150. /**
  98151. * Update the transform matrix to update from the current active camera
  98152. * @param force defines a boolean used to force the update even if cache is up to date
  98153. */
  98154. updateTransformMatrix(force?: boolean): void;
  98155. private _bindFrameBuffer;
  98156. /** @hidden */
  98157. _allowPostProcessClearColor: boolean;
  98158. /** @hidden */
  98159. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98160. private _processSubCameras;
  98161. private _checkIntersections;
  98162. /** @hidden */
  98163. _advancePhysicsEngineStep(step: number): void;
  98164. /**
  98165. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98166. */
  98167. getDeterministicFrameTime: () => number;
  98168. /** @hidden */
  98169. _animate(): void;
  98170. /** Execute all animations (for a frame) */
  98171. animate(): void;
  98172. /**
  98173. * Render the scene
  98174. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98175. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98176. */
  98177. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98178. /**
  98179. * Freeze all materials
  98180. * A frozen material will not be updatable but should be faster to render
  98181. */
  98182. freezeMaterials(): void;
  98183. /**
  98184. * Unfreeze all materials
  98185. * A frozen material will not be updatable but should be faster to render
  98186. */
  98187. unfreezeMaterials(): void;
  98188. /**
  98189. * Releases all held ressources
  98190. */
  98191. dispose(): void;
  98192. /**
  98193. * Gets if the scene is already disposed
  98194. */
  98195. readonly isDisposed: boolean;
  98196. /**
  98197. * Call this function to reduce memory footprint of the scene.
  98198. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98199. */
  98200. clearCachedVertexData(): void;
  98201. /**
  98202. * This function will remove the local cached buffer data from texture.
  98203. * It will save memory but will prevent the texture from being rebuilt
  98204. */
  98205. cleanCachedTextureBuffer(): void;
  98206. /**
  98207. * Get the world extend vectors with an optional filter
  98208. *
  98209. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98210. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98211. */
  98212. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98213. min: Vector3;
  98214. max: Vector3;
  98215. };
  98216. /**
  98217. * Creates a ray that can be used to pick in the scene
  98218. * @param x defines the x coordinate of the origin (on-screen)
  98219. * @param y defines the y coordinate of the origin (on-screen)
  98220. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98221. * @param camera defines the camera to use for the picking
  98222. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98223. * @returns a Ray
  98224. */
  98225. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98226. /**
  98227. * Creates a ray that can be used to pick in the scene
  98228. * @param x defines the x coordinate of the origin (on-screen)
  98229. * @param y defines the y coordinate of the origin (on-screen)
  98230. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98231. * @param result defines the ray where to store the picking ray
  98232. * @param camera defines the camera to use for the picking
  98233. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98234. * @returns the current scene
  98235. */
  98236. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98237. /**
  98238. * Creates a ray that can be used to pick in the scene
  98239. * @param x defines the x coordinate of the origin (on-screen)
  98240. * @param y defines the y coordinate of the origin (on-screen)
  98241. * @param camera defines the camera to use for the picking
  98242. * @returns a Ray
  98243. */
  98244. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98245. /**
  98246. * Creates a ray that can be used to pick in the scene
  98247. * @param x defines the x coordinate of the origin (on-screen)
  98248. * @param y defines the y coordinate of the origin (on-screen)
  98249. * @param result defines the ray where to store the picking ray
  98250. * @param camera defines the camera to use for the picking
  98251. * @returns the current scene
  98252. */
  98253. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98254. /** Launch a ray to try to pick a mesh in the scene
  98255. * @param x position on screen
  98256. * @param y position on screen
  98257. * @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
  98258. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98259. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98260. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98261. * @returns a PickingInfo
  98262. */
  98263. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98264. /** Use the given ray to pick a mesh in the scene
  98265. * @param ray The ray to use to pick meshes
  98266. * @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
  98267. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98268. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98269. * @returns a PickingInfo
  98270. */
  98271. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98272. /**
  98273. * Launch a ray to try to pick a mesh in the scene
  98274. * @param x X position on screen
  98275. * @param y Y position on screen
  98276. * @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
  98277. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98279. * @returns an array of PickingInfo
  98280. */
  98281. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98282. /**
  98283. * Launch a ray to try to pick a mesh in the scene
  98284. * @param ray Ray to use
  98285. * @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
  98286. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98287. * @returns an array of PickingInfo
  98288. */
  98289. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98290. /**
  98291. * Force the value of meshUnderPointer
  98292. * @param mesh defines the mesh to use
  98293. */
  98294. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98295. /**
  98296. * Gets the mesh under the pointer
  98297. * @returns a Mesh or null if no mesh is under the pointer
  98298. */
  98299. getPointerOverMesh(): Nullable<AbstractMesh>;
  98300. /** @hidden */
  98301. _rebuildGeometries(): void;
  98302. /** @hidden */
  98303. _rebuildTextures(): void;
  98304. private _getByTags;
  98305. /**
  98306. * Get a list of meshes by tags
  98307. * @param tagsQuery defines the tags query to use
  98308. * @param forEach defines a predicate used to filter results
  98309. * @returns an array of Mesh
  98310. */
  98311. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98312. /**
  98313. * Get a list of cameras by tags
  98314. * @param tagsQuery defines the tags query to use
  98315. * @param forEach defines a predicate used to filter results
  98316. * @returns an array of Camera
  98317. */
  98318. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98319. /**
  98320. * Get a list of lights by tags
  98321. * @param tagsQuery defines the tags query to use
  98322. * @param forEach defines a predicate used to filter results
  98323. * @returns an array of Light
  98324. */
  98325. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98326. /**
  98327. * Get a list of materials by tags
  98328. * @param tagsQuery defines the tags query to use
  98329. * @param forEach defines a predicate used to filter results
  98330. * @returns an array of Material
  98331. */
  98332. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98333. /**
  98334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98335. * This allowed control for front to back rendering or reversly depending of the special needs.
  98336. *
  98337. * @param renderingGroupId The rendering group id corresponding to its index
  98338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98341. */
  98342. 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;
  98343. /**
  98344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98345. *
  98346. * @param renderingGroupId The rendering group id corresponding to its index
  98347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98348. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98349. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98350. */
  98351. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98352. /**
  98353. * Gets the current auto clear configuration for one rendering group of the rendering
  98354. * manager.
  98355. * @param index the rendering group index to get the information for
  98356. * @returns The auto clear setup for the requested rendering group
  98357. */
  98358. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98359. private _blockMaterialDirtyMechanism;
  98360. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98361. blockMaterialDirtyMechanism: boolean;
  98362. /**
  98363. * Will flag all materials as dirty to trigger new shader compilation
  98364. * @param flag defines the flag used to specify which material part must be marked as dirty
  98365. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98366. */
  98367. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98368. /** @hidden */
  98369. _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;
  98370. /** @hidden */
  98371. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98372. }
  98373. }
  98374. declare module BABYLON {
  98375. /**
  98376. * Set of assets to keep when moving a scene into an asset container.
  98377. */
  98378. export class KeepAssets extends AbstractScene {
  98379. }
  98380. /**
  98381. * Container with a set of assets that can be added or removed from a scene.
  98382. */
  98383. export class AssetContainer extends AbstractScene {
  98384. /**
  98385. * The scene the AssetContainer belongs to.
  98386. */
  98387. scene: Scene;
  98388. /**
  98389. * Instantiates an AssetContainer.
  98390. * @param scene The scene the AssetContainer belongs to.
  98391. */
  98392. constructor(scene: Scene);
  98393. /**
  98394. * Adds all the assets from the container to the scene.
  98395. */
  98396. addAllToScene(): void;
  98397. /**
  98398. * Removes all the assets in the container from the scene
  98399. */
  98400. removeAllFromScene(): void;
  98401. /**
  98402. * Disposes all the assets in the container
  98403. */
  98404. dispose(): void;
  98405. private _moveAssets;
  98406. /**
  98407. * Removes all the assets contained in the scene and adds them to the container.
  98408. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98409. */
  98410. moveAllFromScene(keepAssets?: KeepAssets): void;
  98411. /**
  98412. * 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.
  98413. * @returns the root mesh
  98414. */
  98415. createRootMesh(): Mesh;
  98416. }
  98417. }
  98418. declare module BABYLON {
  98419. /**
  98420. * Defines how the parser contract is defined.
  98421. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98422. */
  98423. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98424. /**
  98425. * Defines how the individual parser contract is defined.
  98426. * These parser can parse an individual asset
  98427. */
  98428. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98429. /**
  98430. * Base class of the scene acting as a container for the different elements composing a scene.
  98431. * This class is dynamically extended by the different components of the scene increasing
  98432. * flexibility and reducing coupling
  98433. */
  98434. export abstract class AbstractScene {
  98435. /**
  98436. * Stores the list of available parsers in the application.
  98437. */
  98438. private static _BabylonFileParsers;
  98439. /**
  98440. * Stores the list of available individual parsers in the application.
  98441. */
  98442. private static _IndividualBabylonFileParsers;
  98443. /**
  98444. * Adds a parser in the list of available ones
  98445. * @param name Defines the name of the parser
  98446. * @param parser Defines the parser to add
  98447. */
  98448. static AddParser(name: string, parser: BabylonFileParser): void;
  98449. /**
  98450. * Gets a general parser from the list of avaialble ones
  98451. * @param name Defines the name of the parser
  98452. * @returns the requested parser or null
  98453. */
  98454. static GetParser(name: string): Nullable<BabylonFileParser>;
  98455. /**
  98456. * Adds n individual parser in the list of available ones
  98457. * @param name Defines the name of the parser
  98458. * @param parser Defines the parser to add
  98459. */
  98460. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98461. /**
  98462. * Gets an individual parser from the list of avaialble ones
  98463. * @param name Defines the name of the parser
  98464. * @returns the requested parser or null
  98465. */
  98466. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98467. /**
  98468. * Parser json data and populate both a scene and its associated container object
  98469. * @param jsonData Defines the data to parse
  98470. * @param scene Defines the scene to parse the data for
  98471. * @param container Defines the container attached to the parsing sequence
  98472. * @param rootUrl Defines the root url of the data
  98473. */
  98474. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98475. /**
  98476. * Gets the list of root nodes (ie. nodes with no parent)
  98477. */
  98478. rootNodes: Node[];
  98479. /** All of the cameras added to this scene
  98480. * @see http://doc.babylonjs.com/babylon101/cameras
  98481. */
  98482. cameras: Camera[];
  98483. /**
  98484. * All of the lights added to this scene
  98485. * @see http://doc.babylonjs.com/babylon101/lights
  98486. */
  98487. lights: Light[];
  98488. /**
  98489. * All of the (abstract) meshes added to this scene
  98490. */
  98491. meshes: AbstractMesh[];
  98492. /**
  98493. * The list of skeletons added to the scene
  98494. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98495. */
  98496. skeletons: Skeleton[];
  98497. /**
  98498. * All of the particle systems added to this scene
  98499. * @see http://doc.babylonjs.com/babylon101/particles
  98500. */
  98501. particleSystems: IParticleSystem[];
  98502. /**
  98503. * Gets a list of Animations associated with the scene
  98504. */
  98505. animations: Animation[];
  98506. /**
  98507. * All of the animation groups added to this scene
  98508. * @see http://doc.babylonjs.com/how_to/group
  98509. */
  98510. animationGroups: AnimationGroup[];
  98511. /**
  98512. * All of the multi-materials added to this scene
  98513. * @see http://doc.babylonjs.com/how_to/multi_materials
  98514. */
  98515. multiMaterials: MultiMaterial[];
  98516. /**
  98517. * All of the materials added to this scene
  98518. * In the context of a Scene, it is not supposed to be modified manually.
  98519. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98520. * Note also that the order of the Material wihin the array is not significant and might change.
  98521. * @see http://doc.babylonjs.com/babylon101/materials
  98522. */
  98523. materials: Material[];
  98524. /**
  98525. * The list of morph target managers added to the scene
  98526. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98527. */
  98528. morphTargetManagers: MorphTargetManager[];
  98529. /**
  98530. * The list of geometries used in the scene.
  98531. */
  98532. geometries: Geometry[];
  98533. /**
  98534. * All of the tranform nodes added to this scene
  98535. * In the context of a Scene, it is not supposed to be modified manually.
  98536. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98537. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98538. * @see http://doc.babylonjs.com/how_to/transformnode
  98539. */
  98540. transformNodes: TransformNode[];
  98541. /**
  98542. * ActionManagers available on the scene.
  98543. */
  98544. actionManagers: AbstractActionManager[];
  98545. /**
  98546. * Textures to keep.
  98547. */
  98548. textures: BaseTexture[];
  98549. /**
  98550. * Environment texture for the scene
  98551. */
  98552. environmentTexture: Nullable<BaseTexture>;
  98553. }
  98554. }
  98555. declare module BABYLON {
  98556. /**
  98557. * Interface used to define options for Sound class
  98558. */
  98559. export interface ISoundOptions {
  98560. /**
  98561. * Does the sound autoplay once loaded.
  98562. */
  98563. autoplay?: boolean;
  98564. /**
  98565. * Does the sound loop after it finishes playing once.
  98566. */
  98567. loop?: boolean;
  98568. /**
  98569. * Sound's volume
  98570. */
  98571. volume?: number;
  98572. /**
  98573. * Is it a spatial sound?
  98574. */
  98575. spatialSound?: boolean;
  98576. /**
  98577. * Maximum distance to hear that sound
  98578. */
  98579. maxDistance?: number;
  98580. /**
  98581. * Uses user defined attenuation function
  98582. */
  98583. useCustomAttenuation?: boolean;
  98584. /**
  98585. * Define the roll off factor of spatial sounds.
  98586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98587. */
  98588. rolloffFactor?: number;
  98589. /**
  98590. * Define the reference distance the sound should be heard perfectly.
  98591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98592. */
  98593. refDistance?: number;
  98594. /**
  98595. * Define the distance attenuation model the sound will follow.
  98596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98597. */
  98598. distanceModel?: string;
  98599. /**
  98600. * Defines the playback speed (1 by default)
  98601. */
  98602. playbackRate?: number;
  98603. /**
  98604. * Defines if the sound is from a streaming source
  98605. */
  98606. streaming?: boolean;
  98607. /**
  98608. * Defines an optional length (in seconds) inside the sound file
  98609. */
  98610. length?: number;
  98611. /**
  98612. * Defines an optional offset (in seconds) inside the sound file
  98613. */
  98614. offset?: number;
  98615. /**
  98616. * If true, URLs will not be required to state the audio file codec to use.
  98617. */
  98618. skipCodecCheck?: boolean;
  98619. }
  98620. /**
  98621. * Defines a sound that can be played in the application.
  98622. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98624. */
  98625. export class Sound {
  98626. /**
  98627. * The name of the sound in the scene.
  98628. */
  98629. name: string;
  98630. /**
  98631. * Does the sound autoplay once loaded.
  98632. */
  98633. autoplay: boolean;
  98634. /**
  98635. * Does the sound loop after it finishes playing once.
  98636. */
  98637. loop: boolean;
  98638. /**
  98639. * Does the sound use a custom attenuation curve to simulate the falloff
  98640. * happening when the source gets further away from the camera.
  98641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98642. */
  98643. useCustomAttenuation: boolean;
  98644. /**
  98645. * The sound track id this sound belongs to.
  98646. */
  98647. soundTrackId: number;
  98648. /**
  98649. * Is this sound currently played.
  98650. */
  98651. isPlaying: boolean;
  98652. /**
  98653. * Is this sound currently paused.
  98654. */
  98655. isPaused: boolean;
  98656. /**
  98657. * Does this sound enables spatial sound.
  98658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98659. */
  98660. spatialSound: boolean;
  98661. /**
  98662. * Define the reference distance the sound should be heard perfectly.
  98663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98664. */
  98665. refDistance: number;
  98666. /**
  98667. * Define the roll off factor of spatial sounds.
  98668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98669. */
  98670. rolloffFactor: number;
  98671. /**
  98672. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98674. */
  98675. maxDistance: number;
  98676. /**
  98677. * Define the distance attenuation model the sound will follow.
  98678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98679. */
  98680. distanceModel: string;
  98681. /**
  98682. * @hidden
  98683. * Back Compat
  98684. **/
  98685. onended: () => any;
  98686. /**
  98687. * Observable event when the current playing sound finishes.
  98688. */
  98689. onEndedObservable: Observable<Sound>;
  98690. private _panningModel;
  98691. private _playbackRate;
  98692. private _streaming;
  98693. private _startTime;
  98694. private _startOffset;
  98695. private _position;
  98696. /** @hidden */
  98697. _positionInEmitterSpace: boolean;
  98698. private _localDirection;
  98699. private _volume;
  98700. private _isReadyToPlay;
  98701. private _isDirectional;
  98702. private _readyToPlayCallback;
  98703. private _audioBuffer;
  98704. private _soundSource;
  98705. private _streamingSource;
  98706. private _soundPanner;
  98707. private _soundGain;
  98708. private _inputAudioNode;
  98709. private _outputAudioNode;
  98710. private _coneInnerAngle;
  98711. private _coneOuterAngle;
  98712. private _coneOuterGain;
  98713. private _scene;
  98714. private _connectedTransformNode;
  98715. private _customAttenuationFunction;
  98716. private _registerFunc;
  98717. private _isOutputConnected;
  98718. private _htmlAudioElement;
  98719. private _urlType;
  98720. private _length?;
  98721. private _offset?;
  98722. /** @hidden */
  98723. static _SceneComponentInitialization: (scene: Scene) => void;
  98724. /**
  98725. * Create a sound and attach it to a scene
  98726. * @param name Name of your sound
  98727. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98728. * @param scene defines the scene the sound belongs to
  98729. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98730. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98731. */
  98732. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98733. /**
  98734. * Release the sound and its associated resources
  98735. */
  98736. dispose(): void;
  98737. /**
  98738. * Gets if the sounds is ready to be played or not.
  98739. * @returns true if ready, otherwise false
  98740. */
  98741. isReady(): boolean;
  98742. private _soundLoaded;
  98743. /**
  98744. * Sets the data of the sound from an audiobuffer
  98745. * @param audioBuffer The audioBuffer containing the data
  98746. */
  98747. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98748. /**
  98749. * Updates the current sounds options such as maxdistance, loop...
  98750. * @param options A JSON object containing values named as the object properties
  98751. */
  98752. updateOptions(options: ISoundOptions): void;
  98753. private _createSpatialParameters;
  98754. private _updateSpatialParameters;
  98755. /**
  98756. * Switch the panning model to HRTF:
  98757. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98759. */
  98760. switchPanningModelToHRTF(): void;
  98761. /**
  98762. * Switch the panning model to Equal Power:
  98763. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98765. */
  98766. switchPanningModelToEqualPower(): void;
  98767. private _switchPanningModel;
  98768. /**
  98769. * Connect this sound to a sound track audio node like gain...
  98770. * @param soundTrackAudioNode the sound track audio node to connect to
  98771. */
  98772. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  98773. /**
  98774. * Transform this sound into a directional source
  98775. * @param coneInnerAngle Size of the inner cone in degree
  98776. * @param coneOuterAngle Size of the outer cone in degree
  98777. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  98778. */
  98779. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  98780. /**
  98781. * Gets or sets the inner angle for the directional cone.
  98782. */
  98783. /**
  98784. * Gets or sets the inner angle for the directional cone.
  98785. */
  98786. directionalConeInnerAngle: number;
  98787. /**
  98788. * Gets or sets the outer angle for the directional cone.
  98789. */
  98790. /**
  98791. * Gets or sets the outer angle for the directional cone.
  98792. */
  98793. directionalConeOuterAngle: number;
  98794. /**
  98795. * Sets the position of the emitter if spatial sound is enabled
  98796. * @param newPosition Defines the new posisiton
  98797. */
  98798. setPosition(newPosition: Vector3): void;
  98799. /**
  98800. * Sets the local direction of the emitter if spatial sound is enabled
  98801. * @param newLocalDirection Defines the new local direction
  98802. */
  98803. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  98804. private _updateDirection;
  98805. /** @hidden */
  98806. updateDistanceFromListener(): void;
  98807. /**
  98808. * Sets a new custom attenuation function for the sound.
  98809. * @param callback Defines the function used for the attenuation
  98810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98811. */
  98812. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  98813. /**
  98814. * Play the sound
  98815. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  98816. * @param offset (optional) Start the sound at a specific time in seconds
  98817. * @param length (optional) Sound duration (in seconds)
  98818. */
  98819. play(time?: number, offset?: number, length?: number): void;
  98820. private _onended;
  98821. /**
  98822. * Stop the sound
  98823. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  98824. */
  98825. stop(time?: number): void;
  98826. /**
  98827. * Put the sound in pause
  98828. */
  98829. pause(): void;
  98830. /**
  98831. * Sets a dedicated volume for this sounds
  98832. * @param newVolume Define the new volume of the sound
  98833. * @param time Define time for gradual change to new volume
  98834. */
  98835. setVolume(newVolume: number, time?: number): void;
  98836. /**
  98837. * Set the sound play back rate
  98838. * @param newPlaybackRate Define the playback rate the sound should be played at
  98839. */
  98840. setPlaybackRate(newPlaybackRate: number): void;
  98841. /**
  98842. * Gets the volume of the sound.
  98843. * @returns the volume of the sound
  98844. */
  98845. getVolume(): number;
  98846. /**
  98847. * Attach the sound to a dedicated mesh
  98848. * @param transformNode The transform node to connect the sound with
  98849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98850. */
  98851. attachToMesh(transformNode: TransformNode): void;
  98852. /**
  98853. * Detach the sound from the previously attached mesh
  98854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98855. */
  98856. detachFromMesh(): void;
  98857. private _onRegisterAfterWorldMatrixUpdate;
  98858. /**
  98859. * Clone the current sound in the scene.
  98860. * @returns the new sound clone
  98861. */
  98862. clone(): Nullable<Sound>;
  98863. /**
  98864. * Gets the current underlying audio buffer containing the data
  98865. * @returns the audio buffer
  98866. */
  98867. getAudioBuffer(): Nullable<AudioBuffer>;
  98868. /**
  98869. * Serializes the Sound in a JSON representation
  98870. * @returns the JSON representation of the sound
  98871. */
  98872. serialize(): any;
  98873. /**
  98874. * Parse a JSON representation of a sound to innstantiate in a given scene
  98875. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  98876. * @param scene Define the scene the new parsed sound should be created in
  98877. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  98878. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  98879. * @returns the newly parsed sound
  98880. */
  98881. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  98882. }
  98883. }
  98884. declare module BABYLON {
  98885. /**
  98886. * This defines an action helpful to play a defined sound on a triggered action.
  98887. */
  98888. export class PlaySoundAction extends Action {
  98889. private _sound;
  98890. /**
  98891. * Instantiate the action
  98892. * @param triggerOptions defines the trigger options
  98893. * @param sound defines the sound to play
  98894. * @param condition defines the trigger related conditions
  98895. */
  98896. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98897. /** @hidden */
  98898. _prepare(): void;
  98899. /**
  98900. * Execute the action and play the sound.
  98901. */
  98902. execute(): void;
  98903. /**
  98904. * Serializes the actions and its related information.
  98905. * @param parent defines the object to serialize in
  98906. * @returns the serialized object
  98907. */
  98908. serialize(parent: any): any;
  98909. }
  98910. /**
  98911. * This defines an action helpful to stop a defined sound on a triggered action.
  98912. */
  98913. export class StopSoundAction extends Action {
  98914. private _sound;
  98915. /**
  98916. * Instantiate the action
  98917. * @param triggerOptions defines the trigger options
  98918. * @param sound defines the sound to stop
  98919. * @param condition defines the trigger related conditions
  98920. */
  98921. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98922. /** @hidden */
  98923. _prepare(): void;
  98924. /**
  98925. * Execute the action and stop the sound.
  98926. */
  98927. execute(): void;
  98928. /**
  98929. * Serializes the actions and its related information.
  98930. * @param parent defines the object to serialize in
  98931. * @returns the serialized object
  98932. */
  98933. serialize(parent: any): any;
  98934. }
  98935. }
  98936. declare module BABYLON {
  98937. /**
  98938. * This defines an action responsible to change the value of a property
  98939. * by interpolating between its current value and the newly set one once triggered.
  98940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98941. */
  98942. export class InterpolateValueAction extends Action {
  98943. /**
  98944. * Defines the path of the property where the value should be interpolated
  98945. */
  98946. propertyPath: string;
  98947. /**
  98948. * Defines the target value at the end of the interpolation.
  98949. */
  98950. value: any;
  98951. /**
  98952. * Defines the time it will take for the property to interpolate to the value.
  98953. */
  98954. duration: number;
  98955. /**
  98956. * Defines if the other scene animations should be stopped when the action has been triggered
  98957. */
  98958. stopOtherAnimations?: boolean;
  98959. /**
  98960. * Defines a callback raised once the interpolation animation has been done.
  98961. */
  98962. onInterpolationDone?: () => void;
  98963. /**
  98964. * Observable triggered once the interpolation animation has been done.
  98965. */
  98966. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98967. private _target;
  98968. private _effectiveTarget;
  98969. private _property;
  98970. /**
  98971. * Instantiate the action
  98972. * @param triggerOptions defines the trigger options
  98973. * @param target defines the object containing the value to interpolate
  98974. * @param propertyPath defines the path to the property in the target object
  98975. * @param value defines the target value at the end of the interpolation
  98976. * @param duration deines the time it will take for the property to interpolate to the value.
  98977. * @param condition defines the trigger related conditions
  98978. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98979. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98980. */
  98981. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98982. /** @hidden */
  98983. _prepare(): void;
  98984. /**
  98985. * Execute the action starts the value interpolation.
  98986. */
  98987. execute(): void;
  98988. /**
  98989. * Serializes the actions and its related information.
  98990. * @param parent defines the object to serialize in
  98991. * @returns the serialized object
  98992. */
  98993. serialize(parent: any): any;
  98994. }
  98995. }
  98996. declare module BABYLON {
  98997. /**
  98998. * Options allowed during the creation of a sound track.
  98999. */
  99000. export interface ISoundTrackOptions {
  99001. /**
  99002. * The volume the sound track should take during creation
  99003. */
  99004. volume?: number;
  99005. /**
  99006. * Define if the sound track is the main sound track of the scene
  99007. */
  99008. mainTrack?: boolean;
  99009. }
  99010. /**
  99011. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99012. * It will be also used in a future release to apply effects on a specific track.
  99013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99014. */
  99015. export class SoundTrack {
  99016. /**
  99017. * The unique identifier of the sound track in the scene.
  99018. */
  99019. id: number;
  99020. /**
  99021. * The list of sounds included in the sound track.
  99022. */
  99023. soundCollection: Array<Sound>;
  99024. private _outputAudioNode;
  99025. private _scene;
  99026. private _isMainTrack;
  99027. private _connectedAnalyser;
  99028. private _options;
  99029. private _isInitialized;
  99030. /**
  99031. * Creates a new sound track.
  99032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99033. * @param scene Define the scene the sound track belongs to
  99034. * @param options
  99035. */
  99036. constructor(scene: Scene, options?: ISoundTrackOptions);
  99037. private _initializeSoundTrackAudioGraph;
  99038. /**
  99039. * Release the sound track and its associated resources
  99040. */
  99041. dispose(): void;
  99042. /**
  99043. * Adds a sound to this sound track
  99044. * @param sound define the cound to add
  99045. * @ignoreNaming
  99046. */
  99047. AddSound(sound: Sound): void;
  99048. /**
  99049. * Removes a sound to this sound track
  99050. * @param sound define the cound to remove
  99051. * @ignoreNaming
  99052. */
  99053. RemoveSound(sound: Sound): void;
  99054. /**
  99055. * Set a global volume for the full sound track.
  99056. * @param newVolume Define the new volume of the sound track
  99057. */
  99058. setVolume(newVolume: number): void;
  99059. /**
  99060. * Switch the panning model to HRTF:
  99061. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99063. */
  99064. switchPanningModelToHRTF(): void;
  99065. /**
  99066. * Switch the panning model to Equal Power:
  99067. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99069. */
  99070. switchPanningModelToEqualPower(): void;
  99071. /**
  99072. * Connect the sound track to an audio analyser allowing some amazing
  99073. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99075. * @param analyser The analyser to connect to the engine
  99076. */
  99077. connectToAnalyser(analyser: Analyser): void;
  99078. }
  99079. }
  99080. declare module BABYLON {
  99081. interface AbstractScene {
  99082. /**
  99083. * The list of sounds used in the scene.
  99084. */
  99085. sounds: Nullable<Array<Sound>>;
  99086. }
  99087. interface Scene {
  99088. /**
  99089. * @hidden
  99090. * Backing field
  99091. */
  99092. _mainSoundTrack: SoundTrack;
  99093. /**
  99094. * The main sound track played by the scene.
  99095. * It cotains your primary collection of sounds.
  99096. */
  99097. mainSoundTrack: SoundTrack;
  99098. /**
  99099. * The list of sound tracks added to the scene
  99100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99101. */
  99102. soundTracks: Nullable<Array<SoundTrack>>;
  99103. /**
  99104. * Gets a sound using a given name
  99105. * @param name defines the name to search for
  99106. * @return the found sound or null if not found at all.
  99107. */
  99108. getSoundByName(name: string): Nullable<Sound>;
  99109. /**
  99110. * Gets or sets if audio support is enabled
  99111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99112. */
  99113. audioEnabled: boolean;
  99114. /**
  99115. * Gets or sets if audio will be output to headphones
  99116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99117. */
  99118. headphone: boolean;
  99119. }
  99120. /**
  99121. * Defines the sound scene component responsible to manage any sounds
  99122. * in a given scene.
  99123. */
  99124. export class AudioSceneComponent implements ISceneSerializableComponent {
  99125. /**
  99126. * The component name helpfull to identify the component in the list of scene components.
  99127. */
  99128. readonly name: string;
  99129. /**
  99130. * The scene the component belongs to.
  99131. */
  99132. scene: Scene;
  99133. private _audioEnabled;
  99134. /**
  99135. * Gets whether audio is enabled or not.
  99136. * Please use related enable/disable method to switch state.
  99137. */
  99138. readonly audioEnabled: boolean;
  99139. private _headphone;
  99140. /**
  99141. * Gets whether audio is outputing to headphone or not.
  99142. * Please use the according Switch methods to change output.
  99143. */
  99144. readonly headphone: boolean;
  99145. /**
  99146. * Creates a new instance of the component for the given scene
  99147. * @param scene Defines the scene to register the component in
  99148. */
  99149. constructor(scene: Scene);
  99150. /**
  99151. * Registers the component in a given scene
  99152. */
  99153. register(): void;
  99154. /**
  99155. * Rebuilds the elements related to this component in case of
  99156. * context lost for instance.
  99157. */
  99158. rebuild(): void;
  99159. /**
  99160. * Serializes the component data to the specified json object
  99161. * @param serializationObject The object to serialize to
  99162. */
  99163. serialize(serializationObject: any): void;
  99164. /**
  99165. * Adds all the elements from the container to the scene
  99166. * @param container the container holding the elements
  99167. */
  99168. addFromContainer(container: AbstractScene): void;
  99169. /**
  99170. * Removes all the elements in the container from the scene
  99171. * @param container contains the elements to remove
  99172. * @param dispose if the removed element should be disposed (default: false)
  99173. */
  99174. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99175. /**
  99176. * Disposes the component and the associated ressources.
  99177. */
  99178. dispose(): void;
  99179. /**
  99180. * Disables audio in the associated scene.
  99181. */
  99182. disableAudio(): void;
  99183. /**
  99184. * Enables audio in the associated scene.
  99185. */
  99186. enableAudio(): void;
  99187. /**
  99188. * Switch audio to headphone output.
  99189. */
  99190. switchAudioModeForHeadphones(): void;
  99191. /**
  99192. * Switch audio to normal speakers.
  99193. */
  99194. switchAudioModeForNormalSpeakers(): void;
  99195. private _afterRender;
  99196. }
  99197. }
  99198. declare module BABYLON {
  99199. /**
  99200. * Wraps one or more Sound objects and selects one with random weight for playback.
  99201. */
  99202. export class WeightedSound {
  99203. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99204. loop: boolean;
  99205. private _coneInnerAngle;
  99206. private _coneOuterAngle;
  99207. private _volume;
  99208. /** A Sound is currently playing. */
  99209. isPlaying: boolean;
  99210. /** A Sound is currently paused. */
  99211. isPaused: boolean;
  99212. private _sounds;
  99213. private _weights;
  99214. private _currentIndex?;
  99215. /**
  99216. * Creates a new WeightedSound from the list of sounds given.
  99217. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99218. * @param sounds Array of Sounds that will be selected from.
  99219. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99220. */
  99221. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99222. /**
  99223. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99224. */
  99225. /**
  99226. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99227. */
  99228. directionalConeInnerAngle: number;
  99229. /**
  99230. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99231. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99232. */
  99233. /**
  99234. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99235. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99236. */
  99237. directionalConeOuterAngle: number;
  99238. /**
  99239. * Playback volume.
  99240. */
  99241. /**
  99242. * Playback volume.
  99243. */
  99244. volume: number;
  99245. private _onended;
  99246. /**
  99247. * Suspend playback
  99248. */
  99249. pause(): void;
  99250. /**
  99251. * Stop playback
  99252. */
  99253. stop(): void;
  99254. /**
  99255. * Start playback.
  99256. * @param startOffset Position the clip head at a specific time in seconds.
  99257. */
  99258. play(startOffset?: number): void;
  99259. }
  99260. }
  99261. declare module BABYLON {
  99262. /**
  99263. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99264. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99265. */
  99266. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99267. /**
  99268. * Gets the name of the behavior.
  99269. */
  99270. readonly name: string;
  99271. /**
  99272. * The easing function used by animations
  99273. */
  99274. static EasingFunction: BackEase;
  99275. /**
  99276. * The easing mode used by animations
  99277. */
  99278. static EasingMode: number;
  99279. /**
  99280. * The duration of the animation, in milliseconds
  99281. */
  99282. transitionDuration: number;
  99283. /**
  99284. * Length of the distance animated by the transition when lower radius is reached
  99285. */
  99286. lowerRadiusTransitionRange: number;
  99287. /**
  99288. * Length of the distance animated by the transition when upper radius is reached
  99289. */
  99290. upperRadiusTransitionRange: number;
  99291. private _autoTransitionRange;
  99292. /**
  99293. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99294. */
  99295. /**
  99296. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99297. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99298. */
  99299. autoTransitionRange: boolean;
  99300. private _attachedCamera;
  99301. private _onAfterCheckInputsObserver;
  99302. private _onMeshTargetChangedObserver;
  99303. /**
  99304. * Initializes the behavior.
  99305. */
  99306. init(): void;
  99307. /**
  99308. * Attaches the behavior to its arc rotate camera.
  99309. * @param camera Defines the camera to attach the behavior to
  99310. */
  99311. attach(camera: ArcRotateCamera): void;
  99312. /**
  99313. * Detaches the behavior from its current arc rotate camera.
  99314. */
  99315. detach(): void;
  99316. private _radiusIsAnimating;
  99317. private _radiusBounceTransition;
  99318. private _animatables;
  99319. private _cachedWheelPrecision;
  99320. /**
  99321. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99322. * @param radiusLimit The limit to check against.
  99323. * @return Bool to indicate if at limit.
  99324. */
  99325. private _isRadiusAtLimit;
  99326. /**
  99327. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99328. * @param radiusDelta The delta by which to animate to. Can be negative.
  99329. */
  99330. private _applyBoundRadiusAnimation;
  99331. /**
  99332. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99333. */
  99334. protected _clearAnimationLocks(): void;
  99335. /**
  99336. * Stops and removes all animations that have been applied to the camera
  99337. */
  99338. stopAllAnimations(): void;
  99339. }
  99340. }
  99341. declare module BABYLON {
  99342. /**
  99343. * 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.
  99344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99345. */
  99346. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99347. /**
  99348. * Gets the name of the behavior.
  99349. */
  99350. readonly name: string;
  99351. private _mode;
  99352. private _radiusScale;
  99353. private _positionScale;
  99354. private _defaultElevation;
  99355. private _elevationReturnTime;
  99356. private _elevationReturnWaitTime;
  99357. private _zoomStopsAnimation;
  99358. private _framingTime;
  99359. /**
  99360. * The easing function used by animations
  99361. */
  99362. static EasingFunction: ExponentialEase;
  99363. /**
  99364. * The easing mode used by animations
  99365. */
  99366. static EasingMode: number;
  99367. /**
  99368. * Sets the current mode used by the behavior
  99369. */
  99370. /**
  99371. * Gets current mode used by the behavior.
  99372. */
  99373. mode: number;
  99374. /**
  99375. * Sets the scale applied to the radius (1 by default)
  99376. */
  99377. /**
  99378. * Gets the scale applied to the radius
  99379. */
  99380. radiusScale: number;
  99381. /**
  99382. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99383. */
  99384. /**
  99385. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99386. */
  99387. positionScale: number;
  99388. /**
  99389. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99390. * behaviour is triggered, in radians.
  99391. */
  99392. /**
  99393. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99394. * behaviour is triggered, in radians.
  99395. */
  99396. defaultElevation: number;
  99397. /**
  99398. * Sets the time (in milliseconds) taken to return to the default beta position.
  99399. * Negative value indicates camera should not return to default.
  99400. */
  99401. /**
  99402. * Gets the time (in milliseconds) taken to return to the default beta position.
  99403. * Negative value indicates camera should not return to default.
  99404. */
  99405. elevationReturnTime: number;
  99406. /**
  99407. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99408. */
  99409. /**
  99410. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99411. */
  99412. elevationReturnWaitTime: number;
  99413. /**
  99414. * Sets the flag that indicates if user zooming should stop animation.
  99415. */
  99416. /**
  99417. * Gets the flag that indicates if user zooming should stop animation.
  99418. */
  99419. zoomStopsAnimation: boolean;
  99420. /**
  99421. * Sets the transition time when framing the mesh, in milliseconds
  99422. */
  99423. /**
  99424. * Gets the transition time when framing the mesh, in milliseconds
  99425. */
  99426. framingTime: number;
  99427. /**
  99428. * Define if the behavior should automatically change the configured
  99429. * camera limits and sensibilities.
  99430. */
  99431. autoCorrectCameraLimitsAndSensibility: boolean;
  99432. private _onPrePointerObservableObserver;
  99433. private _onAfterCheckInputsObserver;
  99434. private _onMeshTargetChangedObserver;
  99435. private _attachedCamera;
  99436. private _isPointerDown;
  99437. private _lastInteractionTime;
  99438. /**
  99439. * Initializes the behavior.
  99440. */
  99441. init(): void;
  99442. /**
  99443. * Attaches the behavior to its arc rotate camera.
  99444. * @param camera Defines the camera to attach the behavior to
  99445. */
  99446. attach(camera: ArcRotateCamera): void;
  99447. /**
  99448. * Detaches the behavior from its current arc rotate camera.
  99449. */
  99450. detach(): void;
  99451. private _animatables;
  99452. private _betaIsAnimating;
  99453. private _betaTransition;
  99454. private _radiusTransition;
  99455. private _vectorTransition;
  99456. /**
  99457. * Targets the given mesh and updates zoom level accordingly.
  99458. * @param mesh The mesh to target.
  99459. * @param radius Optional. If a cached radius position already exists, overrides default.
  99460. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99461. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99462. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99463. */
  99464. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99465. /**
  99466. * Targets the given mesh with its children and updates zoom level accordingly.
  99467. * @param mesh The mesh to target.
  99468. * @param radius Optional. If a cached radius position already exists, overrides default.
  99469. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99472. */
  99473. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99474. /**
  99475. * Targets the given meshes with their children and updates zoom level accordingly.
  99476. * @param meshes The mesh to target.
  99477. * @param radius Optional. If a cached radius position already exists, overrides default.
  99478. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99481. */
  99482. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99483. /**
  99484. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99485. * @param minimumWorld Determines the smaller position of the bounding box extend
  99486. * @param maximumWorld Determines the bigger position of the bounding box extend
  99487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99489. */
  99490. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99491. /**
  99492. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99493. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99494. * frustum width.
  99495. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99496. * to fully enclose the mesh in the viewing frustum.
  99497. */
  99498. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99499. /**
  99500. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99501. * is automatically returned to its default position (expected to be above ground plane).
  99502. */
  99503. private _maintainCameraAboveGround;
  99504. /**
  99505. * Returns the frustum slope based on the canvas ratio and camera FOV
  99506. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99507. */
  99508. private _getFrustumSlope;
  99509. /**
  99510. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99511. */
  99512. private _clearAnimationLocks;
  99513. /**
  99514. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99515. */
  99516. private _applyUserInteraction;
  99517. /**
  99518. * Stops and removes all animations that have been applied to the camera
  99519. */
  99520. stopAllAnimations(): void;
  99521. /**
  99522. * Gets a value indicating if the user is moving the camera
  99523. */
  99524. readonly isUserIsMoving: boolean;
  99525. /**
  99526. * The camera can move all the way towards the mesh.
  99527. */
  99528. static IgnoreBoundsSizeMode: number;
  99529. /**
  99530. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99531. */
  99532. static FitFrustumSidesMode: number;
  99533. }
  99534. }
  99535. declare module BABYLON {
  99536. /**
  99537. * Base class for Camera Pointer Inputs.
  99538. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99539. * for example usage.
  99540. */
  99541. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99542. /**
  99543. * Defines the camera the input is attached to.
  99544. */
  99545. abstract camera: Camera;
  99546. /**
  99547. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99548. */
  99549. protected _altKey: boolean;
  99550. protected _ctrlKey: boolean;
  99551. protected _metaKey: boolean;
  99552. protected _shiftKey: boolean;
  99553. /**
  99554. * Which mouse buttons were pressed at time of last mouse event.
  99555. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99556. */
  99557. protected _buttonsPressed: number;
  99558. /**
  99559. * Defines the buttons associated with the input to handle camera move.
  99560. */
  99561. buttons: number[];
  99562. /**
  99563. * Attach the input controls to a specific dom element to get the input from.
  99564. * @param element Defines the element the controls should be listened from
  99565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99566. */
  99567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99568. /**
  99569. * Detach the current controls from the specified dom element.
  99570. * @param element Defines the element to stop listening the inputs from
  99571. */
  99572. detachControl(element: Nullable<HTMLElement>): void;
  99573. /**
  99574. * Gets the class name of the current input.
  99575. * @returns the class name
  99576. */
  99577. getClassName(): string;
  99578. /**
  99579. * Get the friendly name associated with the input class.
  99580. * @returns the input friendly name
  99581. */
  99582. getSimpleName(): string;
  99583. /**
  99584. * Called on pointer POINTERDOUBLETAP event.
  99585. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99586. */
  99587. protected onDoubleTap(type: string): void;
  99588. /**
  99589. * Called on pointer POINTERMOVE event if only a single touch is active.
  99590. * Override this method to provide functionality.
  99591. */
  99592. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99593. /**
  99594. * Called on pointer POINTERMOVE event if multiple touches are active.
  99595. * Override this method to provide functionality.
  99596. */
  99597. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99598. /**
  99599. * Called on JS contextmenu event.
  99600. * Override this method to provide functionality.
  99601. */
  99602. protected onContextMenu(evt: PointerEvent): void;
  99603. /**
  99604. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99605. * press.
  99606. * Override this method to provide functionality.
  99607. */
  99608. protected onButtonDown(evt: PointerEvent): void;
  99609. /**
  99610. * Called each time a new POINTERUP event occurs. Ie, for each button
  99611. * release.
  99612. * Override this method to provide functionality.
  99613. */
  99614. protected onButtonUp(evt: PointerEvent): void;
  99615. /**
  99616. * Called when window becomes inactive.
  99617. * Override this method to provide functionality.
  99618. */
  99619. protected onLostFocus(): void;
  99620. private _pointerInput;
  99621. private _observer;
  99622. private _onLostFocus;
  99623. private pointA;
  99624. private pointB;
  99625. }
  99626. }
  99627. declare module BABYLON {
  99628. /**
  99629. * Manage the pointers inputs to control an arc rotate camera.
  99630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99631. */
  99632. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99633. /**
  99634. * Defines the camera the input is attached to.
  99635. */
  99636. camera: ArcRotateCamera;
  99637. /**
  99638. * Gets the class name of the current input.
  99639. * @returns the class name
  99640. */
  99641. getClassName(): string;
  99642. /**
  99643. * Defines the buttons associated with the input to handle camera move.
  99644. */
  99645. buttons: number[];
  99646. /**
  99647. * Defines the pointer angular sensibility along the X axis or how fast is
  99648. * the camera rotating.
  99649. */
  99650. angularSensibilityX: number;
  99651. /**
  99652. * Defines the pointer angular sensibility along the Y axis or how fast is
  99653. * the camera rotating.
  99654. */
  99655. angularSensibilityY: number;
  99656. /**
  99657. * Defines the pointer pinch precision or how fast is the camera zooming.
  99658. */
  99659. pinchPrecision: number;
  99660. /**
  99661. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99662. * from 0.
  99663. * It defines the percentage of current camera.radius to use as delta when
  99664. * pinch zoom is used.
  99665. */
  99666. pinchDeltaPercentage: number;
  99667. /**
  99668. * Defines the pointer panning sensibility or how fast is the camera moving.
  99669. */
  99670. panningSensibility: number;
  99671. /**
  99672. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99673. */
  99674. multiTouchPanning: boolean;
  99675. /**
  99676. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99677. * zoom (pinch) through multitouch.
  99678. */
  99679. multiTouchPanAndZoom: boolean;
  99680. /**
  99681. * Revers pinch action direction.
  99682. */
  99683. pinchInwards: boolean;
  99684. private _isPanClick;
  99685. private _twoFingerActivityCount;
  99686. private _isPinching;
  99687. /**
  99688. * Called on pointer POINTERMOVE event if only a single touch is active.
  99689. */
  99690. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99691. /**
  99692. * Called on pointer POINTERDOUBLETAP event.
  99693. */
  99694. protected onDoubleTap(type: string): void;
  99695. /**
  99696. * Called on pointer POINTERMOVE event if multiple touches are active.
  99697. */
  99698. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99699. /**
  99700. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99701. * press.
  99702. */
  99703. protected onButtonDown(evt: PointerEvent): void;
  99704. /**
  99705. * Called each time a new POINTERUP event occurs. Ie, for each button
  99706. * release.
  99707. */
  99708. protected onButtonUp(evt: PointerEvent): void;
  99709. /**
  99710. * Called when window becomes inactive.
  99711. */
  99712. protected onLostFocus(): void;
  99713. }
  99714. }
  99715. declare module BABYLON {
  99716. /**
  99717. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99719. */
  99720. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99721. /**
  99722. * Defines the camera the input is attached to.
  99723. */
  99724. camera: ArcRotateCamera;
  99725. /**
  99726. * Defines the list of key codes associated with the up action (increase alpha)
  99727. */
  99728. keysUp: number[];
  99729. /**
  99730. * Defines the list of key codes associated with the down action (decrease alpha)
  99731. */
  99732. keysDown: number[];
  99733. /**
  99734. * Defines the list of key codes associated with the left action (increase beta)
  99735. */
  99736. keysLeft: number[];
  99737. /**
  99738. * Defines the list of key codes associated with the right action (decrease beta)
  99739. */
  99740. keysRight: number[];
  99741. /**
  99742. * Defines the list of key codes associated with the reset action.
  99743. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99744. */
  99745. keysReset: number[];
  99746. /**
  99747. * Defines the panning sensibility of the inputs.
  99748. * (How fast is the camera paning)
  99749. */
  99750. panningSensibility: number;
  99751. /**
  99752. * Defines the zooming sensibility of the inputs.
  99753. * (How fast is the camera zooming)
  99754. */
  99755. zoomingSensibility: number;
  99756. /**
  99757. * Defines wether maintaining the alt key down switch the movement mode from
  99758. * orientation to zoom.
  99759. */
  99760. useAltToZoom: boolean;
  99761. /**
  99762. * Rotation speed of the camera
  99763. */
  99764. angularSpeed: number;
  99765. private _keys;
  99766. private _ctrlPressed;
  99767. private _altPressed;
  99768. private _onCanvasBlurObserver;
  99769. private _onKeyboardObserver;
  99770. private _engine;
  99771. private _scene;
  99772. /**
  99773. * Attach the input controls to a specific dom element to get the input from.
  99774. * @param element Defines the element the controls should be listened from
  99775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99776. */
  99777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99778. /**
  99779. * Detach the current controls from the specified dom element.
  99780. * @param element Defines the element to stop listening the inputs from
  99781. */
  99782. detachControl(element: Nullable<HTMLElement>): void;
  99783. /**
  99784. * Update the current camera state depending on the inputs that have been used this frame.
  99785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99786. */
  99787. checkInputs(): void;
  99788. /**
  99789. * Gets the class name of the current intput.
  99790. * @returns the class name
  99791. */
  99792. getClassName(): string;
  99793. /**
  99794. * Get the friendly name associated with the input class.
  99795. * @returns the input friendly name
  99796. */
  99797. getSimpleName(): string;
  99798. }
  99799. }
  99800. declare module BABYLON {
  99801. /**
  99802. * Manage the mouse wheel inputs to control an arc rotate camera.
  99803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99804. */
  99805. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  99806. /**
  99807. * Defines the camera the input is attached to.
  99808. */
  99809. camera: ArcRotateCamera;
  99810. /**
  99811. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99812. */
  99813. wheelPrecision: number;
  99814. /**
  99815. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99816. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99817. */
  99818. wheelDeltaPercentage: number;
  99819. private _wheel;
  99820. private _observer;
  99821. private computeDeltaFromMouseWheelLegacyEvent;
  99822. /**
  99823. * Attach the input controls to a specific dom element to get the input from.
  99824. * @param element Defines the element the controls should be listened from
  99825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99826. */
  99827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99828. /**
  99829. * Detach the current controls from the specified dom element.
  99830. * @param element Defines the element to stop listening the inputs from
  99831. */
  99832. detachControl(element: Nullable<HTMLElement>): void;
  99833. /**
  99834. * Gets the class name of the current intput.
  99835. * @returns the class name
  99836. */
  99837. getClassName(): string;
  99838. /**
  99839. * Get the friendly name associated with the input class.
  99840. * @returns the input friendly name
  99841. */
  99842. getSimpleName(): string;
  99843. }
  99844. }
  99845. declare module BABYLON {
  99846. /**
  99847. * Default Inputs manager for the ArcRotateCamera.
  99848. * It groups all the default supported inputs for ease of use.
  99849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99850. */
  99851. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  99852. /**
  99853. * Instantiates a new ArcRotateCameraInputsManager.
  99854. * @param camera Defines the camera the inputs belong to
  99855. */
  99856. constructor(camera: ArcRotateCamera);
  99857. /**
  99858. * Add mouse wheel input support to the input manager.
  99859. * @returns the current input manager
  99860. */
  99861. addMouseWheel(): ArcRotateCameraInputsManager;
  99862. /**
  99863. * Add pointers input support to the input manager.
  99864. * @returns the current input manager
  99865. */
  99866. addPointers(): ArcRotateCameraInputsManager;
  99867. /**
  99868. * Add keyboard input support to the input manager.
  99869. * @returns the current input manager
  99870. */
  99871. addKeyboard(): ArcRotateCameraInputsManager;
  99872. }
  99873. }
  99874. declare module BABYLON {
  99875. /**
  99876. * This represents an orbital type of camera.
  99877. *
  99878. * 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.
  99879. * 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.
  99880. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  99881. */
  99882. export class ArcRotateCamera extends TargetCamera {
  99883. /**
  99884. * Defines the rotation angle of the camera along the longitudinal axis.
  99885. */
  99886. alpha: number;
  99887. /**
  99888. * Defines the rotation angle of the camera along the latitudinal axis.
  99889. */
  99890. beta: number;
  99891. /**
  99892. * Defines the radius of the camera from it s target point.
  99893. */
  99894. radius: number;
  99895. protected _target: Vector3;
  99896. protected _targetHost: Nullable<AbstractMesh>;
  99897. /**
  99898. * Defines the target point of the camera.
  99899. * The camera looks towards it form the radius distance.
  99900. */
  99901. target: Vector3;
  99902. /**
  99903. * Define the current local position of the camera in the scene
  99904. */
  99905. position: Vector3;
  99906. protected _upVector: Vector3;
  99907. protected _upToYMatrix: Matrix;
  99908. protected _YToUpMatrix: Matrix;
  99909. /**
  99910. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99911. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99912. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99913. */
  99914. upVector: Vector3;
  99915. /**
  99916. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99917. */
  99918. setMatUp(): void;
  99919. /**
  99920. * Current inertia value on the longitudinal axis.
  99921. * The bigger this number the longer it will take for the camera to stop.
  99922. */
  99923. inertialAlphaOffset: number;
  99924. /**
  99925. * Current inertia value on the latitudinal axis.
  99926. * The bigger this number the longer it will take for the camera to stop.
  99927. */
  99928. inertialBetaOffset: number;
  99929. /**
  99930. * Current inertia value on the radius axis.
  99931. * The bigger this number the longer it will take for the camera to stop.
  99932. */
  99933. inertialRadiusOffset: number;
  99934. /**
  99935. * Minimum allowed angle on the longitudinal axis.
  99936. * This can help limiting how the Camera is able to move in the scene.
  99937. */
  99938. lowerAlphaLimit: Nullable<number>;
  99939. /**
  99940. * Maximum allowed angle on the longitudinal axis.
  99941. * This can help limiting how the Camera is able to move in the scene.
  99942. */
  99943. upperAlphaLimit: Nullable<number>;
  99944. /**
  99945. * Minimum allowed angle on the latitudinal axis.
  99946. * This can help limiting how the Camera is able to move in the scene.
  99947. */
  99948. lowerBetaLimit: number;
  99949. /**
  99950. * Maximum allowed angle on the latitudinal axis.
  99951. * This can help limiting how the Camera is able to move in the scene.
  99952. */
  99953. upperBetaLimit: number;
  99954. /**
  99955. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99956. * This can help limiting how the Camera is able to move in the scene.
  99957. */
  99958. lowerRadiusLimit: Nullable<number>;
  99959. /**
  99960. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99961. * This can help limiting how the Camera is able to move in the scene.
  99962. */
  99963. upperRadiusLimit: Nullable<number>;
  99964. /**
  99965. * Defines the current inertia value used during panning of the camera along the X axis.
  99966. */
  99967. inertialPanningX: number;
  99968. /**
  99969. * Defines the current inertia value used during panning of the camera along the Y axis.
  99970. */
  99971. inertialPanningY: number;
  99972. /**
  99973. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99974. * Basically if your fingers moves away from more than this distance you will be considered
  99975. * in pinch mode.
  99976. */
  99977. pinchToPanMaxDistance: number;
  99978. /**
  99979. * Defines the maximum distance the camera can pan.
  99980. * This could help keeping the cammera always in your scene.
  99981. */
  99982. panningDistanceLimit: Nullable<number>;
  99983. /**
  99984. * Defines the target of the camera before paning.
  99985. */
  99986. panningOriginTarget: Vector3;
  99987. /**
  99988. * Defines the value of the inertia used during panning.
  99989. * 0 would mean stop inertia and one would mean no decelleration at all.
  99990. */
  99991. panningInertia: number;
  99992. /**
  99993. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99994. */
  99995. angularSensibilityX: number;
  99996. /**
  99997. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99998. */
  99999. angularSensibilityY: number;
  100000. /**
  100001. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100002. */
  100003. pinchPrecision: number;
  100004. /**
  100005. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100006. * It will be used instead of pinchDeltaPrecision if different from 0.
  100007. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100008. */
  100009. pinchDeltaPercentage: number;
  100010. /**
  100011. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100012. */
  100013. panningSensibility: number;
  100014. /**
  100015. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100016. */
  100017. keysUp: number[];
  100018. /**
  100019. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100020. */
  100021. keysDown: number[];
  100022. /**
  100023. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100024. */
  100025. keysLeft: number[];
  100026. /**
  100027. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100028. */
  100029. keysRight: number[];
  100030. /**
  100031. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100032. */
  100033. wheelPrecision: number;
  100034. /**
  100035. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100036. * It will be used instead of pinchDeltaPrecision if different from 0.
  100037. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100038. */
  100039. wheelDeltaPercentage: number;
  100040. /**
  100041. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100042. */
  100043. zoomOnFactor: number;
  100044. /**
  100045. * Defines a screen offset for the camera position.
  100046. */
  100047. targetScreenOffset: Vector2;
  100048. /**
  100049. * Allows the camera to be completely reversed.
  100050. * If false the camera can not arrive upside down.
  100051. */
  100052. allowUpsideDown: boolean;
  100053. /**
  100054. * Define if double tap/click is used to restore the previously saved state of the camera.
  100055. */
  100056. useInputToRestoreState: boolean;
  100057. /** @hidden */
  100058. _viewMatrix: Matrix;
  100059. /** @hidden */
  100060. _useCtrlForPanning: boolean;
  100061. /** @hidden */
  100062. _panningMouseButton: number;
  100063. /**
  100064. * Defines the input associated to the camera.
  100065. */
  100066. inputs: ArcRotateCameraInputsManager;
  100067. /** @hidden */
  100068. _reset: () => void;
  100069. /**
  100070. * Defines the allowed panning axis.
  100071. */
  100072. panningAxis: Vector3;
  100073. protected _localDirection: Vector3;
  100074. protected _transformedDirection: Vector3;
  100075. private _bouncingBehavior;
  100076. /**
  100077. * Gets the bouncing behavior of the camera if it has been enabled.
  100078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100079. */
  100080. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100081. /**
  100082. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100083. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100084. */
  100085. useBouncingBehavior: boolean;
  100086. private _framingBehavior;
  100087. /**
  100088. * Gets the framing behavior of the camera if it has been enabled.
  100089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100090. */
  100091. readonly framingBehavior: Nullable<FramingBehavior>;
  100092. /**
  100093. * Defines if the framing behavior of the camera is enabled on the camera.
  100094. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100095. */
  100096. useFramingBehavior: boolean;
  100097. private _autoRotationBehavior;
  100098. /**
  100099. * Gets the auto rotation behavior of the camera if it has been enabled.
  100100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100101. */
  100102. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100103. /**
  100104. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100106. */
  100107. useAutoRotationBehavior: boolean;
  100108. /**
  100109. * Observable triggered when the mesh target has been changed on the camera.
  100110. */
  100111. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100112. /**
  100113. * Event raised when the camera is colliding with a mesh.
  100114. */
  100115. onCollide: (collidedMesh: AbstractMesh) => void;
  100116. /**
  100117. * Defines whether the camera should check collision with the objects oh the scene.
  100118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100119. */
  100120. checkCollisions: boolean;
  100121. /**
  100122. * Defines the collision radius of the camera.
  100123. * This simulates a sphere around the camera.
  100124. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100125. */
  100126. collisionRadius: Vector3;
  100127. protected _collider: Collider;
  100128. protected _previousPosition: Vector3;
  100129. protected _collisionVelocity: Vector3;
  100130. protected _newPosition: Vector3;
  100131. protected _previousAlpha: number;
  100132. protected _previousBeta: number;
  100133. protected _previousRadius: number;
  100134. protected _collisionTriggered: boolean;
  100135. protected _targetBoundingCenter: Nullable<Vector3>;
  100136. private _computationVector;
  100137. /**
  100138. * Instantiates a new ArcRotateCamera in a given scene
  100139. * @param name Defines the name of the camera
  100140. * @param alpha Defines the camera rotation along the logitudinal axis
  100141. * @param beta Defines the camera rotation along the latitudinal axis
  100142. * @param radius Defines the camera distance from its target
  100143. * @param target Defines the camera target
  100144. * @param scene Defines the scene the camera belongs to
  100145. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100146. */
  100147. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100148. /** @hidden */
  100149. _initCache(): void;
  100150. /** @hidden */
  100151. _updateCache(ignoreParentClass?: boolean): void;
  100152. protected _getTargetPosition(): Vector3;
  100153. private _storedAlpha;
  100154. private _storedBeta;
  100155. private _storedRadius;
  100156. private _storedTarget;
  100157. /**
  100158. * Stores the current state of the camera (alpha, beta, radius and target)
  100159. * @returns the camera itself
  100160. */
  100161. storeState(): Camera;
  100162. /**
  100163. * @hidden
  100164. * Restored camera state. You must call storeState() first
  100165. */
  100166. _restoreStateValues(): boolean;
  100167. /** @hidden */
  100168. _isSynchronizedViewMatrix(): boolean;
  100169. /**
  100170. * Attached controls to the current camera.
  100171. * @param element Defines the element the controls should be listened from
  100172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100173. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100174. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100175. */
  100176. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100177. /**
  100178. * Detach the current controls from the camera.
  100179. * The camera will stop reacting to inputs.
  100180. * @param element Defines the element to stop listening the inputs from
  100181. */
  100182. detachControl(element: HTMLElement): void;
  100183. /** @hidden */
  100184. _checkInputs(): void;
  100185. protected _checkLimits(): void;
  100186. /**
  100187. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100188. */
  100189. rebuildAnglesAndRadius(): void;
  100190. /**
  100191. * Use a position to define the current camera related information like aplha, beta and radius
  100192. * @param position Defines the position to set the camera at
  100193. */
  100194. setPosition(position: Vector3): void;
  100195. /**
  100196. * Defines the target the camera should look at.
  100197. * This will automatically adapt alpha beta and radius to fit within the new target.
  100198. * @param target Defines the new target as a Vector or a mesh
  100199. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100200. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100201. */
  100202. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100203. /** @hidden */
  100204. _getViewMatrix(): Matrix;
  100205. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100206. /**
  100207. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100208. * @param meshes Defines the mesh to zoom on
  100209. * @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)
  100210. */
  100211. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100212. /**
  100213. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100214. * The target will be changed but the radius
  100215. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100216. * @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)
  100217. */
  100218. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100219. min: Vector3;
  100220. max: Vector3;
  100221. distance: number;
  100222. }, doNotUpdateMaxZ?: boolean): void;
  100223. /**
  100224. * @override
  100225. * Override Camera.createRigCamera
  100226. */
  100227. createRigCamera(name: string, cameraIndex: number): Camera;
  100228. /**
  100229. * @hidden
  100230. * @override
  100231. * Override Camera._updateRigCameras
  100232. */
  100233. _updateRigCameras(): void;
  100234. /**
  100235. * Destroy the camera and release the current resources hold by it.
  100236. */
  100237. dispose(): void;
  100238. /**
  100239. * Gets the current object class name.
  100240. * @return the class name
  100241. */
  100242. getClassName(): string;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100248. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100249. */
  100250. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100251. /**
  100252. * Gets the name of the behavior.
  100253. */
  100254. readonly name: string;
  100255. private _zoomStopsAnimation;
  100256. private _idleRotationSpeed;
  100257. private _idleRotationWaitTime;
  100258. private _idleRotationSpinupTime;
  100259. /**
  100260. * Sets the flag that indicates if user zooming should stop animation.
  100261. */
  100262. /**
  100263. * Gets the flag that indicates if user zooming should stop animation.
  100264. */
  100265. zoomStopsAnimation: boolean;
  100266. /**
  100267. * Sets the default speed at which the camera rotates around the model.
  100268. */
  100269. /**
  100270. * Gets the default speed at which the camera rotates around the model.
  100271. */
  100272. idleRotationSpeed: number;
  100273. /**
  100274. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100275. */
  100276. /**
  100277. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100278. */
  100279. idleRotationWaitTime: number;
  100280. /**
  100281. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100282. */
  100283. /**
  100284. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100285. */
  100286. idleRotationSpinupTime: number;
  100287. /**
  100288. * Gets a value indicating if the camera is currently rotating because of this behavior
  100289. */
  100290. readonly rotationInProgress: boolean;
  100291. private _onPrePointerObservableObserver;
  100292. private _onAfterCheckInputsObserver;
  100293. private _attachedCamera;
  100294. private _isPointerDown;
  100295. private _lastFrameTime;
  100296. private _lastInteractionTime;
  100297. private _cameraRotationSpeed;
  100298. /**
  100299. * Initializes the behavior.
  100300. */
  100301. init(): void;
  100302. /**
  100303. * Attaches the behavior to its arc rotate camera.
  100304. * @param camera Defines the camera to attach the behavior to
  100305. */
  100306. attach(camera: ArcRotateCamera): void;
  100307. /**
  100308. * Detaches the behavior from its current arc rotate camera.
  100309. */
  100310. detach(): void;
  100311. /**
  100312. * Returns true if user is scrolling.
  100313. * @return true if user is scrolling.
  100314. */
  100315. private _userIsZooming;
  100316. private _lastFrameRadius;
  100317. private _shouldAnimationStopForInteraction;
  100318. /**
  100319. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100320. */
  100321. private _applyUserInteraction;
  100322. private _userIsMoving;
  100323. }
  100324. }
  100325. declare module BABYLON {
  100326. /**
  100327. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100328. */
  100329. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100330. private ui;
  100331. /**
  100332. * The name of the behavior
  100333. */
  100334. name: string;
  100335. /**
  100336. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100337. */
  100338. distanceAwayFromFace: number;
  100339. /**
  100340. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100341. */
  100342. distanceAwayFromBottomOfFace: number;
  100343. private _faceVectors;
  100344. private _target;
  100345. private _scene;
  100346. private _onRenderObserver;
  100347. private _tmpMatrix;
  100348. private _tmpVector;
  100349. /**
  100350. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100351. * @param ui The transform node that should be attched to the mesh
  100352. */
  100353. constructor(ui: TransformNode);
  100354. /**
  100355. * Initializes the behavior
  100356. */
  100357. init(): void;
  100358. private _closestFace;
  100359. private _zeroVector;
  100360. private _lookAtTmpMatrix;
  100361. private _lookAtToRef;
  100362. /**
  100363. * Attaches the AttachToBoxBehavior to the passed in mesh
  100364. * @param target The mesh that the specified node will be attached to
  100365. */
  100366. attach(target: Mesh): void;
  100367. /**
  100368. * Detaches the behavior from the mesh
  100369. */
  100370. detach(): void;
  100371. }
  100372. }
  100373. declare module BABYLON {
  100374. /**
  100375. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100376. */
  100377. export class FadeInOutBehavior implements Behavior<Mesh> {
  100378. /**
  100379. * Time in milliseconds to delay before fading in (Default: 0)
  100380. */
  100381. delay: number;
  100382. /**
  100383. * Time in milliseconds for the mesh to fade in (Default: 300)
  100384. */
  100385. fadeInTime: number;
  100386. private _millisecondsPerFrame;
  100387. private _hovered;
  100388. private _hoverValue;
  100389. private _ownerNode;
  100390. /**
  100391. * Instatiates the FadeInOutBehavior
  100392. */
  100393. constructor();
  100394. /**
  100395. * The name of the behavior
  100396. */
  100397. readonly name: string;
  100398. /**
  100399. * Initializes the behavior
  100400. */
  100401. init(): void;
  100402. /**
  100403. * Attaches the fade behavior on the passed in mesh
  100404. * @param ownerNode The mesh that will be faded in/out once attached
  100405. */
  100406. attach(ownerNode: Mesh): void;
  100407. /**
  100408. * Detaches the behavior from the mesh
  100409. */
  100410. detach(): void;
  100411. /**
  100412. * Triggers the mesh to begin fading in or out
  100413. * @param value if the object should fade in or out (true to fade in)
  100414. */
  100415. fadeIn(value: boolean): void;
  100416. private _update;
  100417. private _setAllVisibility;
  100418. }
  100419. }
  100420. declare module BABYLON {
  100421. /**
  100422. * Class containing a set of static utilities functions for managing Pivots
  100423. * @hidden
  100424. */
  100425. export class PivotTools {
  100426. private static _PivotCached;
  100427. private static _OldPivotPoint;
  100428. private static _PivotTranslation;
  100429. private static _PivotTmpVector;
  100430. /** @hidden */
  100431. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100432. /** @hidden */
  100433. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100434. }
  100435. }
  100436. declare module BABYLON {
  100437. /**
  100438. * Class containing static functions to help procedurally build meshes
  100439. */
  100440. export class PlaneBuilder {
  100441. /**
  100442. * Creates a plane mesh
  100443. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100444. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100445. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100449. * @param name defines the name of the mesh
  100450. * @param options defines the options used to create the mesh
  100451. * @param scene defines the hosting scene
  100452. * @returns the plane mesh
  100453. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100454. */
  100455. static CreatePlane(name: string, options: {
  100456. size?: number;
  100457. width?: number;
  100458. height?: number;
  100459. sideOrientation?: number;
  100460. frontUVs?: Vector4;
  100461. backUVs?: Vector4;
  100462. updatable?: boolean;
  100463. sourcePlane?: Plane;
  100464. }, scene?: Nullable<Scene>): Mesh;
  100465. }
  100466. }
  100467. declare module BABYLON {
  100468. /**
  100469. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100470. */
  100471. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100472. private static _AnyMouseID;
  100473. /**
  100474. * Abstract mesh the behavior is set on
  100475. */
  100476. attachedNode: AbstractMesh;
  100477. private _dragPlane;
  100478. private _scene;
  100479. private _pointerObserver;
  100480. private _beforeRenderObserver;
  100481. private static _planeScene;
  100482. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100483. /**
  100484. * 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)
  100485. */
  100486. maxDragAngle: number;
  100487. /**
  100488. * @hidden
  100489. */
  100490. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100491. /**
  100492. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100493. */
  100494. currentDraggingPointerID: number;
  100495. /**
  100496. * The last position where the pointer hit the drag plane in world space
  100497. */
  100498. lastDragPosition: Vector3;
  100499. /**
  100500. * If the behavior is currently in a dragging state
  100501. */
  100502. dragging: boolean;
  100503. /**
  100504. * 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)
  100505. */
  100506. dragDeltaRatio: number;
  100507. /**
  100508. * If the drag plane orientation should be updated during the dragging (Default: true)
  100509. */
  100510. updateDragPlane: boolean;
  100511. private _debugMode;
  100512. private _moving;
  100513. /**
  100514. * Fires each time the attached mesh is dragged with the pointer
  100515. * * delta between last drag position and current drag position in world space
  100516. * * dragDistance along the drag axis
  100517. * * dragPlaneNormal normal of the current drag plane used during the drag
  100518. * * dragPlanePoint in world space where the drag intersects the drag plane
  100519. */
  100520. onDragObservable: Observable<{
  100521. delta: Vector3;
  100522. dragPlanePoint: Vector3;
  100523. dragPlaneNormal: Vector3;
  100524. dragDistance: number;
  100525. pointerId: number;
  100526. }>;
  100527. /**
  100528. * Fires each time a drag begins (eg. mouse down on mesh)
  100529. */
  100530. onDragStartObservable: Observable<{
  100531. dragPlanePoint: Vector3;
  100532. pointerId: number;
  100533. }>;
  100534. /**
  100535. * Fires each time a drag ends (eg. mouse release after drag)
  100536. */
  100537. onDragEndObservable: Observable<{
  100538. dragPlanePoint: Vector3;
  100539. pointerId: number;
  100540. }>;
  100541. /**
  100542. * If the attached mesh should be moved when dragged
  100543. */
  100544. moveAttached: boolean;
  100545. /**
  100546. * If the drag behavior will react to drag events (Default: true)
  100547. */
  100548. enabled: boolean;
  100549. /**
  100550. * If pointer events should start and release the drag (Default: true)
  100551. */
  100552. startAndReleaseDragOnPointerEvents: boolean;
  100553. /**
  100554. * If camera controls should be detached during the drag
  100555. */
  100556. detachCameraControls: boolean;
  100557. /**
  100558. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100559. */
  100560. useObjectOrienationForDragging: boolean;
  100561. private _options;
  100562. /**
  100563. * Creates a pointer drag behavior that can be attached to a mesh
  100564. * @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)
  100565. */
  100566. constructor(options?: {
  100567. dragAxis?: Vector3;
  100568. dragPlaneNormal?: Vector3;
  100569. });
  100570. /**
  100571. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100572. */
  100573. validateDrag: (targetPosition: Vector3) => boolean;
  100574. /**
  100575. * The name of the behavior
  100576. */
  100577. readonly name: string;
  100578. /**
  100579. * Initializes the behavior
  100580. */
  100581. init(): void;
  100582. private _tmpVector;
  100583. private _alternatePickedPoint;
  100584. private _worldDragAxis;
  100585. private _targetPosition;
  100586. private _attachedElement;
  100587. /**
  100588. * Attaches the drag behavior the passed in mesh
  100589. * @param ownerNode The mesh that will be dragged around once attached
  100590. */
  100591. attach(ownerNode: AbstractMesh): void;
  100592. /**
  100593. * Force relase the drag action by code.
  100594. */
  100595. releaseDrag(): void;
  100596. private _startDragRay;
  100597. private _lastPointerRay;
  100598. /**
  100599. * Simulates the start of a pointer drag event on the behavior
  100600. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100601. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100602. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100603. */
  100604. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100605. private _startDrag;
  100606. private _dragDelta;
  100607. private _moveDrag;
  100608. private _pickWithRayOnDragPlane;
  100609. private _pointA;
  100610. private _pointB;
  100611. private _pointC;
  100612. private _lineA;
  100613. private _lineB;
  100614. private _localAxis;
  100615. private _lookAt;
  100616. private _updateDragPlanePosition;
  100617. /**
  100618. * Detaches the behavior from the mesh
  100619. */
  100620. detach(): void;
  100621. }
  100622. }
  100623. declare module BABYLON {
  100624. /**
  100625. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100626. */
  100627. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100628. private _dragBehaviorA;
  100629. private _dragBehaviorB;
  100630. private _startDistance;
  100631. private _initialScale;
  100632. private _targetScale;
  100633. private _ownerNode;
  100634. private _sceneRenderObserver;
  100635. /**
  100636. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100637. */
  100638. constructor();
  100639. /**
  100640. * The name of the behavior
  100641. */
  100642. readonly name: string;
  100643. /**
  100644. * Initializes the behavior
  100645. */
  100646. init(): void;
  100647. private _getCurrentDistance;
  100648. /**
  100649. * Attaches the scale behavior the passed in mesh
  100650. * @param ownerNode The mesh that will be scaled around once attached
  100651. */
  100652. attach(ownerNode: Mesh): void;
  100653. /**
  100654. * Detaches the behavior from the mesh
  100655. */
  100656. detach(): void;
  100657. }
  100658. }
  100659. declare module BABYLON {
  100660. /**
  100661. * 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
  100662. */
  100663. export class SixDofDragBehavior implements Behavior<Mesh> {
  100664. private static _virtualScene;
  100665. private _ownerNode;
  100666. private _sceneRenderObserver;
  100667. private _scene;
  100668. private _targetPosition;
  100669. private _virtualOriginMesh;
  100670. private _virtualDragMesh;
  100671. private _pointerObserver;
  100672. private _moving;
  100673. private _startingOrientation;
  100674. /**
  100675. * 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)
  100676. */
  100677. private zDragFactor;
  100678. /**
  100679. * If the object should rotate to face the drag origin
  100680. */
  100681. rotateDraggedObject: boolean;
  100682. /**
  100683. * If the behavior is currently in a dragging state
  100684. */
  100685. dragging: boolean;
  100686. /**
  100687. * 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)
  100688. */
  100689. dragDeltaRatio: number;
  100690. /**
  100691. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100692. */
  100693. currentDraggingPointerID: number;
  100694. /**
  100695. * If camera controls should be detached during the drag
  100696. */
  100697. detachCameraControls: boolean;
  100698. /**
  100699. * Fires each time a drag starts
  100700. */
  100701. onDragStartObservable: Observable<{}>;
  100702. /**
  100703. * Fires each time a drag ends (eg. mouse release after drag)
  100704. */
  100705. onDragEndObservable: Observable<{}>;
  100706. /**
  100707. * 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
  100708. */
  100709. constructor();
  100710. /**
  100711. * The name of the behavior
  100712. */
  100713. readonly name: string;
  100714. /**
  100715. * Initializes the behavior
  100716. */
  100717. init(): void;
  100718. /**
  100719. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100720. */
  100721. private readonly _pointerCamera;
  100722. /**
  100723. * Attaches the scale behavior the passed in mesh
  100724. * @param ownerNode The mesh that will be scaled around once attached
  100725. */
  100726. attach(ownerNode: Mesh): void;
  100727. /**
  100728. * Detaches the behavior from the mesh
  100729. */
  100730. detach(): void;
  100731. }
  100732. }
  100733. declare module BABYLON {
  100734. /**
  100735. * Class used to apply inverse kinematics to bones
  100736. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100737. */
  100738. export class BoneIKController {
  100739. private static _tmpVecs;
  100740. private static _tmpQuat;
  100741. private static _tmpMats;
  100742. /**
  100743. * Gets or sets the target mesh
  100744. */
  100745. targetMesh: AbstractMesh;
  100746. /** Gets or sets the mesh used as pole */
  100747. poleTargetMesh: AbstractMesh;
  100748. /**
  100749. * Gets or sets the bone used as pole
  100750. */
  100751. poleTargetBone: Nullable<Bone>;
  100752. /**
  100753. * Gets or sets the target position
  100754. */
  100755. targetPosition: Vector3;
  100756. /**
  100757. * Gets or sets the pole target position
  100758. */
  100759. poleTargetPosition: Vector3;
  100760. /**
  100761. * Gets or sets the pole target local offset
  100762. */
  100763. poleTargetLocalOffset: Vector3;
  100764. /**
  100765. * Gets or sets the pole angle
  100766. */
  100767. poleAngle: number;
  100768. /**
  100769. * Gets or sets the mesh associated with the controller
  100770. */
  100771. mesh: AbstractMesh;
  100772. /**
  100773. * 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)
  100774. */
  100775. slerpAmount: number;
  100776. private _bone1Quat;
  100777. private _bone1Mat;
  100778. private _bone2Ang;
  100779. private _bone1;
  100780. private _bone2;
  100781. private _bone1Length;
  100782. private _bone2Length;
  100783. private _maxAngle;
  100784. private _maxReach;
  100785. private _rightHandedSystem;
  100786. private _bendAxis;
  100787. private _slerping;
  100788. private _adjustRoll;
  100789. /**
  100790. * Gets or sets maximum allowed angle
  100791. */
  100792. maxAngle: number;
  100793. /**
  100794. * Creates a new BoneIKController
  100795. * @param mesh defines the mesh to control
  100796. * @param bone defines the bone to control
  100797. * @param options defines options to set up the controller
  100798. */
  100799. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  100800. targetMesh?: AbstractMesh;
  100801. poleTargetMesh?: AbstractMesh;
  100802. poleTargetBone?: Bone;
  100803. poleTargetLocalOffset?: Vector3;
  100804. poleAngle?: number;
  100805. bendAxis?: Vector3;
  100806. maxAngle?: number;
  100807. slerpAmount?: number;
  100808. });
  100809. private _setMaxAngle;
  100810. /**
  100811. * Force the controller to update the bones
  100812. */
  100813. update(): void;
  100814. }
  100815. }
  100816. declare module BABYLON {
  100817. /**
  100818. * Class used to make a bone look toward a point in space
  100819. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  100820. */
  100821. export class BoneLookController {
  100822. private static _tmpVecs;
  100823. private static _tmpQuat;
  100824. private static _tmpMats;
  100825. /**
  100826. * The target Vector3 that the bone will look at
  100827. */
  100828. target: Vector3;
  100829. /**
  100830. * The mesh that the bone is attached to
  100831. */
  100832. mesh: AbstractMesh;
  100833. /**
  100834. * The bone that will be looking to the target
  100835. */
  100836. bone: Bone;
  100837. /**
  100838. * The up axis of the coordinate system that is used when the bone is rotated
  100839. */
  100840. upAxis: Vector3;
  100841. /**
  100842. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  100843. */
  100844. upAxisSpace: Space;
  100845. /**
  100846. * Used to make an adjustment to the yaw of the bone
  100847. */
  100848. adjustYaw: number;
  100849. /**
  100850. * Used to make an adjustment to the pitch of the bone
  100851. */
  100852. adjustPitch: number;
  100853. /**
  100854. * Used to make an adjustment to the roll of the bone
  100855. */
  100856. adjustRoll: number;
  100857. /**
  100858. * 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)
  100859. */
  100860. slerpAmount: number;
  100861. private _minYaw;
  100862. private _maxYaw;
  100863. private _minPitch;
  100864. private _maxPitch;
  100865. private _minYawSin;
  100866. private _minYawCos;
  100867. private _maxYawSin;
  100868. private _maxYawCos;
  100869. private _midYawConstraint;
  100870. private _minPitchTan;
  100871. private _maxPitchTan;
  100872. private _boneQuat;
  100873. private _slerping;
  100874. private _transformYawPitch;
  100875. private _transformYawPitchInv;
  100876. private _firstFrameSkipped;
  100877. private _yawRange;
  100878. private _fowardAxis;
  100879. /**
  100880. * Gets or sets the minimum yaw angle that the bone can look to
  100881. */
  100882. minYaw: number;
  100883. /**
  100884. * Gets or sets the maximum yaw angle that the bone can look to
  100885. */
  100886. maxYaw: number;
  100887. /**
  100888. * Gets or sets the minimum pitch angle that the bone can look to
  100889. */
  100890. minPitch: number;
  100891. /**
  100892. * Gets or sets the maximum pitch angle that the bone can look to
  100893. */
  100894. maxPitch: number;
  100895. /**
  100896. * Create a BoneLookController
  100897. * @param mesh the mesh that the bone belongs to
  100898. * @param bone the bone that will be looking to the target
  100899. * @param target the target Vector3 to look at
  100900. * @param options optional settings:
  100901. * * maxYaw: the maximum angle the bone will yaw to
  100902. * * minYaw: the minimum angle the bone will yaw to
  100903. * * maxPitch: the maximum angle the bone will pitch to
  100904. * * minPitch: the minimum angle the bone will yaw to
  100905. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100906. * * upAxis: the up axis of the coordinate system
  100907. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100908. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100909. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100910. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100911. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100912. * * adjustRoll: used to make an adjustment to the roll of the bone
  100913. **/
  100914. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100915. maxYaw?: number;
  100916. minYaw?: number;
  100917. maxPitch?: number;
  100918. minPitch?: number;
  100919. slerpAmount?: number;
  100920. upAxis?: Vector3;
  100921. upAxisSpace?: Space;
  100922. yawAxis?: Vector3;
  100923. pitchAxis?: Vector3;
  100924. adjustYaw?: number;
  100925. adjustPitch?: number;
  100926. adjustRoll?: number;
  100927. });
  100928. /**
  100929. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100930. */
  100931. update(): void;
  100932. private _getAngleDiff;
  100933. private _getAngleBetween;
  100934. private _isAngleBetween;
  100935. }
  100936. }
  100937. declare module BABYLON {
  100938. /**
  100939. * Manage the gamepad inputs to control an arc rotate camera.
  100940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100941. */
  100942. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100943. /**
  100944. * Defines the camera the input is attached to.
  100945. */
  100946. camera: ArcRotateCamera;
  100947. /**
  100948. * Defines the gamepad the input is gathering event from.
  100949. */
  100950. gamepad: Nullable<Gamepad>;
  100951. /**
  100952. * Defines the gamepad rotation sensiblity.
  100953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100954. */
  100955. gamepadRotationSensibility: number;
  100956. /**
  100957. * Defines the gamepad move sensiblity.
  100958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100959. */
  100960. gamepadMoveSensibility: number;
  100961. private _onGamepadConnectedObserver;
  100962. private _onGamepadDisconnectedObserver;
  100963. /**
  100964. * Attach the input controls to a specific dom element to get the input from.
  100965. * @param element Defines the element the controls should be listened from
  100966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100967. */
  100968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100969. /**
  100970. * Detach the current controls from the specified dom element.
  100971. * @param element Defines the element to stop listening the inputs from
  100972. */
  100973. detachControl(element: Nullable<HTMLElement>): void;
  100974. /**
  100975. * Update the current camera state depending on the inputs that have been used this frame.
  100976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100977. */
  100978. checkInputs(): void;
  100979. /**
  100980. * Gets the class name of the current intput.
  100981. * @returns the class name
  100982. */
  100983. getClassName(): string;
  100984. /**
  100985. * Get the friendly name associated with the input class.
  100986. * @returns the input friendly name
  100987. */
  100988. getSimpleName(): string;
  100989. }
  100990. }
  100991. declare module BABYLON {
  100992. interface ArcRotateCameraInputsManager {
  100993. /**
  100994. * Add orientation input support to the input manager.
  100995. * @returns the current input manager
  100996. */
  100997. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100998. }
  100999. /**
  101000. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101002. */
  101003. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101004. /**
  101005. * Defines the camera the input is attached to.
  101006. */
  101007. camera: ArcRotateCamera;
  101008. /**
  101009. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101010. */
  101011. alphaCorrection: number;
  101012. /**
  101013. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101014. */
  101015. gammaCorrection: number;
  101016. private _alpha;
  101017. private _gamma;
  101018. private _dirty;
  101019. private _deviceOrientationHandler;
  101020. /**
  101021. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101022. */
  101023. constructor();
  101024. /**
  101025. * Attach the input controls to a specific dom element to get the input from.
  101026. * @param element Defines the element the controls should be listened from
  101027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101028. */
  101029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101030. /** @hidden */
  101031. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101032. /**
  101033. * Update the current camera state depending on the inputs that have been used this frame.
  101034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101035. */
  101036. checkInputs(): void;
  101037. /**
  101038. * Detach the current controls from the specified dom element.
  101039. * @param element Defines the element to stop listening the inputs from
  101040. */
  101041. detachControl(element: Nullable<HTMLElement>): void;
  101042. /**
  101043. * Gets the class name of the current intput.
  101044. * @returns the class name
  101045. */
  101046. getClassName(): string;
  101047. /**
  101048. * Get the friendly name associated with the input class.
  101049. * @returns the input friendly name
  101050. */
  101051. getSimpleName(): string;
  101052. }
  101053. }
  101054. declare module BABYLON {
  101055. /**
  101056. * Listen to mouse events to control the camera.
  101057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101058. */
  101059. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101060. /**
  101061. * Defines the camera the input is attached to.
  101062. */
  101063. camera: FlyCamera;
  101064. /**
  101065. * Defines if touch is enabled. (Default is true.)
  101066. */
  101067. touchEnabled: boolean;
  101068. /**
  101069. * Defines the buttons associated with the input to handle camera rotation.
  101070. */
  101071. buttons: number[];
  101072. /**
  101073. * Assign buttons for Yaw control.
  101074. */
  101075. buttonsYaw: number[];
  101076. /**
  101077. * Assign buttons for Pitch control.
  101078. */
  101079. buttonsPitch: number[];
  101080. /**
  101081. * Assign buttons for Roll control.
  101082. */
  101083. buttonsRoll: number[];
  101084. /**
  101085. * Detect if any button is being pressed while mouse is moved.
  101086. * -1 = Mouse locked.
  101087. * 0 = Left button.
  101088. * 1 = Middle Button.
  101089. * 2 = Right Button.
  101090. */
  101091. activeButton: number;
  101092. /**
  101093. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101094. * Higher values reduce its sensitivity.
  101095. */
  101096. angularSensibility: number;
  101097. private _mousemoveCallback;
  101098. private _observer;
  101099. private _rollObserver;
  101100. private previousPosition;
  101101. private noPreventDefault;
  101102. private element;
  101103. /**
  101104. * Listen to mouse events to control the camera.
  101105. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101107. */
  101108. constructor(touchEnabled?: boolean);
  101109. /**
  101110. * Attach the mouse control to the HTML DOM element.
  101111. * @param element Defines the element that listens to the input events.
  101112. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101113. */
  101114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101115. /**
  101116. * Detach the current controls from the specified dom element.
  101117. * @param element Defines the element to stop listening the inputs from
  101118. */
  101119. detachControl(element: Nullable<HTMLElement>): void;
  101120. /**
  101121. * Gets the class name of the current input.
  101122. * @returns the class name.
  101123. */
  101124. getClassName(): string;
  101125. /**
  101126. * Get the friendly name associated with the input class.
  101127. * @returns the input's friendly name.
  101128. */
  101129. getSimpleName(): string;
  101130. private _pointerInput;
  101131. private _onMouseMove;
  101132. /**
  101133. * Rotate camera by mouse offset.
  101134. */
  101135. private rotateCamera;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * Default Inputs manager for the FlyCamera.
  101141. * It groups all the default supported inputs for ease of use.
  101142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101143. */
  101144. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101145. /**
  101146. * Instantiates a new FlyCameraInputsManager.
  101147. * @param camera Defines the camera the inputs belong to.
  101148. */
  101149. constructor(camera: FlyCamera);
  101150. /**
  101151. * Add keyboard input support to the input manager.
  101152. * @returns the new FlyCameraKeyboardMoveInput().
  101153. */
  101154. addKeyboard(): FlyCameraInputsManager;
  101155. /**
  101156. * Add mouse input support to the input manager.
  101157. * @param touchEnabled Enable touch screen support.
  101158. * @returns the new FlyCameraMouseInput().
  101159. */
  101160. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101161. }
  101162. }
  101163. declare module BABYLON {
  101164. /**
  101165. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101166. * such as in a 3D Space Shooter or a Flight Simulator.
  101167. */
  101168. export class FlyCamera extends TargetCamera {
  101169. /**
  101170. * Define the collision ellipsoid of the camera.
  101171. * This is helpful for simulating a camera body, like a player's body.
  101172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101173. */
  101174. ellipsoid: Vector3;
  101175. /**
  101176. * Define an offset for the position of the ellipsoid around the camera.
  101177. * This can be helpful if the camera is attached away from the player's body center,
  101178. * such as at its head.
  101179. */
  101180. ellipsoidOffset: Vector3;
  101181. /**
  101182. * Enable or disable collisions of the camera with the rest of the scene objects.
  101183. */
  101184. checkCollisions: boolean;
  101185. /**
  101186. * Enable or disable gravity on the camera.
  101187. */
  101188. applyGravity: boolean;
  101189. /**
  101190. * Define the current direction the camera is moving to.
  101191. */
  101192. cameraDirection: Vector3;
  101193. /**
  101194. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101195. * This overrides and empties cameraRotation.
  101196. */
  101197. rotationQuaternion: Quaternion;
  101198. /**
  101199. * Track Roll to maintain the wanted Rolling when looking around.
  101200. */
  101201. _trackRoll: number;
  101202. /**
  101203. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101204. */
  101205. rollCorrect: number;
  101206. /**
  101207. * Mimic a banked turn, Rolling the camera when Yawing.
  101208. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101209. */
  101210. bankedTurn: boolean;
  101211. /**
  101212. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101213. */
  101214. bankedTurnLimit: number;
  101215. /**
  101216. * Value of 0 disables the banked Roll.
  101217. * Value of 1 is equal to the Yaw angle in radians.
  101218. */
  101219. bankedTurnMultiplier: number;
  101220. /**
  101221. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101222. */
  101223. inputs: FlyCameraInputsManager;
  101224. /**
  101225. * Gets the input sensibility for mouse input.
  101226. * Higher values reduce sensitivity.
  101227. */
  101228. /**
  101229. * Sets the input sensibility for a mouse input.
  101230. * Higher values reduce sensitivity.
  101231. */
  101232. angularSensibility: number;
  101233. /**
  101234. * Get the keys for camera movement forward.
  101235. */
  101236. /**
  101237. * Set the keys for camera movement forward.
  101238. */
  101239. keysForward: number[];
  101240. /**
  101241. * Get the keys for camera movement backward.
  101242. */
  101243. keysBackward: number[];
  101244. /**
  101245. * Get the keys for camera movement up.
  101246. */
  101247. /**
  101248. * Set the keys for camera movement up.
  101249. */
  101250. keysUp: number[];
  101251. /**
  101252. * Get the keys for camera movement down.
  101253. */
  101254. /**
  101255. * Set the keys for camera movement down.
  101256. */
  101257. keysDown: number[];
  101258. /**
  101259. * Get the keys for camera movement left.
  101260. */
  101261. /**
  101262. * Set the keys for camera movement left.
  101263. */
  101264. keysLeft: number[];
  101265. /**
  101266. * Set the keys for camera movement right.
  101267. */
  101268. /**
  101269. * Set the keys for camera movement right.
  101270. */
  101271. keysRight: number[];
  101272. /**
  101273. * Event raised when the camera collides with a mesh in the scene.
  101274. */
  101275. onCollide: (collidedMesh: AbstractMesh) => void;
  101276. private _collider;
  101277. private _needMoveForGravity;
  101278. private _oldPosition;
  101279. private _diffPosition;
  101280. private _newPosition;
  101281. /** @hidden */
  101282. _localDirection: Vector3;
  101283. /** @hidden */
  101284. _transformedDirection: Vector3;
  101285. /**
  101286. * Instantiates a FlyCamera.
  101287. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101288. * such as in a 3D Space Shooter or a Flight Simulator.
  101289. * @param name Define the name of the camera in the scene.
  101290. * @param position Define the starting position of the camera in the scene.
  101291. * @param scene Define the scene the camera belongs to.
  101292. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101293. */
  101294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101295. /**
  101296. * Attach a control to the HTML DOM element.
  101297. * @param element Defines the element that listens to the input events.
  101298. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101299. */
  101300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101301. /**
  101302. * Detach a control from the HTML DOM element.
  101303. * The camera will stop reacting to that input.
  101304. * @param element Defines the element that listens to the input events.
  101305. */
  101306. detachControl(element: HTMLElement): void;
  101307. private _collisionMask;
  101308. /**
  101309. * Get the mask that the camera ignores in collision events.
  101310. */
  101311. /**
  101312. * Set the mask that the camera ignores in collision events.
  101313. */
  101314. collisionMask: number;
  101315. /** @hidden */
  101316. _collideWithWorld(displacement: Vector3): void;
  101317. /** @hidden */
  101318. private _onCollisionPositionChange;
  101319. /** @hidden */
  101320. _checkInputs(): void;
  101321. /** @hidden */
  101322. _decideIfNeedsToMove(): boolean;
  101323. /** @hidden */
  101324. _updatePosition(): void;
  101325. /**
  101326. * Restore the Roll to its target value at the rate specified.
  101327. * @param rate - Higher means slower restoring.
  101328. * @hidden
  101329. */
  101330. restoreRoll(rate: number): void;
  101331. /**
  101332. * Destroy the camera and release the current resources held by it.
  101333. */
  101334. dispose(): void;
  101335. /**
  101336. * Get the current object class name.
  101337. * @returns the class name.
  101338. */
  101339. getClassName(): string;
  101340. }
  101341. }
  101342. declare module BABYLON {
  101343. /**
  101344. * Listen to keyboard events to control the camera.
  101345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101346. */
  101347. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101348. /**
  101349. * Defines the camera the input is attached to.
  101350. */
  101351. camera: FlyCamera;
  101352. /**
  101353. * The list of keyboard keys used to control the forward move of the camera.
  101354. */
  101355. keysForward: number[];
  101356. /**
  101357. * The list of keyboard keys used to control the backward move of the camera.
  101358. */
  101359. keysBackward: number[];
  101360. /**
  101361. * The list of keyboard keys used to control the forward move of the camera.
  101362. */
  101363. keysUp: number[];
  101364. /**
  101365. * The list of keyboard keys used to control the backward move of the camera.
  101366. */
  101367. keysDown: number[];
  101368. /**
  101369. * The list of keyboard keys used to control the right strafe move of the camera.
  101370. */
  101371. keysRight: number[];
  101372. /**
  101373. * The list of keyboard keys used to control the left strafe move of the camera.
  101374. */
  101375. keysLeft: number[];
  101376. private _keys;
  101377. private _onCanvasBlurObserver;
  101378. private _onKeyboardObserver;
  101379. private _engine;
  101380. private _scene;
  101381. /**
  101382. * Attach the input controls to a specific dom element to get the input from.
  101383. * @param element Defines the element the controls should be listened from
  101384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101385. */
  101386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101387. /**
  101388. * Detach the current controls from the specified dom element.
  101389. * @param element Defines the element to stop listening the inputs from
  101390. */
  101391. detachControl(element: Nullable<HTMLElement>): void;
  101392. /**
  101393. * Gets the class name of the current intput.
  101394. * @returns the class name
  101395. */
  101396. getClassName(): string;
  101397. /** @hidden */
  101398. _onLostFocus(e: FocusEvent): void;
  101399. /**
  101400. * Get the friendly name associated with the input class.
  101401. * @returns the input friendly name
  101402. */
  101403. getSimpleName(): string;
  101404. /**
  101405. * Update the current camera state depending on the inputs that have been used this frame.
  101406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101407. */
  101408. checkInputs(): void;
  101409. }
  101410. }
  101411. declare module BABYLON {
  101412. /**
  101413. * Manage the mouse wheel inputs to control a follow camera.
  101414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101415. */
  101416. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101417. /**
  101418. * Defines the camera the input is attached to.
  101419. */
  101420. camera: FollowCamera;
  101421. /**
  101422. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101423. */
  101424. axisControlRadius: boolean;
  101425. /**
  101426. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101427. */
  101428. axisControlHeight: boolean;
  101429. /**
  101430. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101431. */
  101432. axisControlRotation: boolean;
  101433. /**
  101434. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101435. * relation to mouseWheel events.
  101436. */
  101437. wheelPrecision: number;
  101438. /**
  101439. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101440. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101441. */
  101442. wheelDeltaPercentage: number;
  101443. private _wheel;
  101444. private _observer;
  101445. /**
  101446. * Attach the input controls to a specific dom element to get the input from.
  101447. * @param element Defines the element the controls should be listened from
  101448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101449. */
  101450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101451. /**
  101452. * Detach the current controls from the specified dom element.
  101453. * @param element Defines the element to stop listening the inputs from
  101454. */
  101455. detachControl(element: Nullable<HTMLElement>): void;
  101456. /**
  101457. * Gets the class name of the current intput.
  101458. * @returns the class name
  101459. */
  101460. getClassName(): string;
  101461. /**
  101462. * Get the friendly name associated with the input class.
  101463. * @returns the input friendly name
  101464. */
  101465. getSimpleName(): string;
  101466. }
  101467. }
  101468. declare module BABYLON {
  101469. /**
  101470. * Manage the pointers inputs to control an follow camera.
  101471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101472. */
  101473. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101474. /**
  101475. * Defines the camera the input is attached to.
  101476. */
  101477. camera: FollowCamera;
  101478. /**
  101479. * Gets the class name of the current input.
  101480. * @returns the class name
  101481. */
  101482. getClassName(): string;
  101483. /**
  101484. * Defines the pointer angular sensibility along the X axis or how fast is
  101485. * the camera rotating.
  101486. * A negative number will reverse the axis direction.
  101487. */
  101488. angularSensibilityX: number;
  101489. /**
  101490. * Defines the pointer angular sensibility along the Y axis or how fast is
  101491. * the camera rotating.
  101492. * A negative number will reverse the axis direction.
  101493. */
  101494. angularSensibilityY: number;
  101495. /**
  101496. * Defines the pointer pinch precision or how fast is the camera zooming.
  101497. * A negative number will reverse the axis direction.
  101498. */
  101499. pinchPrecision: number;
  101500. /**
  101501. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101502. * from 0.
  101503. * It defines the percentage of current camera.radius to use as delta when
  101504. * pinch zoom is used.
  101505. */
  101506. pinchDeltaPercentage: number;
  101507. /**
  101508. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101509. */
  101510. axisXControlRadius: boolean;
  101511. /**
  101512. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101513. */
  101514. axisXControlHeight: boolean;
  101515. /**
  101516. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101517. */
  101518. axisXControlRotation: boolean;
  101519. /**
  101520. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101521. */
  101522. axisYControlRadius: boolean;
  101523. /**
  101524. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101525. */
  101526. axisYControlHeight: boolean;
  101527. /**
  101528. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101529. */
  101530. axisYControlRotation: boolean;
  101531. /**
  101532. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101533. */
  101534. axisPinchControlRadius: boolean;
  101535. /**
  101536. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101537. */
  101538. axisPinchControlHeight: boolean;
  101539. /**
  101540. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101541. */
  101542. axisPinchControlRotation: boolean;
  101543. /**
  101544. * Log error messages if basic misconfiguration has occurred.
  101545. */
  101546. warningEnable: boolean;
  101547. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101548. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101549. private _warningCounter;
  101550. private _warning;
  101551. }
  101552. }
  101553. declare module BABYLON {
  101554. /**
  101555. * Default Inputs manager for the FollowCamera.
  101556. * It groups all the default supported inputs for ease of use.
  101557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101558. */
  101559. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101560. /**
  101561. * Instantiates a new FollowCameraInputsManager.
  101562. * @param camera Defines the camera the inputs belong to
  101563. */
  101564. constructor(camera: FollowCamera);
  101565. /**
  101566. * Add keyboard input support to the input manager.
  101567. * @returns the current input manager
  101568. */
  101569. addKeyboard(): FollowCameraInputsManager;
  101570. /**
  101571. * Add mouse wheel input support to the input manager.
  101572. * @returns the current input manager
  101573. */
  101574. addMouseWheel(): FollowCameraInputsManager;
  101575. /**
  101576. * Add pointers input support to the input manager.
  101577. * @returns the current input manager
  101578. */
  101579. addPointers(): FollowCameraInputsManager;
  101580. /**
  101581. * Add orientation input support to the input manager.
  101582. * @returns the current input manager
  101583. */
  101584. addVRDeviceOrientation(): FollowCameraInputsManager;
  101585. }
  101586. }
  101587. declare module BABYLON {
  101588. /**
  101589. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101590. * an arc rotate version arcFollowCamera are available.
  101591. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101592. */
  101593. export class FollowCamera extends TargetCamera {
  101594. /**
  101595. * Distance the follow camera should follow an object at
  101596. */
  101597. radius: number;
  101598. /**
  101599. * Minimum allowed distance of the camera to the axis of rotation
  101600. * (The camera can not get closer).
  101601. * This can help limiting how the Camera is able to move in the scene.
  101602. */
  101603. lowerRadiusLimit: Nullable<number>;
  101604. /**
  101605. * Maximum allowed distance of the camera to the axis of rotation
  101606. * (The camera can not get further).
  101607. * This can help limiting how the Camera is able to move in the scene.
  101608. */
  101609. upperRadiusLimit: Nullable<number>;
  101610. /**
  101611. * Define a rotation offset between the camera and the object it follows
  101612. */
  101613. rotationOffset: number;
  101614. /**
  101615. * Minimum allowed angle to camera position relative to target object.
  101616. * This can help limiting how the Camera is able to move in the scene.
  101617. */
  101618. lowerRotationOffsetLimit: Nullable<number>;
  101619. /**
  101620. * Maximum allowed angle to camera position relative to target object.
  101621. * This can help limiting how the Camera is able to move in the scene.
  101622. */
  101623. upperRotationOffsetLimit: Nullable<number>;
  101624. /**
  101625. * Define a height offset between the camera and the object it follows.
  101626. * It can help following an object from the top (like a car chaing a plane)
  101627. */
  101628. heightOffset: number;
  101629. /**
  101630. * Minimum allowed height of camera position relative to target object.
  101631. * This can help limiting how the Camera is able to move in the scene.
  101632. */
  101633. lowerHeightOffsetLimit: Nullable<number>;
  101634. /**
  101635. * Maximum allowed height of camera position relative to target object.
  101636. * This can help limiting how the Camera is able to move in the scene.
  101637. */
  101638. upperHeightOffsetLimit: Nullable<number>;
  101639. /**
  101640. * Define how fast the camera can accelerate to follow it s target.
  101641. */
  101642. cameraAcceleration: number;
  101643. /**
  101644. * Define the speed limit of the camera following an object.
  101645. */
  101646. maxCameraSpeed: number;
  101647. /**
  101648. * Define the target of the camera.
  101649. */
  101650. lockedTarget: Nullable<AbstractMesh>;
  101651. /**
  101652. * Defines the input associated with the camera.
  101653. */
  101654. inputs: FollowCameraInputsManager;
  101655. /**
  101656. * Instantiates the follow camera.
  101657. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101658. * @param name Define the name of the camera in the scene
  101659. * @param position Define the position of the camera
  101660. * @param scene Define the scene the camera belong to
  101661. * @param lockedTarget Define the target of the camera
  101662. */
  101663. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101664. private _follow;
  101665. /**
  101666. * Attached controls to the current camera.
  101667. * @param element Defines the element the controls should be listened from
  101668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101669. */
  101670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101671. /**
  101672. * Detach the current controls from the camera.
  101673. * The camera will stop reacting to inputs.
  101674. * @param element Defines the element to stop listening the inputs from
  101675. */
  101676. detachControl(element: HTMLElement): void;
  101677. /** @hidden */
  101678. _checkInputs(): void;
  101679. private _checkLimits;
  101680. /**
  101681. * Gets the camera class name.
  101682. * @returns the class name
  101683. */
  101684. getClassName(): string;
  101685. }
  101686. /**
  101687. * Arc Rotate version of the follow camera.
  101688. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101690. */
  101691. export class ArcFollowCamera extends TargetCamera {
  101692. /** The longitudinal angle of the camera */
  101693. alpha: number;
  101694. /** The latitudinal angle of the camera */
  101695. beta: number;
  101696. /** The radius of the camera from its target */
  101697. radius: number;
  101698. /** Define the camera target (the messh it should follow) */
  101699. target: Nullable<AbstractMesh>;
  101700. private _cartesianCoordinates;
  101701. /**
  101702. * Instantiates a new ArcFollowCamera
  101703. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101704. * @param name Define the name of the camera
  101705. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101706. * @param beta Define the rotation angle of the camera around the elevation axis
  101707. * @param radius Define the radius of the camera from its target point
  101708. * @param target Define the target of the camera
  101709. * @param scene Define the scene the camera belongs to
  101710. */
  101711. constructor(name: string,
  101712. /** The longitudinal angle of the camera */
  101713. alpha: number,
  101714. /** The latitudinal angle of the camera */
  101715. beta: number,
  101716. /** The radius of the camera from its target */
  101717. radius: number,
  101718. /** Define the camera target (the messh it should follow) */
  101719. target: Nullable<AbstractMesh>, scene: Scene);
  101720. private _follow;
  101721. /** @hidden */
  101722. _checkInputs(): void;
  101723. /**
  101724. * Returns the class name of the object.
  101725. * It is mostly used internally for serialization purposes.
  101726. */
  101727. getClassName(): string;
  101728. }
  101729. }
  101730. declare module BABYLON {
  101731. /**
  101732. * Manage the keyboard inputs to control the movement of a follow camera.
  101733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101734. */
  101735. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101736. /**
  101737. * Defines the camera the input is attached to.
  101738. */
  101739. camera: FollowCamera;
  101740. /**
  101741. * Defines the list of key codes associated with the up action (increase heightOffset)
  101742. */
  101743. keysHeightOffsetIncr: number[];
  101744. /**
  101745. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101746. */
  101747. keysHeightOffsetDecr: number[];
  101748. /**
  101749. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101750. */
  101751. keysHeightOffsetModifierAlt: boolean;
  101752. /**
  101753. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101754. */
  101755. keysHeightOffsetModifierCtrl: boolean;
  101756. /**
  101757. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  101758. */
  101759. keysHeightOffsetModifierShift: boolean;
  101760. /**
  101761. * Defines the list of key codes associated with the left action (increase rotationOffset)
  101762. */
  101763. keysRotationOffsetIncr: number[];
  101764. /**
  101765. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  101766. */
  101767. keysRotationOffsetDecr: number[];
  101768. /**
  101769. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  101770. */
  101771. keysRotationOffsetModifierAlt: boolean;
  101772. /**
  101773. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  101774. */
  101775. keysRotationOffsetModifierCtrl: boolean;
  101776. /**
  101777. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  101778. */
  101779. keysRotationOffsetModifierShift: boolean;
  101780. /**
  101781. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  101782. */
  101783. keysRadiusIncr: number[];
  101784. /**
  101785. * Defines the list of key codes associated with the zoom-out action (increase radius)
  101786. */
  101787. keysRadiusDecr: number[];
  101788. /**
  101789. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  101790. */
  101791. keysRadiusModifierAlt: boolean;
  101792. /**
  101793. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  101794. */
  101795. keysRadiusModifierCtrl: boolean;
  101796. /**
  101797. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  101798. */
  101799. keysRadiusModifierShift: boolean;
  101800. /**
  101801. * Defines the rate of change of heightOffset.
  101802. */
  101803. heightSensibility: number;
  101804. /**
  101805. * Defines the rate of change of rotationOffset.
  101806. */
  101807. rotationSensibility: number;
  101808. /**
  101809. * Defines the rate of change of radius.
  101810. */
  101811. radiusSensibility: number;
  101812. private _keys;
  101813. private _ctrlPressed;
  101814. private _altPressed;
  101815. private _shiftPressed;
  101816. private _onCanvasBlurObserver;
  101817. private _onKeyboardObserver;
  101818. private _engine;
  101819. private _scene;
  101820. /**
  101821. * Attach the input controls to a specific dom element to get the input from.
  101822. * @param element Defines the element the controls should be listened from
  101823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101824. */
  101825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101826. /**
  101827. * Detach the current controls from the specified dom element.
  101828. * @param element Defines the element to stop listening the inputs from
  101829. */
  101830. detachControl(element: Nullable<HTMLElement>): void;
  101831. /**
  101832. * Update the current camera state depending on the inputs that have been used this frame.
  101833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101834. */
  101835. checkInputs(): void;
  101836. /**
  101837. * Gets the class name of the current input.
  101838. * @returns the class name
  101839. */
  101840. getClassName(): string;
  101841. /**
  101842. * Get the friendly name associated with the input class.
  101843. * @returns the input friendly name
  101844. */
  101845. getSimpleName(): string;
  101846. /**
  101847. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101848. * allow modification of the heightOffset value.
  101849. */
  101850. private _modifierHeightOffset;
  101851. /**
  101852. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101853. * allow modification of the rotationOffset value.
  101854. */
  101855. private _modifierRotationOffset;
  101856. /**
  101857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101858. * allow modification of the radius value.
  101859. */
  101860. private _modifierRadius;
  101861. }
  101862. }
  101863. declare module BABYLON {
  101864. interface FreeCameraInputsManager {
  101865. /**
  101866. * @hidden
  101867. */
  101868. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  101869. /**
  101870. * Add orientation input support to the input manager.
  101871. * @returns the current input manager
  101872. */
  101873. addDeviceOrientation(): FreeCameraInputsManager;
  101874. }
  101875. /**
  101876. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  101877. * Screen rotation is taken into account.
  101878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101879. */
  101880. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  101881. private _camera;
  101882. private _screenOrientationAngle;
  101883. private _constantTranform;
  101884. private _screenQuaternion;
  101885. private _alpha;
  101886. private _beta;
  101887. private _gamma;
  101888. /**
  101889. * Can be used to detect if a device orientation sensor is availible on a device
  101890. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  101891. * @returns a promise that will resolve on orientation change
  101892. */
  101893. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  101894. /**
  101895. * @hidden
  101896. */
  101897. _onDeviceOrientationChangedObservable: Observable<void>;
  101898. /**
  101899. * Instantiates a new input
  101900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101901. */
  101902. constructor();
  101903. /**
  101904. * Define the camera controlled by the input.
  101905. */
  101906. camera: FreeCamera;
  101907. /**
  101908. * Attach the input controls to a specific dom element to get the input from.
  101909. * @param element Defines the element the controls should be listened from
  101910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101911. */
  101912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101913. private _orientationChanged;
  101914. private _deviceOrientation;
  101915. /**
  101916. * Detach the current controls from the specified dom element.
  101917. * @param element Defines the element to stop listening the inputs from
  101918. */
  101919. detachControl(element: Nullable<HTMLElement>): void;
  101920. /**
  101921. * Update the current camera state depending on the inputs that have been used this frame.
  101922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101923. */
  101924. checkInputs(): void;
  101925. /**
  101926. * Gets the class name of the current intput.
  101927. * @returns the class name
  101928. */
  101929. getClassName(): string;
  101930. /**
  101931. * Get the friendly name associated with the input class.
  101932. * @returns the input friendly name
  101933. */
  101934. getSimpleName(): string;
  101935. }
  101936. }
  101937. declare module BABYLON {
  101938. /**
  101939. * Manage the gamepad inputs to control a free camera.
  101940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101941. */
  101942. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101943. /**
  101944. * Define the camera the input is attached to.
  101945. */
  101946. camera: FreeCamera;
  101947. /**
  101948. * Define the Gamepad controlling the input
  101949. */
  101950. gamepad: Nullable<Gamepad>;
  101951. /**
  101952. * Defines the gamepad rotation sensiblity.
  101953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101954. */
  101955. gamepadAngularSensibility: number;
  101956. /**
  101957. * Defines the gamepad move sensiblity.
  101958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101959. */
  101960. gamepadMoveSensibility: number;
  101961. private _onGamepadConnectedObserver;
  101962. private _onGamepadDisconnectedObserver;
  101963. private _cameraTransform;
  101964. private _deltaTransform;
  101965. private _vector3;
  101966. private _vector2;
  101967. /**
  101968. * Attach the input controls to a specific dom element to get the input from.
  101969. * @param element Defines the element the controls should be listened from
  101970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101971. */
  101972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101973. /**
  101974. * Detach the current controls from the specified dom element.
  101975. * @param element Defines the element to stop listening the inputs from
  101976. */
  101977. detachControl(element: Nullable<HTMLElement>): void;
  101978. /**
  101979. * Update the current camera state depending on the inputs that have been used this frame.
  101980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101981. */
  101982. checkInputs(): void;
  101983. /**
  101984. * Gets the class name of the current intput.
  101985. * @returns the class name
  101986. */
  101987. getClassName(): string;
  101988. /**
  101989. * Get the friendly name associated with the input class.
  101990. * @returns the input friendly name
  101991. */
  101992. getSimpleName(): string;
  101993. }
  101994. }
  101995. declare module BABYLON {
  101996. /**
  101997. * Defines the potential axis of a Joystick
  101998. */
  101999. export enum JoystickAxis {
  102000. /** X axis */
  102001. X = 0,
  102002. /** Y axis */
  102003. Y = 1,
  102004. /** Z axis */
  102005. Z = 2
  102006. }
  102007. /**
  102008. * Class used to define virtual joystick (used in touch mode)
  102009. */
  102010. export class VirtualJoystick {
  102011. /**
  102012. * Gets or sets a boolean indicating that left and right values must be inverted
  102013. */
  102014. reverseLeftRight: boolean;
  102015. /**
  102016. * Gets or sets a boolean indicating that up and down values must be inverted
  102017. */
  102018. reverseUpDown: boolean;
  102019. /**
  102020. * Gets the offset value for the position (ie. the change of the position value)
  102021. */
  102022. deltaPosition: Vector3;
  102023. /**
  102024. * Gets a boolean indicating if the virtual joystick was pressed
  102025. */
  102026. pressed: boolean;
  102027. /**
  102028. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102029. */
  102030. static Canvas: Nullable<HTMLCanvasElement>;
  102031. private static _globalJoystickIndex;
  102032. private static vjCanvasContext;
  102033. private static vjCanvasWidth;
  102034. private static vjCanvasHeight;
  102035. private static halfWidth;
  102036. private _action;
  102037. private _axisTargetedByLeftAndRight;
  102038. private _axisTargetedByUpAndDown;
  102039. private _joystickSensibility;
  102040. private _inversedSensibility;
  102041. private _joystickPointerID;
  102042. private _joystickColor;
  102043. private _joystickPointerPos;
  102044. private _joystickPreviousPointerPos;
  102045. private _joystickPointerStartPos;
  102046. private _deltaJoystickVector;
  102047. private _leftJoystick;
  102048. private _touches;
  102049. private _onPointerDownHandlerRef;
  102050. private _onPointerMoveHandlerRef;
  102051. private _onPointerUpHandlerRef;
  102052. private _onResize;
  102053. /**
  102054. * Creates a new virtual joystick
  102055. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102056. */
  102057. constructor(leftJoystick?: boolean);
  102058. /**
  102059. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102060. * @param newJoystickSensibility defines the new sensibility
  102061. */
  102062. setJoystickSensibility(newJoystickSensibility: number): void;
  102063. private _onPointerDown;
  102064. private _onPointerMove;
  102065. private _onPointerUp;
  102066. /**
  102067. * Change the color of the virtual joystick
  102068. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102069. */
  102070. setJoystickColor(newColor: string): void;
  102071. /**
  102072. * Defines a callback to call when the joystick is touched
  102073. * @param action defines the callback
  102074. */
  102075. setActionOnTouch(action: () => any): void;
  102076. /**
  102077. * Defines which axis you'd like to control for left & right
  102078. * @param axis defines the axis to use
  102079. */
  102080. setAxisForLeftRight(axis: JoystickAxis): void;
  102081. /**
  102082. * Defines which axis you'd like to control for up & down
  102083. * @param axis defines the axis to use
  102084. */
  102085. setAxisForUpDown(axis: JoystickAxis): void;
  102086. private _drawVirtualJoystick;
  102087. /**
  102088. * Release internal HTML canvas
  102089. */
  102090. releaseCanvas(): void;
  102091. }
  102092. }
  102093. declare module BABYLON {
  102094. interface FreeCameraInputsManager {
  102095. /**
  102096. * Add virtual joystick input support to the input manager.
  102097. * @returns the current input manager
  102098. */
  102099. addVirtualJoystick(): FreeCameraInputsManager;
  102100. }
  102101. /**
  102102. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102104. */
  102105. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102106. /**
  102107. * Defines the camera the input is attached to.
  102108. */
  102109. camera: FreeCamera;
  102110. private _leftjoystick;
  102111. private _rightjoystick;
  102112. /**
  102113. * Gets the left stick of the virtual joystick.
  102114. * @returns The virtual Joystick
  102115. */
  102116. getLeftJoystick(): VirtualJoystick;
  102117. /**
  102118. * Gets the right stick of the virtual joystick.
  102119. * @returns The virtual Joystick
  102120. */
  102121. getRightJoystick(): VirtualJoystick;
  102122. /**
  102123. * Update the current camera state depending on the inputs that have been used this frame.
  102124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102125. */
  102126. checkInputs(): void;
  102127. /**
  102128. * Attach the input controls to a specific dom element to get the input from.
  102129. * @param element Defines the element the controls should be listened from
  102130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102131. */
  102132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102133. /**
  102134. * Detach the current controls from the specified dom element.
  102135. * @param element Defines the element to stop listening the inputs from
  102136. */
  102137. detachControl(element: Nullable<HTMLElement>): void;
  102138. /**
  102139. * Gets the class name of the current intput.
  102140. * @returns the class name
  102141. */
  102142. getClassName(): string;
  102143. /**
  102144. * Get the friendly name associated with the input class.
  102145. * @returns the input friendly name
  102146. */
  102147. getSimpleName(): string;
  102148. }
  102149. }
  102150. declare module BABYLON {
  102151. /**
  102152. * This represents a FPS type of camera controlled by touch.
  102153. * This is like a universal camera minus the Gamepad controls.
  102154. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102155. */
  102156. export class TouchCamera extends FreeCamera {
  102157. /**
  102158. * Defines the touch sensibility for rotation.
  102159. * The higher the faster.
  102160. */
  102161. touchAngularSensibility: number;
  102162. /**
  102163. * Defines the touch sensibility for move.
  102164. * The higher the faster.
  102165. */
  102166. touchMoveSensibility: number;
  102167. /**
  102168. * Instantiates a new touch camera.
  102169. * This represents a FPS type of camera controlled by touch.
  102170. * This is like a universal camera minus the Gamepad controls.
  102171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102172. * @param name Define the name of the camera in the scene
  102173. * @param position Define the start position of the camera in the scene
  102174. * @param scene Define the scene the camera belongs to
  102175. */
  102176. constructor(name: string, position: Vector3, scene: Scene);
  102177. /**
  102178. * Gets the current object class name.
  102179. * @return the class name
  102180. */
  102181. getClassName(): string;
  102182. /** @hidden */
  102183. _setupInputs(): void;
  102184. }
  102185. }
  102186. declare module BABYLON {
  102187. /**
  102188. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102189. * being tilted forward or back and left or right.
  102190. */
  102191. export class DeviceOrientationCamera extends FreeCamera {
  102192. private _initialQuaternion;
  102193. private _quaternionCache;
  102194. private _tmpDragQuaternion;
  102195. /**
  102196. * Creates a new device orientation camera
  102197. * @param name The name of the camera
  102198. * @param position The start position camera
  102199. * @param scene The scene the camera belongs to
  102200. */
  102201. constructor(name: string, position: Vector3, scene: Scene);
  102202. /**
  102203. * @hidden
  102204. * Disabled pointer input on first orientation sensor update (Default: true)
  102205. */
  102206. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  102207. private _dragFactor;
  102208. /**
  102209. * Enabled turning on the y axis when the orientation sensor is active
  102210. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102211. */
  102212. enableHorizontalDragging(dragFactor?: number): void;
  102213. /**
  102214. * Gets the current instance class name ("DeviceOrientationCamera").
  102215. * This helps avoiding instanceof at run time.
  102216. * @returns the class name
  102217. */
  102218. getClassName(): string;
  102219. /**
  102220. * @hidden
  102221. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102222. */
  102223. _checkInputs(): void;
  102224. /**
  102225. * Reset the camera to its default orientation on the specified axis only.
  102226. * @param axis The axis to reset
  102227. */
  102228. resetToCurrentRotation(axis?: Axis): void;
  102229. }
  102230. }
  102231. declare module BABYLON {
  102232. /**
  102233. * Defines supported buttons for XBox360 compatible gamepads
  102234. */
  102235. export enum Xbox360Button {
  102236. /** A */
  102237. A = 0,
  102238. /** B */
  102239. B = 1,
  102240. /** X */
  102241. X = 2,
  102242. /** Y */
  102243. Y = 3,
  102244. /** Start */
  102245. Start = 4,
  102246. /** Back */
  102247. Back = 5,
  102248. /** Left button */
  102249. LB = 6,
  102250. /** Right button */
  102251. RB = 7,
  102252. /** Left stick */
  102253. LeftStick = 8,
  102254. /** Right stick */
  102255. RightStick = 9
  102256. }
  102257. /** Defines values for XBox360 DPad */
  102258. export enum Xbox360Dpad {
  102259. /** Up */
  102260. Up = 0,
  102261. /** Down */
  102262. Down = 1,
  102263. /** Left */
  102264. Left = 2,
  102265. /** Right */
  102266. Right = 3
  102267. }
  102268. /**
  102269. * Defines a XBox360 gamepad
  102270. */
  102271. export class Xbox360Pad extends Gamepad {
  102272. private _leftTrigger;
  102273. private _rightTrigger;
  102274. private _onlefttriggerchanged;
  102275. private _onrighttriggerchanged;
  102276. private _onbuttondown;
  102277. private _onbuttonup;
  102278. private _ondpaddown;
  102279. private _ondpadup;
  102280. /** Observable raised when a button is pressed */
  102281. onButtonDownObservable: Observable<Xbox360Button>;
  102282. /** Observable raised when a button is released */
  102283. onButtonUpObservable: Observable<Xbox360Button>;
  102284. /** Observable raised when a pad is pressed */
  102285. onPadDownObservable: Observable<Xbox360Dpad>;
  102286. /** Observable raised when a pad is released */
  102287. onPadUpObservable: Observable<Xbox360Dpad>;
  102288. private _buttonA;
  102289. private _buttonB;
  102290. private _buttonX;
  102291. private _buttonY;
  102292. private _buttonBack;
  102293. private _buttonStart;
  102294. private _buttonLB;
  102295. private _buttonRB;
  102296. private _buttonLeftStick;
  102297. private _buttonRightStick;
  102298. private _dPadUp;
  102299. private _dPadDown;
  102300. private _dPadLeft;
  102301. private _dPadRight;
  102302. private _isXboxOnePad;
  102303. /**
  102304. * Creates a new XBox360 gamepad object
  102305. * @param id defines the id of this gamepad
  102306. * @param index defines its index
  102307. * @param gamepad defines the internal HTML gamepad object
  102308. * @param xboxOne defines if it is a XBox One gamepad
  102309. */
  102310. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102311. /**
  102312. * Defines the callback to call when left trigger is pressed
  102313. * @param callback defines the callback to use
  102314. */
  102315. onlefttriggerchanged(callback: (value: number) => void): void;
  102316. /**
  102317. * Defines the callback to call when right trigger is pressed
  102318. * @param callback defines the callback to use
  102319. */
  102320. onrighttriggerchanged(callback: (value: number) => void): void;
  102321. /**
  102322. * Gets the left trigger value
  102323. */
  102324. /**
  102325. * Sets the left trigger value
  102326. */
  102327. leftTrigger: number;
  102328. /**
  102329. * Gets the right trigger value
  102330. */
  102331. /**
  102332. * Sets the right trigger value
  102333. */
  102334. rightTrigger: number;
  102335. /**
  102336. * Defines the callback to call when a button is pressed
  102337. * @param callback defines the callback to use
  102338. */
  102339. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102340. /**
  102341. * Defines the callback to call when a button is released
  102342. * @param callback defines the callback to use
  102343. */
  102344. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102345. /**
  102346. * Defines the callback to call when a pad is pressed
  102347. * @param callback defines the callback to use
  102348. */
  102349. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102350. /**
  102351. * Defines the callback to call when a pad is released
  102352. * @param callback defines the callback to use
  102353. */
  102354. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102355. private _setButtonValue;
  102356. private _setDPadValue;
  102357. /**
  102358. * Gets the value of the `A` button
  102359. */
  102360. /**
  102361. * Sets the value of the `A` button
  102362. */
  102363. buttonA: number;
  102364. /**
  102365. * Gets the value of the `B` button
  102366. */
  102367. /**
  102368. * Sets the value of the `B` button
  102369. */
  102370. buttonB: number;
  102371. /**
  102372. * Gets the value of the `X` button
  102373. */
  102374. /**
  102375. * Sets the value of the `X` button
  102376. */
  102377. buttonX: number;
  102378. /**
  102379. * Gets the value of the `Y` button
  102380. */
  102381. /**
  102382. * Sets the value of the `Y` button
  102383. */
  102384. buttonY: number;
  102385. /**
  102386. * Gets the value of the `Start` button
  102387. */
  102388. /**
  102389. * Sets the value of the `Start` button
  102390. */
  102391. buttonStart: number;
  102392. /**
  102393. * Gets the value of the `Back` button
  102394. */
  102395. /**
  102396. * Sets the value of the `Back` button
  102397. */
  102398. buttonBack: number;
  102399. /**
  102400. * Gets the value of the `Left` button
  102401. */
  102402. /**
  102403. * Sets the value of the `Left` button
  102404. */
  102405. buttonLB: number;
  102406. /**
  102407. * Gets the value of the `Right` button
  102408. */
  102409. /**
  102410. * Sets the value of the `Right` button
  102411. */
  102412. buttonRB: number;
  102413. /**
  102414. * Gets the value of the Left joystick
  102415. */
  102416. /**
  102417. * Sets the value of the Left joystick
  102418. */
  102419. buttonLeftStick: number;
  102420. /**
  102421. * Gets the value of the Right joystick
  102422. */
  102423. /**
  102424. * Sets the value of the Right joystick
  102425. */
  102426. buttonRightStick: number;
  102427. /**
  102428. * Gets the value of D-pad up
  102429. */
  102430. /**
  102431. * Sets the value of D-pad up
  102432. */
  102433. dPadUp: number;
  102434. /**
  102435. * Gets the value of D-pad down
  102436. */
  102437. /**
  102438. * Sets the value of D-pad down
  102439. */
  102440. dPadDown: number;
  102441. /**
  102442. * Gets the value of D-pad left
  102443. */
  102444. /**
  102445. * Sets the value of D-pad left
  102446. */
  102447. dPadLeft: number;
  102448. /**
  102449. * Gets the value of D-pad right
  102450. */
  102451. /**
  102452. * Sets the value of D-pad right
  102453. */
  102454. dPadRight: number;
  102455. /**
  102456. * Force the gamepad to synchronize with device values
  102457. */
  102458. update(): void;
  102459. /**
  102460. * Disposes the gamepad
  102461. */
  102462. dispose(): void;
  102463. }
  102464. }
  102465. declare module BABYLON {
  102466. /**
  102467. * Manager for handling gamepads
  102468. */
  102469. export class GamepadManager {
  102470. private _scene?;
  102471. private _babylonGamepads;
  102472. private _oneGamepadConnected;
  102473. /** @hidden */
  102474. _isMonitoring: boolean;
  102475. private _gamepadEventSupported;
  102476. private _gamepadSupport;
  102477. /**
  102478. * observable to be triggered when the gamepad controller has been connected
  102479. */
  102480. onGamepadConnectedObservable: Observable<Gamepad>;
  102481. /**
  102482. * observable to be triggered when the gamepad controller has been disconnected
  102483. */
  102484. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102485. private _onGamepadConnectedEvent;
  102486. private _onGamepadDisconnectedEvent;
  102487. /**
  102488. * Initializes the gamepad manager
  102489. * @param _scene BabylonJS scene
  102490. */
  102491. constructor(_scene?: Scene | undefined);
  102492. /**
  102493. * The gamepads in the game pad manager
  102494. */
  102495. readonly gamepads: Gamepad[];
  102496. /**
  102497. * Get the gamepad controllers based on type
  102498. * @param type The type of gamepad controller
  102499. * @returns Nullable gamepad
  102500. */
  102501. getGamepadByType(type?: number): Nullable<Gamepad>;
  102502. /**
  102503. * Disposes the gamepad manager
  102504. */
  102505. dispose(): void;
  102506. private _addNewGamepad;
  102507. private _startMonitoringGamepads;
  102508. private _stopMonitoringGamepads;
  102509. /** @hidden */
  102510. _checkGamepadsStatus(): void;
  102511. private _updateGamepadObjects;
  102512. }
  102513. }
  102514. declare module BABYLON {
  102515. interface Scene {
  102516. /** @hidden */
  102517. _gamepadManager: Nullable<GamepadManager>;
  102518. /**
  102519. * Gets the gamepad manager associated with the scene
  102520. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102521. */
  102522. gamepadManager: GamepadManager;
  102523. }
  102524. /**
  102525. * Interface representing a free camera inputs manager
  102526. */
  102527. interface FreeCameraInputsManager {
  102528. /**
  102529. * Adds gamepad input support to the FreeCameraInputsManager.
  102530. * @returns the FreeCameraInputsManager
  102531. */
  102532. addGamepad(): FreeCameraInputsManager;
  102533. }
  102534. /**
  102535. * Interface representing an arc rotate camera inputs manager
  102536. */
  102537. interface ArcRotateCameraInputsManager {
  102538. /**
  102539. * Adds gamepad input support to the ArcRotateCamera InputManager.
  102540. * @returns the camera inputs manager
  102541. */
  102542. addGamepad(): ArcRotateCameraInputsManager;
  102543. }
  102544. /**
  102545. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  102546. */
  102547. export class GamepadSystemSceneComponent implements ISceneComponent {
  102548. /**
  102549. * The component name helpfull to identify the component in the list of scene components.
  102550. */
  102551. readonly name: string;
  102552. /**
  102553. * The scene the component belongs to.
  102554. */
  102555. scene: Scene;
  102556. /**
  102557. * Creates a new instance of the component for the given scene
  102558. * @param scene Defines the scene to register the component in
  102559. */
  102560. constructor(scene: Scene);
  102561. /**
  102562. * Registers the component in a given scene
  102563. */
  102564. register(): void;
  102565. /**
  102566. * Rebuilds the elements related to this component in case of
  102567. * context lost for instance.
  102568. */
  102569. rebuild(): void;
  102570. /**
  102571. * Disposes the component and the associated ressources
  102572. */
  102573. dispose(): void;
  102574. private _beforeCameraUpdate;
  102575. }
  102576. }
  102577. declare module BABYLON {
  102578. /**
  102579. * 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,
  102580. * which still works and will still be found in many Playgrounds.
  102581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102582. */
  102583. export class UniversalCamera extends TouchCamera {
  102584. /**
  102585. * Defines the gamepad rotation sensiblity.
  102586. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102587. */
  102588. gamepadAngularSensibility: number;
  102589. /**
  102590. * Defines the gamepad move sensiblity.
  102591. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102592. */
  102593. gamepadMoveSensibility: number;
  102594. /**
  102595. * 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,
  102596. * which still works and will still be found in many Playgrounds.
  102597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102598. * @param name Define the name of the camera in the scene
  102599. * @param position Define the start position of the camera in the scene
  102600. * @param scene Define the scene the camera belongs to
  102601. */
  102602. constructor(name: string, position: Vector3, scene: Scene);
  102603. /**
  102604. * Gets the current object class name.
  102605. * @return the class name
  102606. */
  102607. getClassName(): string;
  102608. }
  102609. }
  102610. declare module BABYLON {
  102611. /**
  102612. * This represents a FPS type of camera. This is only here for back compat purpose.
  102613. * Please use the UniversalCamera instead as both are identical.
  102614. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102615. */
  102616. export class GamepadCamera extends UniversalCamera {
  102617. /**
  102618. * Instantiates a new Gamepad Camera
  102619. * This represents a FPS type of camera. This is only here for back compat purpose.
  102620. * Please use the UniversalCamera instead as both are identical.
  102621. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102622. * @param name Define the name of the camera in the scene
  102623. * @param position Define the start position of the camera in the scene
  102624. * @param scene Define the scene the camera belongs to
  102625. */
  102626. constructor(name: string, position: Vector3, scene: Scene);
  102627. /**
  102628. * Gets the current object class name.
  102629. * @return the class name
  102630. */
  102631. getClassName(): string;
  102632. }
  102633. }
  102634. declare module BABYLON {
  102635. /** @hidden */
  102636. export var passPixelShader: {
  102637. name: string;
  102638. shader: string;
  102639. };
  102640. }
  102641. declare module BABYLON {
  102642. /** @hidden */
  102643. export var passCubePixelShader: {
  102644. name: string;
  102645. shader: string;
  102646. };
  102647. }
  102648. declare module BABYLON {
  102649. /**
  102650. * PassPostProcess which produces an output the same as it's input
  102651. */
  102652. export class PassPostProcess extends PostProcess {
  102653. /**
  102654. * Creates the PassPostProcess
  102655. * @param name The name of the effect.
  102656. * @param options The required width/height ratio to downsize to before computing the render pass.
  102657. * @param camera The camera to apply the render pass to.
  102658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102659. * @param engine The engine which the post process will be applied. (default: current engine)
  102660. * @param reusable If the post process can be reused on the same frame. (default: false)
  102661. * @param textureType The type of texture to be used when performing the post processing.
  102662. * @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)
  102663. */
  102664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102665. }
  102666. /**
  102667. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  102668. */
  102669. export class PassCubePostProcess extends PostProcess {
  102670. private _face;
  102671. /**
  102672. * Gets or sets the cube face to display.
  102673. * * 0 is +X
  102674. * * 1 is -X
  102675. * * 2 is +Y
  102676. * * 3 is -Y
  102677. * * 4 is +Z
  102678. * * 5 is -Z
  102679. */
  102680. face: number;
  102681. /**
  102682. * Creates the PassCubePostProcess
  102683. * @param name The name of the effect.
  102684. * @param options The required width/height ratio to downsize to before computing the render pass.
  102685. * @param camera The camera to apply the render pass to.
  102686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102687. * @param engine The engine which the post process will be applied. (default: current engine)
  102688. * @param reusable If the post process can be reused on the same frame. (default: false)
  102689. * @param textureType The type of texture to be used when performing the post processing.
  102690. * @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)
  102691. */
  102692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102693. }
  102694. }
  102695. declare module BABYLON {
  102696. /** @hidden */
  102697. export var anaglyphPixelShader: {
  102698. name: string;
  102699. shader: string;
  102700. };
  102701. }
  102702. declare module BABYLON {
  102703. /**
  102704. * Postprocess used to generate anaglyphic rendering
  102705. */
  102706. export class AnaglyphPostProcess extends PostProcess {
  102707. private _passedProcess;
  102708. /**
  102709. * Creates a new AnaglyphPostProcess
  102710. * @param name defines postprocess name
  102711. * @param options defines creation options or target ratio scale
  102712. * @param rigCameras defines cameras using this postprocess
  102713. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  102714. * @param engine defines hosting engine
  102715. * @param reusable defines if the postprocess will be reused multiple times per frame
  102716. */
  102717. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  102718. }
  102719. }
  102720. declare module BABYLON {
  102721. /**
  102722. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  102723. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102724. */
  102725. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  102726. /**
  102727. * Creates a new AnaglyphArcRotateCamera
  102728. * @param name defines camera name
  102729. * @param alpha defines alpha angle (in radians)
  102730. * @param beta defines beta angle (in radians)
  102731. * @param radius defines radius
  102732. * @param target defines camera target
  102733. * @param interaxialDistance defines distance between each color axis
  102734. * @param scene defines the hosting scene
  102735. */
  102736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  102737. /**
  102738. * Gets camera class name
  102739. * @returns AnaglyphArcRotateCamera
  102740. */
  102741. getClassName(): string;
  102742. }
  102743. }
  102744. declare module BABYLON {
  102745. /**
  102746. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  102747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102748. */
  102749. export class AnaglyphFreeCamera extends FreeCamera {
  102750. /**
  102751. * Creates a new AnaglyphFreeCamera
  102752. * @param name defines camera name
  102753. * @param position defines initial position
  102754. * @param interaxialDistance defines distance between each color axis
  102755. * @param scene defines the hosting scene
  102756. */
  102757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102758. /**
  102759. * Gets camera class name
  102760. * @returns AnaglyphFreeCamera
  102761. */
  102762. getClassName(): string;
  102763. }
  102764. }
  102765. declare module BABYLON {
  102766. /**
  102767. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  102768. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102769. */
  102770. export class AnaglyphGamepadCamera extends GamepadCamera {
  102771. /**
  102772. * Creates a new AnaglyphGamepadCamera
  102773. * @param name defines camera name
  102774. * @param position defines initial position
  102775. * @param interaxialDistance defines distance between each color axis
  102776. * @param scene defines the hosting scene
  102777. */
  102778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102779. /**
  102780. * Gets camera class name
  102781. * @returns AnaglyphGamepadCamera
  102782. */
  102783. getClassName(): string;
  102784. }
  102785. }
  102786. declare module BABYLON {
  102787. /**
  102788. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  102789. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102790. */
  102791. export class AnaglyphUniversalCamera extends UniversalCamera {
  102792. /**
  102793. * Creates a new AnaglyphUniversalCamera
  102794. * @param name defines camera name
  102795. * @param position defines initial position
  102796. * @param interaxialDistance defines distance between each color axis
  102797. * @param scene defines the hosting scene
  102798. */
  102799. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102800. /**
  102801. * Gets camera class name
  102802. * @returns AnaglyphUniversalCamera
  102803. */
  102804. getClassName(): string;
  102805. }
  102806. }
  102807. declare module BABYLON {
  102808. /** @hidden */
  102809. export var stereoscopicInterlacePixelShader: {
  102810. name: string;
  102811. shader: string;
  102812. };
  102813. }
  102814. declare module BABYLON {
  102815. /**
  102816. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  102817. */
  102818. export class StereoscopicInterlacePostProcess extends PostProcess {
  102819. private _stepSize;
  102820. private _passedProcess;
  102821. /**
  102822. * Initializes a StereoscopicInterlacePostProcess
  102823. * @param name The name of the effect.
  102824. * @param rigCameras The rig cameras to be appled to the post process
  102825. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  102826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102827. * @param engine The engine which the post process will be applied. (default: current engine)
  102828. * @param reusable If the post process can be reused on the same frame. (default: false)
  102829. */
  102830. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  102831. }
  102832. }
  102833. declare module BABYLON {
  102834. /**
  102835. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  102836. * @see http://doc.babylonjs.com/features/cameras
  102837. */
  102838. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  102839. /**
  102840. * Creates a new StereoscopicArcRotateCamera
  102841. * @param name defines camera name
  102842. * @param alpha defines alpha angle (in radians)
  102843. * @param beta defines beta angle (in radians)
  102844. * @param radius defines radius
  102845. * @param target defines camera target
  102846. * @param interaxialDistance defines distance between each color axis
  102847. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102848. * @param scene defines the hosting scene
  102849. */
  102850. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102851. /**
  102852. * Gets camera class name
  102853. * @returns StereoscopicArcRotateCamera
  102854. */
  102855. getClassName(): string;
  102856. }
  102857. }
  102858. declare module BABYLON {
  102859. /**
  102860. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  102861. * @see http://doc.babylonjs.com/features/cameras
  102862. */
  102863. export class StereoscopicFreeCamera extends FreeCamera {
  102864. /**
  102865. * Creates a new StereoscopicFreeCamera
  102866. * @param name defines camera name
  102867. * @param position defines initial position
  102868. * @param interaxialDistance defines distance between each color axis
  102869. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102870. * @param scene defines the hosting scene
  102871. */
  102872. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102873. /**
  102874. * Gets camera class name
  102875. * @returns StereoscopicFreeCamera
  102876. */
  102877. getClassName(): string;
  102878. }
  102879. }
  102880. declare module BABYLON {
  102881. /**
  102882. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  102883. * @see http://doc.babylonjs.com/features/cameras
  102884. */
  102885. export class StereoscopicGamepadCamera extends GamepadCamera {
  102886. /**
  102887. * Creates a new StereoscopicGamepadCamera
  102888. * @param name defines camera name
  102889. * @param position defines initial position
  102890. * @param interaxialDistance defines distance between each color axis
  102891. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102892. * @param scene defines the hosting scene
  102893. */
  102894. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102895. /**
  102896. * Gets camera class name
  102897. * @returns StereoscopicGamepadCamera
  102898. */
  102899. getClassName(): string;
  102900. }
  102901. }
  102902. declare module BABYLON {
  102903. /**
  102904. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102905. * @see http://doc.babylonjs.com/features/cameras
  102906. */
  102907. export class StereoscopicUniversalCamera extends UniversalCamera {
  102908. /**
  102909. * Creates a new StereoscopicUniversalCamera
  102910. * @param name defines camera name
  102911. * @param position defines initial position
  102912. * @param interaxialDistance defines distance between each color axis
  102913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102914. * @param scene defines the hosting scene
  102915. */
  102916. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102917. /**
  102918. * Gets camera class name
  102919. * @returns StereoscopicUniversalCamera
  102920. */
  102921. getClassName(): string;
  102922. }
  102923. }
  102924. declare module BABYLON {
  102925. /**
  102926. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102927. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102928. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102929. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102930. */
  102931. export class VirtualJoysticksCamera extends FreeCamera {
  102932. /**
  102933. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102934. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102935. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102936. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102937. * @param name Define the name of the camera in the scene
  102938. * @param position Define the start position of the camera in the scene
  102939. * @param scene Define the scene the camera belongs to
  102940. */
  102941. constructor(name: string, position: Vector3, scene: Scene);
  102942. /**
  102943. * Gets the current object class name.
  102944. * @return the class name
  102945. */
  102946. getClassName(): string;
  102947. }
  102948. }
  102949. declare module BABYLON {
  102950. /**
  102951. * This represents all the required metrics to create a VR camera.
  102952. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102953. */
  102954. export class VRCameraMetrics {
  102955. /**
  102956. * Define the horizontal resolution off the screen.
  102957. */
  102958. hResolution: number;
  102959. /**
  102960. * Define the vertical resolution off the screen.
  102961. */
  102962. vResolution: number;
  102963. /**
  102964. * Define the horizontal screen size.
  102965. */
  102966. hScreenSize: number;
  102967. /**
  102968. * Define the vertical screen size.
  102969. */
  102970. vScreenSize: number;
  102971. /**
  102972. * Define the vertical screen center position.
  102973. */
  102974. vScreenCenter: number;
  102975. /**
  102976. * Define the distance of the eyes to the screen.
  102977. */
  102978. eyeToScreenDistance: number;
  102979. /**
  102980. * Define the distance between both lenses
  102981. */
  102982. lensSeparationDistance: number;
  102983. /**
  102984. * Define the distance between both viewer's eyes.
  102985. */
  102986. interpupillaryDistance: number;
  102987. /**
  102988. * Define the distortion factor of the VR postprocess.
  102989. * Please, touch with care.
  102990. */
  102991. distortionK: number[];
  102992. /**
  102993. * Define the chromatic aberration correction factors for the VR post process.
  102994. */
  102995. chromaAbCorrection: number[];
  102996. /**
  102997. * Define the scale factor of the post process.
  102998. * The smaller the better but the slower.
  102999. */
  103000. postProcessScaleFactor: number;
  103001. /**
  103002. * Define an offset for the lens center.
  103003. */
  103004. lensCenterOffset: number;
  103005. /**
  103006. * Define if the current vr camera should compensate the distortion of the lense or not.
  103007. */
  103008. compensateDistortion: boolean;
  103009. /**
  103010. * Defines if multiview should be enabled when rendering (Default: false)
  103011. */
  103012. multiviewEnabled: boolean;
  103013. /**
  103014. * Gets the rendering aspect ratio based on the provided resolutions.
  103015. */
  103016. readonly aspectRatio: number;
  103017. /**
  103018. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  103019. */
  103020. readonly aspectRatioFov: number;
  103021. /**
  103022. * @hidden
  103023. */
  103024. readonly leftHMatrix: Matrix;
  103025. /**
  103026. * @hidden
  103027. */
  103028. readonly rightHMatrix: Matrix;
  103029. /**
  103030. * @hidden
  103031. */
  103032. readonly leftPreViewMatrix: Matrix;
  103033. /**
  103034. * @hidden
  103035. */
  103036. readonly rightPreViewMatrix: Matrix;
  103037. /**
  103038. * Get the default VRMetrics based on the most generic setup.
  103039. * @returns the default vr metrics
  103040. */
  103041. static GetDefault(): VRCameraMetrics;
  103042. }
  103043. }
  103044. declare module BABYLON {
  103045. /** @hidden */
  103046. export var vrDistortionCorrectionPixelShader: {
  103047. name: string;
  103048. shader: string;
  103049. };
  103050. }
  103051. declare module BABYLON {
  103052. /**
  103053. * VRDistortionCorrectionPostProcess used for mobile VR
  103054. */
  103055. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103056. private _isRightEye;
  103057. private _distortionFactors;
  103058. private _postProcessScaleFactor;
  103059. private _lensCenterOffset;
  103060. private _scaleIn;
  103061. private _scaleFactor;
  103062. private _lensCenter;
  103063. /**
  103064. * Initializes the VRDistortionCorrectionPostProcess
  103065. * @param name The name of the effect.
  103066. * @param camera The camera to apply the render pass to.
  103067. * @param isRightEye If this is for the right eye distortion
  103068. * @param vrMetrics All the required metrics for the VR camera
  103069. */
  103070. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103071. }
  103072. }
  103073. declare module BABYLON {
  103074. /**
  103075. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103076. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103077. */
  103078. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103079. /**
  103080. * Creates a new VRDeviceOrientationArcRotateCamera
  103081. * @param name defines camera name
  103082. * @param alpha defines the camera rotation along the logitudinal axis
  103083. * @param beta defines the camera rotation along the latitudinal axis
  103084. * @param radius defines the camera distance from its target
  103085. * @param target defines the camera target
  103086. * @param scene defines the scene the camera belongs to
  103087. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103088. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103089. */
  103090. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103091. /**
  103092. * Gets camera class name
  103093. * @returns VRDeviceOrientationArcRotateCamera
  103094. */
  103095. getClassName(): string;
  103096. }
  103097. }
  103098. declare module BABYLON {
  103099. /**
  103100. * Camera used to simulate VR rendering (based on FreeCamera)
  103101. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103102. */
  103103. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103104. /**
  103105. * Creates a new VRDeviceOrientationFreeCamera
  103106. * @param name defines camera name
  103107. * @param position defines the start position of the camera
  103108. * @param scene defines the scene the camera belongs to
  103109. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103110. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103111. */
  103112. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103113. /**
  103114. * Gets camera class name
  103115. * @returns VRDeviceOrientationFreeCamera
  103116. */
  103117. getClassName(): string;
  103118. }
  103119. }
  103120. declare module BABYLON {
  103121. /**
  103122. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103123. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103124. */
  103125. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103126. /**
  103127. * Creates a new VRDeviceOrientationGamepadCamera
  103128. * @param name defines camera name
  103129. * @param position defines the start position of the camera
  103130. * @param scene defines the scene the camera belongs to
  103131. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103132. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103133. */
  103134. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103135. /**
  103136. * Gets camera class name
  103137. * @returns VRDeviceOrientationGamepadCamera
  103138. */
  103139. getClassName(): string;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /**
  103144. * Base class of materials working in push mode in babylon JS
  103145. * @hidden
  103146. */
  103147. export class PushMaterial extends Material {
  103148. protected _activeEffect: Effect;
  103149. protected _normalMatrix: Matrix;
  103150. /**
  103151. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103152. * This means that the material can keep using a previous shader while a new one is being compiled.
  103153. * This is mostly used when shader parallel compilation is supported (true by default)
  103154. */
  103155. allowShaderHotSwapping: boolean;
  103156. constructor(name: string, scene: Scene);
  103157. getEffect(): Effect;
  103158. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103159. /**
  103160. * Binds the given world matrix to the active effect
  103161. *
  103162. * @param world the matrix to bind
  103163. */
  103164. bindOnlyWorldMatrix(world: Matrix): void;
  103165. /**
  103166. * Binds the given normal matrix to the active effect
  103167. *
  103168. * @param normalMatrix the matrix to bind
  103169. */
  103170. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103171. bind(world: Matrix, mesh?: Mesh): void;
  103172. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103173. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103174. }
  103175. }
  103176. declare module BABYLON {
  103177. /**
  103178. * This groups all the flags used to control the materials channel.
  103179. */
  103180. export class MaterialFlags {
  103181. private static _DiffuseTextureEnabled;
  103182. /**
  103183. * Are diffuse textures enabled in the application.
  103184. */
  103185. static DiffuseTextureEnabled: boolean;
  103186. private static _AmbientTextureEnabled;
  103187. /**
  103188. * Are ambient textures enabled in the application.
  103189. */
  103190. static AmbientTextureEnabled: boolean;
  103191. private static _OpacityTextureEnabled;
  103192. /**
  103193. * Are opacity textures enabled in the application.
  103194. */
  103195. static OpacityTextureEnabled: boolean;
  103196. private static _ReflectionTextureEnabled;
  103197. /**
  103198. * Are reflection textures enabled in the application.
  103199. */
  103200. static ReflectionTextureEnabled: boolean;
  103201. private static _EmissiveTextureEnabled;
  103202. /**
  103203. * Are emissive textures enabled in the application.
  103204. */
  103205. static EmissiveTextureEnabled: boolean;
  103206. private static _SpecularTextureEnabled;
  103207. /**
  103208. * Are specular textures enabled in the application.
  103209. */
  103210. static SpecularTextureEnabled: boolean;
  103211. private static _BumpTextureEnabled;
  103212. /**
  103213. * Are bump textures enabled in the application.
  103214. */
  103215. static BumpTextureEnabled: boolean;
  103216. private static _LightmapTextureEnabled;
  103217. /**
  103218. * Are lightmap textures enabled in the application.
  103219. */
  103220. static LightmapTextureEnabled: boolean;
  103221. private static _RefractionTextureEnabled;
  103222. /**
  103223. * Are refraction textures enabled in the application.
  103224. */
  103225. static RefractionTextureEnabled: boolean;
  103226. private static _ColorGradingTextureEnabled;
  103227. /**
  103228. * Are color grading textures enabled in the application.
  103229. */
  103230. static ColorGradingTextureEnabled: boolean;
  103231. private static _FresnelEnabled;
  103232. /**
  103233. * Are fresnels enabled in the application.
  103234. */
  103235. static FresnelEnabled: boolean;
  103236. private static _ClearCoatTextureEnabled;
  103237. /**
  103238. * Are clear coat textures enabled in the application.
  103239. */
  103240. static ClearCoatTextureEnabled: boolean;
  103241. private static _ClearCoatBumpTextureEnabled;
  103242. /**
  103243. * Are clear coat bump textures enabled in the application.
  103244. */
  103245. static ClearCoatBumpTextureEnabled: boolean;
  103246. private static _ClearCoatTintTextureEnabled;
  103247. /**
  103248. * Are clear coat tint textures enabled in the application.
  103249. */
  103250. static ClearCoatTintTextureEnabled: boolean;
  103251. private static _SheenTextureEnabled;
  103252. /**
  103253. * Are sheen textures enabled in the application.
  103254. */
  103255. static SheenTextureEnabled: boolean;
  103256. private static _AnisotropicTextureEnabled;
  103257. /**
  103258. * Are anisotropic textures enabled in the application.
  103259. */
  103260. static AnisotropicTextureEnabled: boolean;
  103261. private static _ThicknessTextureEnabled;
  103262. /**
  103263. * Are thickness textures enabled in the application.
  103264. */
  103265. static ThicknessTextureEnabled: boolean;
  103266. }
  103267. }
  103268. declare module BABYLON {
  103269. /** @hidden */
  103270. export var defaultFragmentDeclaration: {
  103271. name: string;
  103272. shader: string;
  103273. };
  103274. }
  103275. declare module BABYLON {
  103276. /** @hidden */
  103277. export var defaultUboDeclaration: {
  103278. name: string;
  103279. shader: string;
  103280. };
  103281. }
  103282. declare module BABYLON {
  103283. /** @hidden */
  103284. export var lightFragmentDeclaration: {
  103285. name: string;
  103286. shader: string;
  103287. };
  103288. }
  103289. declare module BABYLON {
  103290. /** @hidden */
  103291. export var lightUboDeclaration: {
  103292. name: string;
  103293. shader: string;
  103294. };
  103295. }
  103296. declare module BABYLON {
  103297. /** @hidden */
  103298. export var lightsFragmentFunctions: {
  103299. name: string;
  103300. shader: string;
  103301. };
  103302. }
  103303. declare module BABYLON {
  103304. /** @hidden */
  103305. export var shadowsFragmentFunctions: {
  103306. name: string;
  103307. shader: string;
  103308. };
  103309. }
  103310. declare module BABYLON {
  103311. /** @hidden */
  103312. export var fresnelFunction: {
  103313. name: string;
  103314. shader: string;
  103315. };
  103316. }
  103317. declare module BABYLON {
  103318. /** @hidden */
  103319. export var reflectionFunction: {
  103320. name: string;
  103321. shader: string;
  103322. };
  103323. }
  103324. declare module BABYLON {
  103325. /** @hidden */
  103326. export var bumpFragmentFunctions: {
  103327. name: string;
  103328. shader: string;
  103329. };
  103330. }
  103331. declare module BABYLON {
  103332. /** @hidden */
  103333. export var logDepthDeclaration: {
  103334. name: string;
  103335. shader: string;
  103336. };
  103337. }
  103338. declare module BABYLON {
  103339. /** @hidden */
  103340. export var bumpFragment: {
  103341. name: string;
  103342. shader: string;
  103343. };
  103344. }
  103345. declare module BABYLON {
  103346. /** @hidden */
  103347. export var depthPrePass: {
  103348. name: string;
  103349. shader: string;
  103350. };
  103351. }
  103352. declare module BABYLON {
  103353. /** @hidden */
  103354. export var lightFragment: {
  103355. name: string;
  103356. shader: string;
  103357. };
  103358. }
  103359. declare module BABYLON {
  103360. /** @hidden */
  103361. export var logDepthFragment: {
  103362. name: string;
  103363. shader: string;
  103364. };
  103365. }
  103366. declare module BABYLON {
  103367. /** @hidden */
  103368. export var defaultPixelShader: {
  103369. name: string;
  103370. shader: string;
  103371. };
  103372. }
  103373. declare module BABYLON {
  103374. /** @hidden */
  103375. export var defaultVertexDeclaration: {
  103376. name: string;
  103377. shader: string;
  103378. };
  103379. }
  103380. declare module BABYLON {
  103381. /** @hidden */
  103382. export var bumpVertexDeclaration: {
  103383. name: string;
  103384. shader: string;
  103385. };
  103386. }
  103387. declare module BABYLON {
  103388. /** @hidden */
  103389. export var bumpVertex: {
  103390. name: string;
  103391. shader: string;
  103392. };
  103393. }
  103394. declare module BABYLON {
  103395. /** @hidden */
  103396. export var fogVertex: {
  103397. name: string;
  103398. shader: string;
  103399. };
  103400. }
  103401. declare module BABYLON {
  103402. /** @hidden */
  103403. export var shadowsVertex: {
  103404. name: string;
  103405. shader: string;
  103406. };
  103407. }
  103408. declare module BABYLON {
  103409. /** @hidden */
  103410. export var pointCloudVertex: {
  103411. name: string;
  103412. shader: string;
  103413. };
  103414. }
  103415. declare module BABYLON {
  103416. /** @hidden */
  103417. export var logDepthVertex: {
  103418. name: string;
  103419. shader: string;
  103420. };
  103421. }
  103422. declare module BABYLON {
  103423. /** @hidden */
  103424. export var defaultVertexShader: {
  103425. name: string;
  103426. shader: string;
  103427. };
  103428. }
  103429. declare module BABYLON {
  103430. /** @hidden */
  103431. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103432. MAINUV1: boolean;
  103433. MAINUV2: boolean;
  103434. DIFFUSE: boolean;
  103435. DIFFUSEDIRECTUV: number;
  103436. AMBIENT: boolean;
  103437. AMBIENTDIRECTUV: number;
  103438. OPACITY: boolean;
  103439. OPACITYDIRECTUV: number;
  103440. OPACITYRGB: boolean;
  103441. REFLECTION: boolean;
  103442. EMISSIVE: boolean;
  103443. EMISSIVEDIRECTUV: number;
  103444. SPECULAR: boolean;
  103445. SPECULARDIRECTUV: number;
  103446. BUMP: boolean;
  103447. BUMPDIRECTUV: number;
  103448. PARALLAX: boolean;
  103449. PARALLAXOCCLUSION: boolean;
  103450. SPECULAROVERALPHA: boolean;
  103451. CLIPPLANE: boolean;
  103452. CLIPPLANE2: boolean;
  103453. CLIPPLANE3: boolean;
  103454. CLIPPLANE4: boolean;
  103455. ALPHATEST: boolean;
  103456. DEPTHPREPASS: boolean;
  103457. ALPHAFROMDIFFUSE: boolean;
  103458. POINTSIZE: boolean;
  103459. FOG: boolean;
  103460. SPECULARTERM: boolean;
  103461. DIFFUSEFRESNEL: boolean;
  103462. OPACITYFRESNEL: boolean;
  103463. REFLECTIONFRESNEL: boolean;
  103464. REFRACTIONFRESNEL: boolean;
  103465. EMISSIVEFRESNEL: boolean;
  103466. FRESNEL: boolean;
  103467. NORMAL: boolean;
  103468. UV1: boolean;
  103469. UV2: boolean;
  103470. VERTEXCOLOR: boolean;
  103471. VERTEXALPHA: boolean;
  103472. NUM_BONE_INFLUENCERS: number;
  103473. BonesPerMesh: number;
  103474. BONETEXTURE: boolean;
  103475. INSTANCES: boolean;
  103476. GLOSSINESS: boolean;
  103477. ROUGHNESS: boolean;
  103478. EMISSIVEASILLUMINATION: boolean;
  103479. LINKEMISSIVEWITHDIFFUSE: boolean;
  103480. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103481. LIGHTMAP: boolean;
  103482. LIGHTMAPDIRECTUV: number;
  103483. OBJECTSPACE_NORMALMAP: boolean;
  103484. USELIGHTMAPASSHADOWMAP: boolean;
  103485. REFLECTIONMAP_3D: boolean;
  103486. REFLECTIONMAP_SPHERICAL: boolean;
  103487. REFLECTIONMAP_PLANAR: boolean;
  103488. REFLECTIONMAP_CUBIC: boolean;
  103489. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103490. REFLECTIONMAP_PROJECTION: boolean;
  103491. REFLECTIONMAP_SKYBOX: boolean;
  103492. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103493. REFLECTIONMAP_EXPLICIT: boolean;
  103494. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103495. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103496. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103497. INVERTCUBICMAP: boolean;
  103498. LOGARITHMICDEPTH: boolean;
  103499. REFRACTION: boolean;
  103500. REFRACTIONMAP_3D: boolean;
  103501. REFLECTIONOVERALPHA: boolean;
  103502. TWOSIDEDLIGHTING: boolean;
  103503. SHADOWFLOAT: boolean;
  103504. MORPHTARGETS: boolean;
  103505. MORPHTARGETS_NORMAL: boolean;
  103506. MORPHTARGETS_TANGENT: boolean;
  103507. MORPHTARGETS_UV: boolean;
  103508. NUM_MORPH_INFLUENCERS: number;
  103509. NONUNIFORMSCALING: boolean;
  103510. PREMULTIPLYALPHA: boolean;
  103511. IMAGEPROCESSING: boolean;
  103512. VIGNETTE: boolean;
  103513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103514. VIGNETTEBLENDMODEOPAQUE: boolean;
  103515. TONEMAPPING: boolean;
  103516. TONEMAPPING_ACES: boolean;
  103517. CONTRAST: boolean;
  103518. COLORCURVES: boolean;
  103519. COLORGRADING: boolean;
  103520. COLORGRADING3D: boolean;
  103521. SAMPLER3DGREENDEPTH: boolean;
  103522. SAMPLER3DBGRMAP: boolean;
  103523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103524. MULTIVIEW: boolean;
  103525. /**
  103526. * If the reflection texture on this material is in linear color space
  103527. * @hidden
  103528. */
  103529. IS_REFLECTION_LINEAR: boolean;
  103530. /**
  103531. * If the refraction texture on this material is in linear color space
  103532. * @hidden
  103533. */
  103534. IS_REFRACTION_LINEAR: boolean;
  103535. EXPOSURE: boolean;
  103536. constructor();
  103537. setReflectionMode(modeToEnable: string): void;
  103538. }
  103539. /**
  103540. * This is the default material used in Babylon. It is the best trade off between quality
  103541. * and performances.
  103542. * @see http://doc.babylonjs.com/babylon101/materials
  103543. */
  103544. export class StandardMaterial extends PushMaterial {
  103545. private _diffuseTexture;
  103546. /**
  103547. * The basic texture of the material as viewed under a light.
  103548. */
  103549. diffuseTexture: Nullable<BaseTexture>;
  103550. private _ambientTexture;
  103551. /**
  103552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103553. */
  103554. ambientTexture: Nullable<BaseTexture>;
  103555. private _opacityTexture;
  103556. /**
  103557. * Define the transparency of the material from a texture.
  103558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103560. */
  103561. opacityTexture: Nullable<BaseTexture>;
  103562. private _reflectionTexture;
  103563. /**
  103564. * Define the texture used to display the reflection.
  103565. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103566. */
  103567. reflectionTexture: Nullable<BaseTexture>;
  103568. private _emissiveTexture;
  103569. /**
  103570. * Define texture of the material as if self lit.
  103571. * This will be mixed in the final result even in the absence of light.
  103572. */
  103573. emissiveTexture: Nullable<BaseTexture>;
  103574. private _specularTexture;
  103575. /**
  103576. * Define how the color and intensity of the highlight given by the light in the material.
  103577. */
  103578. specularTexture: Nullable<BaseTexture>;
  103579. private _bumpTexture;
  103580. /**
  103581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103582. * 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.
  103583. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103584. */
  103585. bumpTexture: Nullable<BaseTexture>;
  103586. private _lightmapTexture;
  103587. /**
  103588. * Complex lighting can be computationally expensive to compute at runtime.
  103589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103590. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103591. */
  103592. lightmapTexture: Nullable<BaseTexture>;
  103593. private _refractionTexture;
  103594. /**
  103595. * Define the texture used to display the refraction.
  103596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103597. */
  103598. refractionTexture: Nullable<BaseTexture>;
  103599. /**
  103600. * The color of the material lit by the environmental background lighting.
  103601. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103602. */
  103603. ambientColor: Color3;
  103604. /**
  103605. * The basic color of the material as viewed under a light.
  103606. */
  103607. diffuseColor: Color3;
  103608. /**
  103609. * Define how the color and intensity of the highlight given by the light in the material.
  103610. */
  103611. specularColor: Color3;
  103612. /**
  103613. * Define the color of the material as if self lit.
  103614. * This will be mixed in the final result even in the absence of light.
  103615. */
  103616. emissiveColor: Color3;
  103617. /**
  103618. * Defines how sharp are the highlights in the material.
  103619. * The bigger the value the sharper giving a more glossy feeling to the result.
  103620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103621. */
  103622. specularPower: number;
  103623. private _useAlphaFromDiffuseTexture;
  103624. /**
  103625. * Does the transparency come from the diffuse texture alpha channel.
  103626. */
  103627. useAlphaFromDiffuseTexture: boolean;
  103628. private _useEmissiveAsIllumination;
  103629. /**
  103630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103631. */
  103632. useEmissiveAsIllumination: boolean;
  103633. private _linkEmissiveWithDiffuse;
  103634. /**
  103635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103636. * the emissive level when the final color is close to one.
  103637. */
  103638. linkEmissiveWithDiffuse: boolean;
  103639. private _useSpecularOverAlpha;
  103640. /**
  103641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103643. */
  103644. useSpecularOverAlpha: boolean;
  103645. private _useReflectionOverAlpha;
  103646. /**
  103647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103649. */
  103650. useReflectionOverAlpha: boolean;
  103651. private _disableLighting;
  103652. /**
  103653. * Does lights from the scene impacts this material.
  103654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103655. */
  103656. disableLighting: boolean;
  103657. private _useObjectSpaceNormalMap;
  103658. /**
  103659. * Allows using an object space normal map (instead of tangent space).
  103660. */
  103661. useObjectSpaceNormalMap: boolean;
  103662. private _useParallax;
  103663. /**
  103664. * Is parallax enabled or not.
  103665. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103666. */
  103667. useParallax: boolean;
  103668. private _useParallaxOcclusion;
  103669. /**
  103670. * Is parallax occlusion enabled or not.
  103671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103673. */
  103674. useParallaxOcclusion: boolean;
  103675. /**
  103676. * 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.
  103677. */
  103678. parallaxScaleBias: number;
  103679. private _roughness;
  103680. /**
  103681. * Helps to define how blurry the reflections should appears in the material.
  103682. */
  103683. roughness: number;
  103684. /**
  103685. * In case of refraction, define the value of the index of refraction.
  103686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103687. */
  103688. indexOfRefraction: number;
  103689. /**
  103690. * Invert the refraction texture alongside the y axis.
  103691. * It can be useful with procedural textures or probe for instance.
  103692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103693. */
  103694. invertRefractionY: boolean;
  103695. /**
  103696. * Defines the alpha limits in alpha test mode.
  103697. */
  103698. alphaCutOff: number;
  103699. private _useLightmapAsShadowmap;
  103700. /**
  103701. * In case of light mapping, define whether the map contains light or shadow informations.
  103702. */
  103703. useLightmapAsShadowmap: boolean;
  103704. private _diffuseFresnelParameters;
  103705. /**
  103706. * Define the diffuse fresnel parameters of the material.
  103707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103708. */
  103709. diffuseFresnelParameters: FresnelParameters;
  103710. private _opacityFresnelParameters;
  103711. /**
  103712. * Define the opacity fresnel parameters of the material.
  103713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103714. */
  103715. opacityFresnelParameters: FresnelParameters;
  103716. private _reflectionFresnelParameters;
  103717. /**
  103718. * Define the reflection fresnel parameters of the material.
  103719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103720. */
  103721. reflectionFresnelParameters: FresnelParameters;
  103722. private _refractionFresnelParameters;
  103723. /**
  103724. * Define the refraction fresnel parameters of the material.
  103725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103726. */
  103727. refractionFresnelParameters: FresnelParameters;
  103728. private _emissiveFresnelParameters;
  103729. /**
  103730. * Define the emissive fresnel parameters of the material.
  103731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103732. */
  103733. emissiveFresnelParameters: FresnelParameters;
  103734. private _useReflectionFresnelFromSpecular;
  103735. /**
  103736. * If true automatically deducts the fresnels values from the material specularity.
  103737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103738. */
  103739. useReflectionFresnelFromSpecular: boolean;
  103740. private _useGlossinessFromSpecularMapAlpha;
  103741. /**
  103742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103743. */
  103744. useGlossinessFromSpecularMapAlpha: boolean;
  103745. private _maxSimultaneousLights;
  103746. /**
  103747. * Defines the maximum number of lights that can be used in the material
  103748. */
  103749. maxSimultaneousLights: number;
  103750. private _invertNormalMapX;
  103751. /**
  103752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103753. */
  103754. invertNormalMapX: boolean;
  103755. private _invertNormalMapY;
  103756. /**
  103757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103758. */
  103759. invertNormalMapY: boolean;
  103760. private _twoSidedLighting;
  103761. /**
  103762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103763. */
  103764. twoSidedLighting: boolean;
  103765. /**
  103766. * Default configuration related to image processing available in the standard Material.
  103767. */
  103768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103769. /**
  103770. * Gets the image processing configuration used either in this material.
  103771. */
  103772. /**
  103773. * Sets the Default image processing configuration used either in the this material.
  103774. *
  103775. * If sets to null, the scene one is in use.
  103776. */
  103777. imageProcessingConfiguration: ImageProcessingConfiguration;
  103778. /**
  103779. * Keep track of the image processing observer to allow dispose and replace.
  103780. */
  103781. private _imageProcessingObserver;
  103782. /**
  103783. * Attaches a new image processing configuration to the Standard Material.
  103784. * @param configuration
  103785. */
  103786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103787. /**
  103788. * Gets wether the color curves effect is enabled.
  103789. */
  103790. /**
  103791. * Sets wether the color curves effect is enabled.
  103792. */
  103793. cameraColorCurvesEnabled: boolean;
  103794. /**
  103795. * Gets wether the color grading effect is enabled.
  103796. */
  103797. /**
  103798. * Gets wether the color grading effect is enabled.
  103799. */
  103800. cameraColorGradingEnabled: boolean;
  103801. /**
  103802. * Gets wether tonemapping is enabled or not.
  103803. */
  103804. /**
  103805. * Sets wether tonemapping is enabled or not
  103806. */
  103807. cameraToneMappingEnabled: boolean;
  103808. /**
  103809. * The camera exposure used on this material.
  103810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103811. * This corresponds to a photographic exposure.
  103812. */
  103813. /**
  103814. * The camera exposure used on this material.
  103815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103816. * This corresponds to a photographic exposure.
  103817. */
  103818. cameraExposure: number;
  103819. /**
  103820. * Gets The camera contrast used on this material.
  103821. */
  103822. /**
  103823. * Sets The camera contrast used on this material.
  103824. */
  103825. cameraContrast: number;
  103826. /**
  103827. * Gets the Color Grading 2D Lookup Texture.
  103828. */
  103829. /**
  103830. * Sets the Color Grading 2D Lookup Texture.
  103831. */
  103832. cameraColorGradingTexture: Nullable<BaseTexture>;
  103833. /**
  103834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103836. * 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;
  103837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103838. */
  103839. /**
  103840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103842. * 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;
  103843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103844. */
  103845. cameraColorCurves: Nullable<ColorCurves>;
  103846. /**
  103847. * Custom callback helping to override the default shader used in the material.
  103848. */
  103849. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  103850. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103851. protected _worldViewProjectionMatrix: Matrix;
  103852. protected _globalAmbientColor: Color3;
  103853. protected _useLogarithmicDepth: boolean;
  103854. /**
  103855. * Instantiates a new standard material.
  103856. * This is the default material used in Babylon. It is the best trade off between quality
  103857. * and performances.
  103858. * @see http://doc.babylonjs.com/babylon101/materials
  103859. * @param name Define the name of the material in the scene
  103860. * @param scene Define the scene the material belong to
  103861. */
  103862. constructor(name: string, scene: Scene);
  103863. /**
  103864. * Gets a boolean indicating that current material needs to register RTT
  103865. */
  103866. readonly hasRenderTargetTextures: boolean;
  103867. /**
  103868. * Gets the current class name of the material e.g. "StandardMaterial"
  103869. * Mainly use in serialization.
  103870. * @returns the class name
  103871. */
  103872. getClassName(): string;
  103873. /**
  103874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103875. * You can try switching to logarithmic depth.
  103876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103877. */
  103878. useLogarithmicDepth: boolean;
  103879. /**
  103880. * Specifies if the material will require alpha blending
  103881. * @returns a boolean specifying if alpha blending is needed
  103882. */
  103883. needAlphaBlending(): boolean;
  103884. /**
  103885. * Specifies if this material should be rendered in alpha test mode
  103886. * @returns a boolean specifying if an alpha test is needed.
  103887. */
  103888. needAlphaTesting(): boolean;
  103889. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103890. /**
  103891. * Get the texture used for alpha test purpose.
  103892. * @returns the diffuse texture in case of the standard material.
  103893. */
  103894. getAlphaTestTexture(): Nullable<BaseTexture>;
  103895. /**
  103896. * Get if the submesh is ready to be used and all its information available.
  103897. * Child classes can use it to update shaders
  103898. * @param mesh defines the mesh to check
  103899. * @param subMesh defines which submesh to check
  103900. * @param useInstances specifies that instances should be used
  103901. * @returns a boolean indicating that the submesh is ready or not
  103902. */
  103903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103904. /**
  103905. * Builds the material UBO layouts.
  103906. * Used internally during the effect preparation.
  103907. */
  103908. buildUniformLayout(): void;
  103909. /**
  103910. * Unbinds the material from the mesh
  103911. */
  103912. unbind(): void;
  103913. /**
  103914. * Binds the submesh to this material by preparing the effect and shader to draw
  103915. * @param world defines the world transformation matrix
  103916. * @param mesh defines the mesh containing the submesh
  103917. * @param subMesh defines the submesh to bind the material to
  103918. */
  103919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103920. /**
  103921. * Get the list of animatables in the material.
  103922. * @returns the list of animatables object used in the material
  103923. */
  103924. getAnimatables(): IAnimatable[];
  103925. /**
  103926. * Gets the active textures from the material
  103927. * @returns an array of textures
  103928. */
  103929. getActiveTextures(): BaseTexture[];
  103930. /**
  103931. * Specifies if the material uses a texture
  103932. * @param texture defines the texture to check against the material
  103933. * @returns a boolean specifying if the material uses the texture
  103934. */
  103935. hasTexture(texture: BaseTexture): boolean;
  103936. /**
  103937. * Disposes the material
  103938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103940. */
  103941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103942. /**
  103943. * Makes a duplicate of the material, and gives it a new name
  103944. * @param name defines the new name for the duplicated material
  103945. * @returns the cloned material
  103946. */
  103947. clone(name: string): StandardMaterial;
  103948. /**
  103949. * Serializes this material in a JSON representation
  103950. * @returns the serialized material object
  103951. */
  103952. serialize(): any;
  103953. /**
  103954. * Creates a standard material from parsed material data
  103955. * @param source defines the JSON representation of the material
  103956. * @param scene defines the hosting scene
  103957. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103958. * @returns a new standard material
  103959. */
  103960. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103961. /**
  103962. * Are diffuse textures enabled in the application.
  103963. */
  103964. static DiffuseTextureEnabled: boolean;
  103965. /**
  103966. * Are ambient textures enabled in the application.
  103967. */
  103968. static AmbientTextureEnabled: boolean;
  103969. /**
  103970. * Are opacity textures enabled in the application.
  103971. */
  103972. static OpacityTextureEnabled: boolean;
  103973. /**
  103974. * Are reflection textures enabled in the application.
  103975. */
  103976. static ReflectionTextureEnabled: boolean;
  103977. /**
  103978. * Are emissive textures enabled in the application.
  103979. */
  103980. static EmissiveTextureEnabled: boolean;
  103981. /**
  103982. * Are specular textures enabled in the application.
  103983. */
  103984. static SpecularTextureEnabled: boolean;
  103985. /**
  103986. * Are bump textures enabled in the application.
  103987. */
  103988. static BumpTextureEnabled: boolean;
  103989. /**
  103990. * Are lightmap textures enabled in the application.
  103991. */
  103992. static LightmapTextureEnabled: boolean;
  103993. /**
  103994. * Are refraction textures enabled in the application.
  103995. */
  103996. static RefractionTextureEnabled: boolean;
  103997. /**
  103998. * Are color grading textures enabled in the application.
  103999. */
  104000. static ColorGradingTextureEnabled: boolean;
  104001. /**
  104002. * Are fresnels enabled in the application.
  104003. */
  104004. static FresnelEnabled: boolean;
  104005. }
  104006. }
  104007. declare module BABYLON {
  104008. /**
  104009. * A class extending Texture allowing drawing on a texture
  104010. * @see http://doc.babylonjs.com/how_to/dynamictexture
  104011. */
  104012. export class DynamicTexture extends Texture {
  104013. private _generateMipMaps;
  104014. private _canvas;
  104015. private _context;
  104016. private _engine;
  104017. /**
  104018. * Creates a DynamicTexture
  104019. * @param name defines the name of the texture
  104020. * @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
  104021. * @param scene defines the scene where you want the texture
  104022. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  104023. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  104024. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  104025. */
  104026. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  104027. /**
  104028. * Get the current class name of the texture useful for serialization or dynamic coding.
  104029. * @returns "DynamicTexture"
  104030. */
  104031. getClassName(): string;
  104032. /**
  104033. * Gets the current state of canRescale
  104034. */
  104035. readonly canRescale: boolean;
  104036. private _recreate;
  104037. /**
  104038. * Scales the texture
  104039. * @param ratio the scale factor to apply to both width and height
  104040. */
  104041. scale(ratio: number): void;
  104042. /**
  104043. * Resizes the texture
  104044. * @param width the new width
  104045. * @param height the new height
  104046. */
  104047. scaleTo(width: number, height: number): void;
  104048. /**
  104049. * Gets the context of the canvas used by the texture
  104050. * @returns the canvas context of the dynamic texture
  104051. */
  104052. getContext(): CanvasRenderingContext2D;
  104053. /**
  104054. * Clears the texture
  104055. */
  104056. clear(): void;
  104057. /**
  104058. * Updates the texture
  104059. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104060. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104061. */
  104062. update(invertY?: boolean, premulAlpha?: boolean): void;
  104063. /**
  104064. * Draws text onto the texture
  104065. * @param text defines the text to be drawn
  104066. * @param x defines the placement of the text from the left
  104067. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104068. * @param font defines the font to be used with font-style, font-size, font-name
  104069. * @param color defines the color used for the text
  104070. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104071. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104072. * @param update defines whether texture is immediately update (default is true)
  104073. */
  104074. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104075. /**
  104076. * Clones the texture
  104077. * @returns the clone of the texture.
  104078. */
  104079. clone(): DynamicTexture;
  104080. /**
  104081. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104082. * @returns a serialized dynamic texture object
  104083. */
  104084. serialize(): any;
  104085. /** @hidden */
  104086. _rebuild(): void;
  104087. }
  104088. }
  104089. declare module BABYLON {
  104090. /** @hidden */
  104091. export var imageProcessingPixelShader: {
  104092. name: string;
  104093. shader: string;
  104094. };
  104095. }
  104096. declare module BABYLON {
  104097. /**
  104098. * ImageProcessingPostProcess
  104099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104100. */
  104101. export class ImageProcessingPostProcess extends PostProcess {
  104102. /**
  104103. * Default configuration related to image processing available in the PBR Material.
  104104. */
  104105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104106. /**
  104107. * Gets the image processing configuration used either in this material.
  104108. */
  104109. /**
  104110. * Sets the Default image processing configuration used either in the this material.
  104111. *
  104112. * If sets to null, the scene one is in use.
  104113. */
  104114. imageProcessingConfiguration: ImageProcessingConfiguration;
  104115. /**
  104116. * Keep track of the image processing observer to allow dispose and replace.
  104117. */
  104118. private _imageProcessingObserver;
  104119. /**
  104120. * Attaches a new image processing configuration to the PBR Material.
  104121. * @param configuration
  104122. */
  104123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104124. /**
  104125. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104126. */
  104127. /**
  104128. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104129. */
  104130. colorCurves: Nullable<ColorCurves>;
  104131. /**
  104132. * Gets wether the color curves effect is enabled.
  104133. */
  104134. /**
  104135. * Sets wether the color curves effect is enabled.
  104136. */
  104137. colorCurvesEnabled: boolean;
  104138. /**
  104139. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104140. */
  104141. /**
  104142. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104143. */
  104144. colorGradingTexture: Nullable<BaseTexture>;
  104145. /**
  104146. * Gets wether the color grading effect is enabled.
  104147. */
  104148. /**
  104149. * Gets wether the color grading effect is enabled.
  104150. */
  104151. colorGradingEnabled: boolean;
  104152. /**
  104153. * Gets exposure used in the effect.
  104154. */
  104155. /**
  104156. * Sets exposure used in the effect.
  104157. */
  104158. exposure: number;
  104159. /**
  104160. * Gets wether tonemapping is enabled or not.
  104161. */
  104162. /**
  104163. * Sets wether tonemapping is enabled or not
  104164. */
  104165. toneMappingEnabled: boolean;
  104166. /**
  104167. * Gets the type of tone mapping effect.
  104168. */
  104169. /**
  104170. * Sets the type of tone mapping effect.
  104171. */
  104172. toneMappingType: number;
  104173. /**
  104174. * Gets contrast used in the effect.
  104175. */
  104176. /**
  104177. * Sets contrast used in the effect.
  104178. */
  104179. contrast: number;
  104180. /**
  104181. * Gets Vignette stretch size.
  104182. */
  104183. /**
  104184. * Sets Vignette stretch size.
  104185. */
  104186. vignetteStretch: number;
  104187. /**
  104188. * Gets Vignette centre X Offset.
  104189. */
  104190. /**
  104191. * Sets Vignette centre X Offset.
  104192. */
  104193. vignetteCentreX: number;
  104194. /**
  104195. * Gets Vignette centre Y Offset.
  104196. */
  104197. /**
  104198. * Sets Vignette centre Y Offset.
  104199. */
  104200. vignetteCentreY: number;
  104201. /**
  104202. * Gets Vignette weight or intensity of the vignette effect.
  104203. */
  104204. /**
  104205. * Sets Vignette weight or intensity of the vignette effect.
  104206. */
  104207. vignetteWeight: number;
  104208. /**
  104209. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104210. * if vignetteEnabled is set to true.
  104211. */
  104212. /**
  104213. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104214. * if vignetteEnabled is set to true.
  104215. */
  104216. vignetteColor: Color4;
  104217. /**
  104218. * Gets Camera field of view used by the Vignette effect.
  104219. */
  104220. /**
  104221. * Sets Camera field of view used by the Vignette effect.
  104222. */
  104223. vignetteCameraFov: number;
  104224. /**
  104225. * Gets the vignette blend mode allowing different kind of effect.
  104226. */
  104227. /**
  104228. * Sets the vignette blend mode allowing different kind of effect.
  104229. */
  104230. vignetteBlendMode: number;
  104231. /**
  104232. * Gets wether the vignette effect is enabled.
  104233. */
  104234. /**
  104235. * Sets wether the vignette effect is enabled.
  104236. */
  104237. vignetteEnabled: boolean;
  104238. private _fromLinearSpace;
  104239. /**
  104240. * Gets wether the input of the processing is in Gamma or Linear Space.
  104241. */
  104242. /**
  104243. * Sets wether the input of the processing is in Gamma or Linear Space.
  104244. */
  104245. fromLinearSpace: boolean;
  104246. /**
  104247. * Defines cache preventing GC.
  104248. */
  104249. private _defines;
  104250. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104251. /**
  104252. * "ImageProcessingPostProcess"
  104253. * @returns "ImageProcessingPostProcess"
  104254. */
  104255. getClassName(): string;
  104256. protected _updateParameters(): void;
  104257. dispose(camera?: Camera): void;
  104258. }
  104259. }
  104260. declare module BABYLON {
  104261. /**
  104262. * Class containing static functions to help procedurally build meshes
  104263. */
  104264. export class GroundBuilder {
  104265. /**
  104266. * Creates a ground mesh
  104267. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104268. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104270. * @param name defines the name of the mesh
  104271. * @param options defines the options used to create the mesh
  104272. * @param scene defines the hosting scene
  104273. * @returns the ground mesh
  104274. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104275. */
  104276. static CreateGround(name: string, options: {
  104277. width?: number;
  104278. height?: number;
  104279. subdivisions?: number;
  104280. subdivisionsX?: number;
  104281. subdivisionsY?: number;
  104282. updatable?: boolean;
  104283. }, scene: any): Mesh;
  104284. /**
  104285. * Creates a tiled ground mesh
  104286. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104287. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104288. * * 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
  104289. * * 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
  104290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104291. * @param name defines the name of the mesh
  104292. * @param options defines the options used to create the mesh
  104293. * @param scene defines the hosting scene
  104294. * @returns the tiled ground mesh
  104295. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104296. */
  104297. static CreateTiledGround(name: string, options: {
  104298. xmin: number;
  104299. zmin: number;
  104300. xmax: number;
  104301. zmax: number;
  104302. subdivisions?: {
  104303. w: number;
  104304. h: number;
  104305. };
  104306. precision?: {
  104307. w: number;
  104308. h: number;
  104309. };
  104310. updatable?: boolean;
  104311. }, scene?: Nullable<Scene>): Mesh;
  104312. /**
  104313. * Creates a ground mesh from a height map
  104314. * * The parameter `url` sets the URL of the height map image resource.
  104315. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104316. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104317. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104318. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104319. * * 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.
  104320. * * 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).
  104321. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104323. * @param name defines the name of the mesh
  104324. * @param url defines the url to the height map
  104325. * @param options defines the options used to create the mesh
  104326. * @param scene defines the hosting scene
  104327. * @returns the ground mesh
  104328. * @see https://doc.babylonjs.com/babylon101/height_map
  104329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104330. */
  104331. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104332. width?: number;
  104333. height?: number;
  104334. subdivisions?: number;
  104335. minHeight?: number;
  104336. maxHeight?: number;
  104337. colorFilter?: Color3;
  104338. alphaFilter?: number;
  104339. updatable?: boolean;
  104340. onReady?: (mesh: GroundMesh) => void;
  104341. }, scene?: Nullable<Scene>): GroundMesh;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * Class containing static functions to help procedurally build meshes
  104347. */
  104348. export class TorusBuilder {
  104349. /**
  104350. * Creates a torus mesh
  104351. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104352. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104353. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104357. * @param name defines the name of the mesh
  104358. * @param options defines the options used to create the mesh
  104359. * @param scene defines the hosting scene
  104360. * @returns the torus mesh
  104361. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104362. */
  104363. static CreateTorus(name: string, options: {
  104364. diameter?: number;
  104365. thickness?: number;
  104366. tessellation?: number;
  104367. updatable?: boolean;
  104368. sideOrientation?: number;
  104369. frontUVs?: Vector4;
  104370. backUVs?: Vector4;
  104371. }, scene: any): Mesh;
  104372. }
  104373. }
  104374. declare module BABYLON {
  104375. /**
  104376. * Class containing static functions to help procedurally build meshes
  104377. */
  104378. export class CylinderBuilder {
  104379. /**
  104380. * Creates a cylinder or a cone mesh
  104381. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104382. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104383. * * 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.
  104384. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104385. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104386. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104387. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104388. * * 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).
  104389. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104390. * * 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).
  104391. * * 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
  104392. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104393. * * 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
  104394. * * 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.
  104395. * * If `enclose` is false, a ring surface is one element.
  104396. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104397. * * 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
  104398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104401. * @param name defines the name of the mesh
  104402. * @param options defines the options used to create the mesh
  104403. * @param scene defines the hosting scene
  104404. * @returns the cylinder mesh
  104405. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104406. */
  104407. static CreateCylinder(name: string, options: {
  104408. height?: number;
  104409. diameterTop?: number;
  104410. diameterBottom?: number;
  104411. diameter?: number;
  104412. tessellation?: number;
  104413. subdivisions?: number;
  104414. arc?: number;
  104415. faceColors?: Color4[];
  104416. faceUV?: Vector4[];
  104417. updatable?: boolean;
  104418. hasRings?: boolean;
  104419. enclose?: boolean;
  104420. cap?: number;
  104421. sideOrientation?: number;
  104422. frontUVs?: Vector4;
  104423. backUVs?: Vector4;
  104424. }, scene: any): Mesh;
  104425. }
  104426. }
  104427. declare module BABYLON {
  104428. /**
  104429. * Options to modify the vr teleportation behavior.
  104430. */
  104431. export interface VRTeleportationOptions {
  104432. /**
  104433. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104434. */
  104435. floorMeshName?: string;
  104436. /**
  104437. * A list of meshes to be used as the teleportation floor. (default: empty)
  104438. */
  104439. floorMeshes?: Mesh[];
  104440. }
  104441. /**
  104442. * Options to modify the vr experience helper's behavior.
  104443. */
  104444. export interface VRExperienceHelperOptions extends WebVROptions {
  104445. /**
  104446. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104447. */
  104448. createDeviceOrientationCamera?: boolean;
  104449. /**
  104450. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104451. */
  104452. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104453. /**
  104454. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104455. */
  104456. laserToggle?: boolean;
  104457. /**
  104458. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104459. */
  104460. floorMeshes?: Mesh[];
  104461. /**
  104462. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104463. */
  104464. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104465. }
  104466. /**
  104467. * Event containing information after VR has been entered
  104468. */
  104469. export class OnAfterEnteringVRObservableEvent {
  104470. /**
  104471. * If entering vr was successful
  104472. */
  104473. success: boolean;
  104474. }
  104475. /**
  104476. * Helps to quickly add VR support to an existing scene.
  104477. * See http://doc.babylonjs.com/how_to/webvr_helper
  104478. */
  104479. export class VRExperienceHelper {
  104480. /** Options to modify the vr experience helper's behavior. */
  104481. webVROptions: VRExperienceHelperOptions;
  104482. private _scene;
  104483. private _position;
  104484. private _btnVR;
  104485. private _btnVRDisplayed;
  104486. private _webVRsupported;
  104487. private _webVRready;
  104488. private _webVRrequesting;
  104489. private _webVRpresenting;
  104490. private _hasEnteredVR;
  104491. private _fullscreenVRpresenting;
  104492. private _canvas;
  104493. private _webVRCamera;
  104494. private _vrDeviceOrientationCamera;
  104495. private _deviceOrientationCamera;
  104496. private _existingCamera;
  104497. private _onKeyDown;
  104498. private _onVrDisplayPresentChange;
  104499. private _onVRDisplayChanged;
  104500. private _onVRRequestPresentStart;
  104501. private _onVRRequestPresentComplete;
  104502. /**
  104503. * 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)
  104504. */
  104505. enableGazeEvenWhenNoPointerLock: boolean;
  104506. /**
  104507. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104508. */
  104509. exitVROnDoubleTap: boolean;
  104510. /**
  104511. * Observable raised right before entering VR.
  104512. */
  104513. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104514. /**
  104515. * Observable raised when entering VR has completed.
  104516. */
  104517. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104518. /**
  104519. * Observable raised when exiting VR.
  104520. */
  104521. onExitingVRObservable: Observable<VRExperienceHelper>;
  104522. /**
  104523. * Observable raised when controller mesh is loaded.
  104524. */
  104525. onControllerMeshLoadedObservable: Observable<WebVRController>;
  104526. /** Return this.onEnteringVRObservable
  104527. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  104528. */
  104529. readonly onEnteringVR: Observable<VRExperienceHelper>;
  104530. /** Return this.onExitingVRObservable
  104531. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  104532. */
  104533. readonly onExitingVR: Observable<VRExperienceHelper>;
  104534. /** Return this.onControllerMeshLoadedObservable
  104535. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  104536. */
  104537. readonly onControllerMeshLoaded: Observable<WebVRController>;
  104538. private _rayLength;
  104539. private _useCustomVRButton;
  104540. private _teleportationRequested;
  104541. private _teleportActive;
  104542. private _floorMeshName;
  104543. private _floorMeshesCollection;
  104544. private _rotationAllowed;
  104545. private _teleportBackwardsVector;
  104546. private _teleportationTarget;
  104547. private _isDefaultTeleportationTarget;
  104548. private _postProcessMove;
  104549. private _teleportationFillColor;
  104550. private _teleportationBorderColor;
  104551. private _rotationAngle;
  104552. private _haloCenter;
  104553. private _cameraGazer;
  104554. private _padSensibilityUp;
  104555. private _padSensibilityDown;
  104556. private _leftController;
  104557. private _rightController;
  104558. /**
  104559. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  104560. */
  104561. onNewMeshSelected: Observable<AbstractMesh>;
  104562. /**
  104563. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  104564. */
  104565. onNewMeshPicked: Observable<PickingInfo>;
  104566. private _circleEase;
  104567. /**
  104568. * Observable raised before camera teleportation
  104569. */
  104570. onBeforeCameraTeleport: Observable<Vector3>;
  104571. /**
  104572. * Observable raised after camera teleportation
  104573. */
  104574. onAfterCameraTeleport: Observable<Vector3>;
  104575. /**
  104576. * Observable raised when current selected mesh gets unselected
  104577. */
  104578. onSelectedMeshUnselected: Observable<AbstractMesh>;
  104579. private _raySelectionPredicate;
  104580. /**
  104581. * To be optionaly changed by user to define custom ray selection
  104582. */
  104583. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  104584. /**
  104585. * To be optionaly changed by user to define custom selection logic (after ray selection)
  104586. */
  104587. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104588. /**
  104589. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  104590. */
  104591. teleportationEnabled: boolean;
  104592. private _defaultHeight;
  104593. private _teleportationInitialized;
  104594. private _interactionsEnabled;
  104595. private _interactionsRequested;
  104596. private _displayGaze;
  104597. private _displayLaserPointer;
  104598. /**
  104599. * The mesh used to display where the user is going to teleport.
  104600. */
  104601. /**
  104602. * Sets the mesh to be used to display where the user is going to teleport.
  104603. */
  104604. teleportationTarget: Mesh;
  104605. /**
  104606. * 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
  104607. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  104608. * See http://doc.babylonjs.com/resources/baking_transformations
  104609. */
  104610. gazeTrackerMesh: Mesh;
  104611. /**
  104612. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  104613. */
  104614. updateGazeTrackerScale: boolean;
  104615. /**
  104616. * If the gaze trackers color should be updated when selecting meshes
  104617. */
  104618. updateGazeTrackerColor: boolean;
  104619. /**
  104620. * The gaze tracking mesh corresponding to the left controller
  104621. */
  104622. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  104623. /**
  104624. * The gaze tracking mesh corresponding to the right controller
  104625. */
  104626. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  104627. /**
  104628. * If the ray of the gaze should be displayed.
  104629. */
  104630. /**
  104631. * Sets if the ray of the gaze should be displayed.
  104632. */
  104633. displayGaze: boolean;
  104634. /**
  104635. * If the ray of the LaserPointer should be displayed.
  104636. */
  104637. /**
  104638. * Sets if the ray of the LaserPointer should be displayed.
  104639. */
  104640. displayLaserPointer: boolean;
  104641. /**
  104642. * The deviceOrientationCamera used as the camera when not in VR.
  104643. */
  104644. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  104645. /**
  104646. * Based on the current WebVR support, returns the current VR camera used.
  104647. */
  104648. readonly currentVRCamera: Nullable<Camera>;
  104649. /**
  104650. * The webVRCamera which is used when in VR.
  104651. */
  104652. readonly webVRCamera: WebVRFreeCamera;
  104653. /**
  104654. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  104655. */
  104656. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  104657. /**
  104658. * The html button that is used to trigger entering into VR.
  104659. */
  104660. readonly vrButton: Nullable<HTMLButtonElement>;
  104661. private readonly _teleportationRequestInitiated;
  104662. /**
  104663. * Defines wether or not Pointer lock should be requested when switching to
  104664. * full screen.
  104665. */
  104666. requestPointerLockOnFullScreen: boolean;
  104667. /**
  104668. * Instantiates a VRExperienceHelper.
  104669. * Helps to quickly add VR support to an existing scene.
  104670. * @param scene The scene the VRExperienceHelper belongs to.
  104671. * @param webVROptions Options to modify the vr experience helper's behavior.
  104672. */
  104673. constructor(scene: Scene,
  104674. /** Options to modify the vr experience helper's behavior. */
  104675. webVROptions?: VRExperienceHelperOptions);
  104676. private _onDefaultMeshLoaded;
  104677. private _onResize;
  104678. private _onFullscreenChange;
  104679. /**
  104680. * Gets a value indicating if we are currently in VR mode.
  104681. */
  104682. readonly isInVRMode: boolean;
  104683. private onVrDisplayPresentChange;
  104684. private onVRDisplayChanged;
  104685. private moveButtonToBottomRight;
  104686. private displayVRButton;
  104687. private updateButtonVisibility;
  104688. private _cachedAngularSensibility;
  104689. /**
  104690. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  104691. * Otherwise, will use the fullscreen API.
  104692. */
  104693. enterVR(): void;
  104694. /**
  104695. * Attempt to exit VR, or fullscreen.
  104696. */
  104697. exitVR(): void;
  104698. /**
  104699. * The position of the vr experience helper.
  104700. */
  104701. /**
  104702. * Sets the position of the vr experience helper.
  104703. */
  104704. position: Vector3;
  104705. /**
  104706. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  104707. */
  104708. enableInteractions(): void;
  104709. private readonly _noControllerIsActive;
  104710. private beforeRender;
  104711. private _isTeleportationFloor;
  104712. /**
  104713. * Adds a floor mesh to be used for teleportation.
  104714. * @param floorMesh the mesh to be used for teleportation.
  104715. */
  104716. addFloorMesh(floorMesh: Mesh): void;
  104717. /**
  104718. * Removes a floor mesh from being used for teleportation.
  104719. * @param floorMesh the mesh to be removed.
  104720. */
  104721. removeFloorMesh(floorMesh: Mesh): void;
  104722. /**
  104723. * Enables interactions and teleportation using the VR controllers and gaze.
  104724. * @param vrTeleportationOptions options to modify teleportation behavior.
  104725. */
  104726. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  104727. private _onNewGamepadConnected;
  104728. private _tryEnableInteractionOnController;
  104729. private _onNewGamepadDisconnected;
  104730. private _enableInteractionOnController;
  104731. private _checkTeleportWithRay;
  104732. private _checkRotate;
  104733. private _checkTeleportBackwards;
  104734. private _enableTeleportationOnController;
  104735. private _createTeleportationCircles;
  104736. private _displayTeleportationTarget;
  104737. private _hideTeleportationTarget;
  104738. private _rotateCamera;
  104739. private _moveTeleportationSelectorTo;
  104740. private _workingVector;
  104741. private _workingQuaternion;
  104742. private _workingMatrix;
  104743. /**
  104744. * Teleports the users feet to the desired location
  104745. * @param location The location where the user's feet should be placed
  104746. */
  104747. teleportCamera(location: Vector3): void;
  104748. private _convertNormalToDirectionOfRay;
  104749. private _castRayAndSelectObject;
  104750. private _notifySelectedMeshUnselected;
  104751. /**
  104752. * Sets the color of the laser ray from the vr controllers.
  104753. * @param color new color for the ray.
  104754. */
  104755. changeLaserColor(color: Color3): void;
  104756. /**
  104757. * Sets the color of the ray from the vr headsets gaze.
  104758. * @param color new color for the ray.
  104759. */
  104760. changeGazeColor(color: Color3): void;
  104761. /**
  104762. * Exits VR and disposes of the vr experience helper
  104763. */
  104764. dispose(): void;
  104765. /**
  104766. * Gets the name of the VRExperienceHelper class
  104767. * @returns "VRExperienceHelper"
  104768. */
  104769. getClassName(): string;
  104770. }
  104771. }
  104772. declare module BABYLON {
  104773. /**
  104774. * Manages an XRSession to work with Babylon's engine
  104775. * @see https://doc.babylonjs.com/how_to/webxr
  104776. */
  104777. export class WebXRSessionManager implements IDisposable {
  104778. private scene;
  104779. /**
  104780. * Fires every time a new xrFrame arrives which can be used to update the camera
  104781. */
  104782. onXRFrameObservable: Observable<any>;
  104783. /**
  104784. * Fires when the xr session is ended either by the device or manually done
  104785. */
  104786. onXRSessionEnded: Observable<any>;
  104787. /**
  104788. * Underlying xr session
  104789. */
  104790. session: XRSession;
  104791. /**
  104792. * Type of reference space used when creating the session
  104793. */
  104794. referenceSpace: XRReferenceSpace;
  104795. /** @hidden */
  104796. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  104797. /**
  104798. * Current XR frame
  104799. */
  104800. currentFrame: Nullable<XRFrame>;
  104801. private _xrNavigator;
  104802. private baseLayer;
  104803. /**
  104804. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  104805. * @param scene The scene which the session should be created for
  104806. */
  104807. constructor(scene: Scene);
  104808. /**
  104809. * Initializes the manager
  104810. * After initialization enterXR can be called to start an XR session
  104811. * @returns Promise which resolves after it is initialized
  104812. */
  104813. initializeAsync(): Promise<void>;
  104814. /**
  104815. * Initializes an xr session
  104816. * @param xrSessionMode mode to initialize
  104817. * @returns a promise which will resolve once the session has been initialized
  104818. */
  104819. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  104820. /**
  104821. * Sets the reference space on the xr session
  104822. * @param referenceSpace space to set
  104823. * @returns a promise that will resolve once the reference space has been set
  104824. */
  104825. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  104826. /**
  104827. * Updates the render state of the session
  104828. * @param state state to set
  104829. * @returns a promise that resolves once the render state has been updated
  104830. */
  104831. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  104832. /**
  104833. * Starts rendering to the xr layer
  104834. * @returns a promise that will resolve once rendering has started
  104835. */
  104836. startRenderingToXRAsync(): Promise<void>;
  104837. /**
  104838. * Stops the xrSession and restores the renderloop
  104839. * @returns Promise which resolves after it exits XR
  104840. */
  104841. exitXRAsync(): Promise<unknown>;
  104842. /**
  104843. * Checks if a session would be supported for the creation options specified
  104844. * @param sessionMode session mode to check if supported eg. immersive-vr
  104845. * @returns true if supported
  104846. */
  104847. supportsSessionAsync(sessionMode: XRSessionMode): any;
  104848. /**
  104849. * @hidden
  104850. * Converts the render layer of xrSession to a render target
  104851. * @param session session to create render target for
  104852. * @param scene scene the new render target should be created for
  104853. */
  104854. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  104855. /**
  104856. * Disposes of the session manager
  104857. */
  104858. dispose(): void;
  104859. }
  104860. }
  104861. declare module BABYLON {
  104862. /**
  104863. * WebXR Camera which holds the views for the xrSession
  104864. * @see https://doc.babylonjs.com/how_to/webxr
  104865. */
  104866. export class WebXRCamera extends FreeCamera {
  104867. private static _TmpMatrix;
  104868. /**
  104869. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  104870. * @param name the name of the camera
  104871. * @param scene the scene to add the camera to
  104872. */
  104873. constructor(name: string, scene: Scene);
  104874. private _updateNumberOfRigCameras;
  104875. /** @hidden */
  104876. _updateForDualEyeDebugging(pupilDistance?: number): void;
  104877. /**
  104878. * Updates the cameras position from the current pose information of the XR session
  104879. * @param xrSessionManager the session containing pose information
  104880. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  104881. */
  104882. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  104883. }
  104884. }
  104885. declare module BABYLON {
  104886. /**
  104887. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  104888. */
  104889. export class WebXRManagedOutputCanvas implements IDisposable {
  104890. private helper;
  104891. private _canvas;
  104892. /**
  104893. * xrpresent context of the canvas which can be used to display/mirror xr content
  104894. */
  104895. canvasContext: WebGLRenderingContext;
  104896. /**
  104897. * xr layer for the canvas
  104898. */
  104899. xrLayer: Nullable<XRWebGLLayer>;
  104900. /**
  104901. * Initializes the xr layer for the session
  104902. * @param xrSession xr session
  104903. * @returns a promise that will resolve once the XR Layer has been created
  104904. */
  104905. initializeXRLayerAsync(xrSession: any): any;
  104906. /**
  104907. * Initializes the canvas to be added/removed upon entering/exiting xr
  104908. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104909. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104910. */
  104911. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104912. /**
  104913. * Disposes of the object
  104914. */
  104915. dispose(): void;
  104916. private _setManagedOutputCanvas;
  104917. private _addCanvas;
  104918. private _removeCanvas;
  104919. }
  104920. }
  104921. declare module BABYLON {
  104922. /**
  104923. * States of the webXR experience
  104924. */
  104925. export enum WebXRState {
  104926. /**
  104927. * Transitioning to being in XR mode
  104928. */
  104929. ENTERING_XR = 0,
  104930. /**
  104931. * Transitioning to non XR mode
  104932. */
  104933. EXITING_XR = 1,
  104934. /**
  104935. * In XR mode and presenting
  104936. */
  104937. IN_XR = 2,
  104938. /**
  104939. * Not entered XR mode
  104940. */
  104941. NOT_IN_XR = 3
  104942. }
  104943. /**
  104944. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104945. * @see https://doc.babylonjs.com/how_to/webxr
  104946. */
  104947. export class WebXRExperienceHelper implements IDisposable {
  104948. private scene;
  104949. /**
  104950. * 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
  104951. */
  104952. container: AbstractMesh;
  104953. /**
  104954. * Camera used to render xr content
  104955. */
  104956. camera: WebXRCamera;
  104957. /**
  104958. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104959. */
  104960. state: WebXRState;
  104961. private _setState;
  104962. private static _TmpVector;
  104963. /**
  104964. * Fires when the state of the experience helper has changed
  104965. */
  104966. onStateChangedObservable: Observable<WebXRState>;
  104967. /** Session manager used to keep track of xr session */
  104968. sessionManager: WebXRSessionManager;
  104969. private _nonVRCamera;
  104970. private _originalSceneAutoClear;
  104971. private _supported;
  104972. /**
  104973. * Creates the experience helper
  104974. * @param scene the scene to attach the experience helper to
  104975. * @returns a promise for the experience helper
  104976. */
  104977. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104978. /**
  104979. * Creates a WebXRExperienceHelper
  104980. * @param scene The scene the helper should be created in
  104981. */
  104982. private constructor();
  104983. /**
  104984. * Exits XR mode and returns the scene to its original state
  104985. * @returns promise that resolves after xr mode has exited
  104986. */
  104987. exitXRAsync(): Promise<unknown>;
  104988. /**
  104989. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104990. * @param sessionCreationOptions options for the XR session
  104991. * @param referenceSpaceType frame of reference of the XR session
  104992. * @param outputCanvas the output canvas that will be used to enter XR mode
  104993. * @returns promise that resolves after xr mode has entered
  104994. */
  104995. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104996. /**
  104997. * Updates the global position of the camera by moving the camera's container
  104998. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104999. * @param position The desired global position of the camera
  105000. */
  105001. setPositionOfCameraUsingContainer(position: Vector3): void;
  105002. /**
  105003. * Rotates the xr camera by rotating the camera's container around the camera's position
  105004. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  105005. * @param rotation the desired quaternion rotation to apply to the camera
  105006. */
  105007. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  105008. /**
  105009. * Disposes of the experience helper
  105010. */
  105011. dispose(): void;
  105012. }
  105013. }
  105014. declare module BABYLON {
  105015. /**
  105016. * Button which can be used to enter a different mode of XR
  105017. */
  105018. export class WebXREnterExitUIButton {
  105019. /** button element */
  105020. element: HTMLElement;
  105021. /** XR initialization options for the button */
  105022. sessionMode: XRSessionMode;
  105023. /** Reference space type */
  105024. referenceSpaceType: XRReferenceSpaceType;
  105025. /**
  105026. * Creates a WebXREnterExitUIButton
  105027. * @param element button element
  105028. * @param sessionMode XR initialization session mode
  105029. * @param referenceSpaceType the type of reference space to be used
  105030. */
  105031. constructor(
  105032. /** button element */
  105033. element: HTMLElement,
  105034. /** XR initialization options for the button */
  105035. sessionMode: XRSessionMode,
  105036. /** Reference space type */
  105037. referenceSpaceType: XRReferenceSpaceType);
  105038. /**
  105039. * Overwritable function which can be used to update the button's visuals when the state changes
  105040. * @param activeButton the current active button in the UI
  105041. */
  105042. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  105043. }
  105044. /**
  105045. * Options to create the webXR UI
  105046. */
  105047. export class WebXREnterExitUIOptions {
  105048. /**
  105049. * Context to enter xr with
  105050. */
  105051. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  105052. /**
  105053. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105054. */
  105055. customButtons?: Array<WebXREnterExitUIButton>;
  105056. }
  105057. /**
  105058. * UI to allow the user to enter/exit XR mode
  105059. */
  105060. export class WebXREnterExitUI implements IDisposable {
  105061. private scene;
  105062. private _overlay;
  105063. private _buttons;
  105064. private _activeButton;
  105065. /**
  105066. * Fired every time the active button is changed.
  105067. *
  105068. * When xr is entered via a button that launches xr that button will be the callback parameter
  105069. *
  105070. * When exiting xr the callback parameter will be null)
  105071. */
  105072. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105073. /**
  105074. * Creates UI to allow the user to enter/exit XR mode
  105075. * @param scene the scene to add the ui to
  105076. * @param helper the xr experience helper to enter/exit xr with
  105077. * @param options options to configure the UI
  105078. * @returns the created ui
  105079. */
  105080. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105081. private constructor();
  105082. private _updateButtons;
  105083. /**
  105084. * Disposes of the object
  105085. */
  105086. dispose(): void;
  105087. }
  105088. }
  105089. declare module BABYLON {
  105090. /**
  105091. * Represents an XR input
  105092. */
  105093. export class WebXRController {
  105094. private scene;
  105095. /** The underlying input source for the controller */
  105096. inputSource: XRInputSource;
  105097. private parentContainer;
  105098. /**
  105099. * 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
  105100. */
  105101. grip?: AbstractMesh;
  105102. /**
  105103. * Pointer which can be used to select objects or attach a visible laser to
  105104. */
  105105. pointer: AbstractMesh;
  105106. /**
  105107. * Event that fires when the controller is removed/disposed
  105108. */
  105109. onDisposeObservable: Observable<{}>;
  105110. private _tmpMatrix;
  105111. private _tmpQuaternion;
  105112. private _tmpVector;
  105113. /**
  105114. * Creates the controller
  105115. * @see https://doc.babylonjs.com/how_to/webxr
  105116. * @param scene the scene which the controller should be associated to
  105117. * @param inputSource the underlying input source for the controller
  105118. * @param parentContainer parent that the controller meshes should be children of
  105119. */
  105120. constructor(scene: Scene,
  105121. /** The underlying input source for the controller */
  105122. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105123. /**
  105124. * Updates the controller pose based on the given XRFrame
  105125. * @param xrFrame xr frame to update the pose with
  105126. * @param referenceSpace reference space to use
  105127. */
  105128. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105129. /**
  105130. * Gets a world space ray coming from the controller
  105131. * @param result the resulting ray
  105132. */
  105133. getWorldPointerRayToRef(result: Ray): void;
  105134. /**
  105135. * Disposes of the object
  105136. */
  105137. dispose(): void;
  105138. }
  105139. }
  105140. declare module BABYLON {
  105141. /**
  105142. * XR input used to track XR inputs such as controllers/rays
  105143. */
  105144. export class WebXRInput implements IDisposable {
  105145. /**
  105146. * Base experience the input listens to
  105147. */
  105148. baseExperience: WebXRExperienceHelper;
  105149. /**
  105150. * XR controllers being tracked
  105151. */
  105152. controllers: Array<WebXRController>;
  105153. private _frameObserver;
  105154. private _stateObserver;
  105155. /**
  105156. * Event when a controller has been connected/added
  105157. */
  105158. onControllerAddedObservable: Observable<WebXRController>;
  105159. /**
  105160. * Event when a controller has been removed/disconnected
  105161. */
  105162. onControllerRemovedObservable: Observable<WebXRController>;
  105163. /**
  105164. * Initializes the WebXRInput
  105165. * @param baseExperience experience helper which the input should be created for
  105166. */
  105167. constructor(
  105168. /**
  105169. * Base experience the input listens to
  105170. */
  105171. baseExperience: WebXRExperienceHelper);
  105172. private _onInputSourcesChange;
  105173. private _addAndRemoveControllers;
  105174. /**
  105175. * Disposes of the object
  105176. */
  105177. dispose(): void;
  105178. }
  105179. }
  105180. declare module BABYLON {
  105181. /**
  105182. * Enables teleportation
  105183. */
  105184. export class WebXRControllerTeleportation {
  105185. private _teleportationFillColor;
  105186. private _teleportationBorderColor;
  105187. private _tmpRay;
  105188. private _tmpVector;
  105189. /**
  105190. * Creates a WebXRControllerTeleportation
  105191. * @param input input manager to add teleportation to
  105192. * @param floorMeshes floormeshes which can be teleported to
  105193. */
  105194. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  105195. }
  105196. }
  105197. declare module BABYLON {
  105198. /**
  105199. * Handles pointer input automatically for the pointer of XR controllers
  105200. */
  105201. export class WebXRControllerPointerSelection {
  105202. private static _idCounter;
  105203. private _tmpRay;
  105204. /**
  105205. * Creates a WebXRControllerPointerSelection
  105206. * @param input input manager to setup pointer selection
  105207. */
  105208. constructor(input: WebXRInput);
  105209. private _convertNormalToDirectionOfRay;
  105210. private _updatePointerDistance;
  105211. }
  105212. }
  105213. declare module BABYLON {
  105214. /**
  105215. * Class used to represent data loading progression
  105216. */
  105217. export class SceneLoaderProgressEvent {
  105218. /** defines if data length to load can be evaluated */
  105219. readonly lengthComputable: boolean;
  105220. /** defines the loaded data length */
  105221. readonly loaded: number;
  105222. /** defines the data length to load */
  105223. readonly total: number;
  105224. /**
  105225. * Create a new progress event
  105226. * @param lengthComputable defines if data length to load can be evaluated
  105227. * @param loaded defines the loaded data length
  105228. * @param total defines the data length to load
  105229. */
  105230. constructor(
  105231. /** defines if data length to load can be evaluated */
  105232. lengthComputable: boolean,
  105233. /** defines the loaded data length */
  105234. loaded: number,
  105235. /** defines the data length to load */
  105236. total: number);
  105237. /**
  105238. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105239. * @param event defines the source event
  105240. * @returns a new SceneLoaderProgressEvent
  105241. */
  105242. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105243. }
  105244. /**
  105245. * Interface used by SceneLoader plugins to define supported file extensions
  105246. */
  105247. export interface ISceneLoaderPluginExtensions {
  105248. /**
  105249. * Defines the list of supported extensions
  105250. */
  105251. [extension: string]: {
  105252. isBinary: boolean;
  105253. };
  105254. }
  105255. /**
  105256. * Interface used by SceneLoader plugin factory
  105257. */
  105258. export interface ISceneLoaderPluginFactory {
  105259. /**
  105260. * Defines the name of the factory
  105261. */
  105262. name: string;
  105263. /**
  105264. * Function called to create a new plugin
  105265. * @return the new plugin
  105266. */
  105267. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105268. /**
  105269. * Boolean indicating if the plugin can direct load specific data
  105270. */
  105271. canDirectLoad?: (data: string) => boolean;
  105272. }
  105273. /**
  105274. * Interface used to define a SceneLoader plugin
  105275. */
  105276. export interface ISceneLoaderPlugin {
  105277. /**
  105278. * The friendly name of this plugin.
  105279. */
  105280. name: string;
  105281. /**
  105282. * The file extensions supported by this plugin.
  105283. */
  105284. extensions: string | ISceneLoaderPluginExtensions;
  105285. /**
  105286. * Import meshes into a scene.
  105287. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105288. * @param scene The scene to import into
  105289. * @param data The data to import
  105290. * @param rootUrl The root url for scene and resources
  105291. * @param meshes The meshes array to import into
  105292. * @param particleSystems The particle systems array to import into
  105293. * @param skeletons The skeletons array to import into
  105294. * @param onError The callback when import fails
  105295. * @returns True if successful or false otherwise
  105296. */
  105297. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105298. /**
  105299. * Load into a scene.
  105300. * @param scene The scene to load into
  105301. * @param data The data to import
  105302. * @param rootUrl The root url for scene and resources
  105303. * @param onError The callback when import fails
  105304. * @returns true if successful or false otherwise
  105305. */
  105306. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105307. /**
  105308. * The callback that returns true if the data can be directly loaded.
  105309. */
  105310. canDirectLoad?: (data: string) => boolean;
  105311. /**
  105312. * The callback that allows custom handling of the root url based on the response url.
  105313. */
  105314. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105315. /**
  105316. * Load into an asset container.
  105317. * @param scene The scene to load into
  105318. * @param data The data to import
  105319. * @param rootUrl The root url for scene and resources
  105320. * @param onError The callback when import fails
  105321. * @returns The loaded asset container
  105322. */
  105323. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105324. }
  105325. /**
  105326. * Interface used to define an async SceneLoader plugin
  105327. */
  105328. export interface ISceneLoaderPluginAsync {
  105329. /**
  105330. * The friendly name of this plugin.
  105331. */
  105332. name: string;
  105333. /**
  105334. * The file extensions supported by this plugin.
  105335. */
  105336. extensions: string | ISceneLoaderPluginExtensions;
  105337. /**
  105338. * Import meshes into a scene.
  105339. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105340. * @param scene The scene to import into
  105341. * @param data The data to import
  105342. * @param rootUrl The root url for scene and resources
  105343. * @param onProgress The callback when the load progresses
  105344. * @param fileName Defines the name of the file to load
  105345. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105346. */
  105347. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105348. meshes: AbstractMesh[];
  105349. particleSystems: IParticleSystem[];
  105350. skeletons: Skeleton[];
  105351. animationGroups: AnimationGroup[];
  105352. }>;
  105353. /**
  105354. * Load into a scene.
  105355. * @param scene The scene to load into
  105356. * @param data The data to import
  105357. * @param rootUrl The root url for scene and resources
  105358. * @param onProgress The callback when the load progresses
  105359. * @param fileName Defines the name of the file to load
  105360. * @returns Nothing
  105361. */
  105362. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105363. /**
  105364. * The callback that returns true if the data can be directly loaded.
  105365. */
  105366. canDirectLoad?: (data: string) => boolean;
  105367. /**
  105368. * The callback that allows custom handling of the root url based on the response url.
  105369. */
  105370. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105371. /**
  105372. * Load into an asset container.
  105373. * @param scene The scene to load into
  105374. * @param data The data to import
  105375. * @param rootUrl The root url for scene and resources
  105376. * @param onProgress The callback when the load progresses
  105377. * @param fileName Defines the name of the file to load
  105378. * @returns The loaded asset container
  105379. */
  105380. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105381. }
  105382. /**
  105383. * Class used to load scene from various file formats using registered plugins
  105384. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105385. */
  105386. export class SceneLoader {
  105387. /**
  105388. * No logging while loading
  105389. */
  105390. static readonly NO_LOGGING: number;
  105391. /**
  105392. * Minimal logging while loading
  105393. */
  105394. static readonly MINIMAL_LOGGING: number;
  105395. /**
  105396. * Summary logging while loading
  105397. */
  105398. static readonly SUMMARY_LOGGING: number;
  105399. /**
  105400. * Detailled logging while loading
  105401. */
  105402. static readonly DETAILED_LOGGING: number;
  105403. /**
  105404. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105405. */
  105406. static ForceFullSceneLoadingForIncremental: boolean;
  105407. /**
  105408. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105409. */
  105410. static ShowLoadingScreen: boolean;
  105411. /**
  105412. * Defines the current logging level (while loading the scene)
  105413. * @ignorenaming
  105414. */
  105415. static loggingLevel: number;
  105416. /**
  105417. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105418. */
  105419. static CleanBoneMatrixWeights: boolean;
  105420. /**
  105421. * Event raised when a plugin is used to load a scene
  105422. */
  105423. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105424. private static _registeredPlugins;
  105425. private static _getDefaultPlugin;
  105426. private static _getPluginForExtension;
  105427. private static _getPluginForDirectLoad;
  105428. private static _getPluginForFilename;
  105429. private static _getDirectLoad;
  105430. private static _loadData;
  105431. private static _getFileInfo;
  105432. /**
  105433. * Gets a plugin that can load the given extension
  105434. * @param extension defines the extension to load
  105435. * @returns a plugin or null if none works
  105436. */
  105437. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105438. /**
  105439. * Gets a boolean indicating that the given extension can be loaded
  105440. * @param extension defines the extension to load
  105441. * @returns true if the extension is supported
  105442. */
  105443. static IsPluginForExtensionAvailable(extension: string): boolean;
  105444. /**
  105445. * Adds a new plugin to the list of registered plugins
  105446. * @param plugin defines the plugin to add
  105447. */
  105448. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105449. /**
  105450. * Import meshes into a scene
  105451. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105452. * @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)
  105453. * @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)
  105454. * @param scene the instance of BABYLON.Scene to append to
  105455. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105456. * @param onProgress a callback with a progress event for each file being loaded
  105457. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105458. * @param pluginExtension the extension used to determine the plugin
  105459. * @returns The loaded plugin
  105460. */
  105461. 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>;
  105462. /**
  105463. * Import meshes into a scene
  105464. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105465. * @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)
  105466. * @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)
  105467. * @param scene the instance of BABYLON.Scene to append to
  105468. * @param onProgress a callback with a progress event for each file being loaded
  105469. * @param pluginExtension the extension used to determine the plugin
  105470. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105471. */
  105472. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105473. meshes: AbstractMesh[];
  105474. particleSystems: IParticleSystem[];
  105475. skeletons: Skeleton[];
  105476. animationGroups: AnimationGroup[];
  105477. }>;
  105478. /**
  105479. * Load a scene
  105480. * @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)
  105481. * @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)
  105482. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105483. * @param onSuccess a callback with the scene when import succeeds
  105484. * @param onProgress a callback with a progress event for each file being loaded
  105485. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105486. * @param pluginExtension the extension used to determine the plugin
  105487. * @returns The loaded plugin
  105488. */
  105489. 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>;
  105490. /**
  105491. * Load a scene
  105492. * @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)
  105493. * @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)
  105494. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105495. * @param onProgress a callback with a progress event for each file being loaded
  105496. * @param pluginExtension the extension used to determine the plugin
  105497. * @returns The loaded scene
  105498. */
  105499. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105500. /**
  105501. * Append a scene
  105502. * @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)
  105503. * @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)
  105504. * @param scene is the instance of BABYLON.Scene to append to
  105505. * @param onSuccess a callback with the scene when import succeeds
  105506. * @param onProgress a callback with a progress event for each file being loaded
  105507. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105508. * @param pluginExtension the extension used to determine the plugin
  105509. * @returns The loaded plugin
  105510. */
  105511. 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>;
  105512. /**
  105513. * Append a scene
  105514. * @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)
  105515. * @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)
  105516. * @param scene is the instance of BABYLON.Scene to append to
  105517. * @param onProgress a callback with a progress event for each file being loaded
  105518. * @param pluginExtension the extension used to determine the plugin
  105519. * @returns The given scene
  105520. */
  105521. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105522. /**
  105523. * Load a scene into an asset container
  105524. * @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)
  105525. * @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)
  105526. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105527. * @param onSuccess a callback with the scene when import succeeds
  105528. * @param onProgress a callback with a progress event for each file being loaded
  105529. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105530. * @param pluginExtension the extension used to determine the plugin
  105531. * @returns The loaded plugin
  105532. */
  105533. 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>;
  105534. /**
  105535. * Load a scene into an asset container
  105536. * @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)
  105537. * @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)
  105538. * @param scene is the instance of Scene to append to
  105539. * @param onProgress a callback with a progress event for each file being loaded
  105540. * @param pluginExtension the extension used to determine the plugin
  105541. * @returns The loaded asset container
  105542. */
  105543. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105544. }
  105545. }
  105546. declare module BABYLON {
  105547. /**
  105548. * Generic Controller
  105549. */
  105550. export class GenericController extends WebVRController {
  105551. /**
  105552. * Base Url for the controller model.
  105553. */
  105554. static readonly MODEL_BASE_URL: string;
  105555. /**
  105556. * File name for the controller model.
  105557. */
  105558. static readonly MODEL_FILENAME: string;
  105559. /**
  105560. * Creates a new GenericController from a gamepad
  105561. * @param vrGamepad the gamepad that the controller should be created from
  105562. */
  105563. constructor(vrGamepad: any);
  105564. /**
  105565. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105566. * @param scene scene in which to add meshes
  105567. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105568. */
  105569. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105570. /**
  105571. * Called once for each button that changed state since the last frame
  105572. * @param buttonIdx Which button index changed
  105573. * @param state New state of the button
  105574. * @param changes Which properties on the state changed since last frame
  105575. */
  105576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105577. }
  105578. }
  105579. declare module BABYLON {
  105580. /**
  105581. * Defines the WindowsMotionController object that the state of the windows motion controller
  105582. */
  105583. export class WindowsMotionController extends WebVRController {
  105584. /**
  105585. * The base url used to load the left and right controller models
  105586. */
  105587. static MODEL_BASE_URL: string;
  105588. /**
  105589. * The name of the left controller model file
  105590. */
  105591. static MODEL_LEFT_FILENAME: string;
  105592. /**
  105593. * The name of the right controller model file
  105594. */
  105595. static MODEL_RIGHT_FILENAME: string;
  105596. /**
  105597. * The controller name prefix for this controller type
  105598. */
  105599. static readonly GAMEPAD_ID_PREFIX: string;
  105600. /**
  105601. * The controller id pattern for this controller type
  105602. */
  105603. private static readonly GAMEPAD_ID_PATTERN;
  105604. private _loadedMeshInfo;
  105605. private readonly _mapping;
  105606. /**
  105607. * Fired when the trackpad on this controller is clicked
  105608. */
  105609. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105610. /**
  105611. * Fired when the trackpad on this controller is modified
  105612. */
  105613. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105614. /**
  105615. * The current x and y values of this controller's trackpad
  105616. */
  105617. trackpad: StickValues;
  105618. /**
  105619. * Creates a new WindowsMotionController from a gamepad
  105620. * @param vrGamepad the gamepad that the controller should be created from
  105621. */
  105622. constructor(vrGamepad: any);
  105623. /**
  105624. * Fired when the trigger on this controller is modified
  105625. */
  105626. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105627. /**
  105628. * Fired when the menu button on this controller is modified
  105629. */
  105630. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105631. /**
  105632. * Fired when the grip button on this controller is modified
  105633. */
  105634. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105635. /**
  105636. * Fired when the thumbstick button on this controller is modified
  105637. */
  105638. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105639. /**
  105640. * Fired when the touchpad button on this controller is modified
  105641. */
  105642. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105643. /**
  105644. * Fired when the touchpad values on this controller are modified
  105645. */
  105646. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105647. private _updateTrackpad;
  105648. /**
  105649. * Called once per frame by the engine.
  105650. */
  105651. update(): void;
  105652. /**
  105653. * Called once for each button that changed state since the last frame
  105654. * @param buttonIdx Which button index changed
  105655. * @param state New state of the button
  105656. * @param changes Which properties on the state changed since last frame
  105657. */
  105658. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105659. /**
  105660. * Moves the buttons on the controller mesh based on their current state
  105661. * @param buttonName the name of the button to move
  105662. * @param buttonValue the value of the button which determines the buttons new position
  105663. */
  105664. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105665. /**
  105666. * Moves the axis on the controller mesh based on its current state
  105667. * @param axis the index of the axis
  105668. * @param axisValue the value of the axis which determines the meshes new position
  105669. * @hidden
  105670. */
  105671. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105672. /**
  105673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105674. * @param scene scene in which to add meshes
  105675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105676. */
  105677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105678. /**
  105679. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105680. * can be transformed by button presses and axes values, based on this._mapping.
  105681. *
  105682. * @param scene scene in which the meshes exist
  105683. * @param meshes list of meshes that make up the controller model to process
  105684. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105685. */
  105686. private processModel;
  105687. private createMeshInfo;
  105688. /**
  105689. * Gets the ray of the controller in the direction the controller is pointing
  105690. * @param length the length the resulting ray should be
  105691. * @returns a ray in the direction the controller is pointing
  105692. */
  105693. getForwardRay(length?: number): Ray;
  105694. /**
  105695. * Disposes of the controller
  105696. */
  105697. dispose(): void;
  105698. }
  105699. }
  105700. declare module BABYLON {
  105701. /**
  105702. * Oculus Touch Controller
  105703. */
  105704. export class OculusTouchController extends WebVRController {
  105705. /**
  105706. * Base Url for the controller model.
  105707. */
  105708. static MODEL_BASE_URL: string;
  105709. /**
  105710. * File name for the left controller model.
  105711. */
  105712. static MODEL_LEFT_FILENAME: string;
  105713. /**
  105714. * File name for the right controller model.
  105715. */
  105716. static MODEL_RIGHT_FILENAME: string;
  105717. /**
  105718. * Base Url for the Quest controller model.
  105719. */
  105720. static QUEST_MODEL_BASE_URL: string;
  105721. /**
  105722. * @hidden
  105723. * If the controllers are running on a device that needs the updated Quest controller models
  105724. */
  105725. static _IsQuest: boolean;
  105726. /**
  105727. * Fired when the secondary trigger on this controller is modified
  105728. */
  105729. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105730. /**
  105731. * Fired when the thumb rest on this controller is modified
  105732. */
  105733. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105734. /**
  105735. * Creates a new OculusTouchController from a gamepad
  105736. * @param vrGamepad the gamepad that the controller should be created from
  105737. */
  105738. constructor(vrGamepad: any);
  105739. /**
  105740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105741. * @param scene scene in which to add meshes
  105742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105743. */
  105744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105745. /**
  105746. * Fired when the A button on this controller is modified
  105747. */
  105748. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105749. /**
  105750. * Fired when the B button on this controller is modified
  105751. */
  105752. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105753. /**
  105754. * Fired when the X button on this controller is modified
  105755. */
  105756. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105757. /**
  105758. * Fired when the Y button on this controller is modified
  105759. */
  105760. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105761. /**
  105762. * Called once for each button that changed state since the last frame
  105763. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105764. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105765. * 2) secondary trigger (same)
  105766. * 3) A (right) X (left), touch, pressed = value
  105767. * 4) B / Y
  105768. * 5) thumb rest
  105769. * @param buttonIdx Which button index changed
  105770. * @param state New state of the button
  105771. * @param changes Which properties on the state changed since last frame
  105772. */
  105773. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105774. }
  105775. }
  105776. declare module BABYLON {
  105777. /**
  105778. * Vive Controller
  105779. */
  105780. export class ViveController extends WebVRController {
  105781. /**
  105782. * Base Url for the controller model.
  105783. */
  105784. static MODEL_BASE_URL: string;
  105785. /**
  105786. * File name for the controller model.
  105787. */
  105788. static MODEL_FILENAME: string;
  105789. /**
  105790. * Creates a new ViveController from a gamepad
  105791. * @param vrGamepad the gamepad that the controller should be created from
  105792. */
  105793. constructor(vrGamepad: any);
  105794. /**
  105795. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105796. * @param scene scene in which to add meshes
  105797. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105798. */
  105799. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105800. /**
  105801. * Fired when the left button on this controller is modified
  105802. */
  105803. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105804. /**
  105805. * Fired when the right button on this controller is modified
  105806. */
  105807. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105808. /**
  105809. * Fired when the menu button on this controller is modified
  105810. */
  105811. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105812. /**
  105813. * Called once for each button that changed state since the last frame
  105814. * Vive mapping:
  105815. * 0: touchpad
  105816. * 1: trigger
  105817. * 2: left AND right buttons
  105818. * 3: menu button
  105819. * @param buttonIdx Which button index changed
  105820. * @param state New state of the button
  105821. * @param changes Which properties on the state changed since last frame
  105822. */
  105823. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105824. }
  105825. }
  105826. declare module BABYLON {
  105827. /**
  105828. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  105829. */
  105830. export class WebXRControllerModelLoader {
  105831. /**
  105832. * Creates the WebXRControllerModelLoader
  105833. * @param input xr input that creates the controllers
  105834. */
  105835. constructor(input: WebXRInput);
  105836. }
  105837. }
  105838. declare module BABYLON {
  105839. /**
  105840. * Contains an array of blocks representing the octree
  105841. */
  105842. export interface IOctreeContainer<T> {
  105843. /**
  105844. * Blocks within the octree
  105845. */
  105846. blocks: Array<OctreeBlock<T>>;
  105847. }
  105848. /**
  105849. * Class used to store a cell in an octree
  105850. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105851. */
  105852. export class OctreeBlock<T> {
  105853. /**
  105854. * Gets the content of the current block
  105855. */
  105856. entries: T[];
  105857. /**
  105858. * Gets the list of block children
  105859. */
  105860. blocks: Array<OctreeBlock<T>>;
  105861. private _depth;
  105862. private _maxDepth;
  105863. private _capacity;
  105864. private _minPoint;
  105865. private _maxPoint;
  105866. private _boundingVectors;
  105867. private _creationFunc;
  105868. /**
  105869. * Creates a new block
  105870. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  105871. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  105872. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105873. * @param depth defines the current depth of this block in the octree
  105874. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  105875. * @param creationFunc defines a callback to call when an element is added to the block
  105876. */
  105877. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  105878. /**
  105879. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105880. */
  105881. readonly capacity: number;
  105882. /**
  105883. * Gets the minimum vector (in world space) of the block's bounding box
  105884. */
  105885. readonly minPoint: Vector3;
  105886. /**
  105887. * Gets the maximum vector (in world space) of the block's bounding box
  105888. */
  105889. readonly maxPoint: Vector3;
  105890. /**
  105891. * Add a new element to this block
  105892. * @param entry defines the element to add
  105893. */
  105894. addEntry(entry: T): void;
  105895. /**
  105896. * Remove an element from this block
  105897. * @param entry defines the element to remove
  105898. */
  105899. removeEntry(entry: T): void;
  105900. /**
  105901. * Add an array of elements to this block
  105902. * @param entries defines the array of elements to add
  105903. */
  105904. addEntries(entries: T[]): void;
  105905. /**
  105906. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  105907. * @param frustumPlanes defines the frustum planes to test
  105908. * @param selection defines the array to store current content if selection is positive
  105909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105910. */
  105911. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105912. /**
  105913. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105914. * @param sphereCenter defines the bounding sphere center
  105915. * @param sphereRadius defines the bounding sphere radius
  105916. * @param selection defines the array to store current content if selection is positive
  105917. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105918. */
  105919. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105920. /**
  105921. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105922. * @param ray defines the ray to test with
  105923. * @param selection defines the array to store current content if selection is positive
  105924. */
  105925. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105926. /**
  105927. * Subdivide the content into child blocks (this block will then be empty)
  105928. */
  105929. createInnerBlocks(): void;
  105930. /**
  105931. * @hidden
  105932. */
  105933. 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;
  105934. }
  105935. }
  105936. declare module BABYLON {
  105937. /**
  105938. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105940. */
  105941. export class Octree<T> {
  105942. /** 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.) */
  105943. maxDepth: number;
  105944. /**
  105945. * Blocks within the octree containing objects
  105946. */
  105947. blocks: Array<OctreeBlock<T>>;
  105948. /**
  105949. * Content stored in the octree
  105950. */
  105951. dynamicContent: T[];
  105952. private _maxBlockCapacity;
  105953. private _selectionContent;
  105954. private _creationFunc;
  105955. /**
  105956. * Creates a octree
  105957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105958. * @param creationFunc function to be used to instatiate the octree
  105959. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105960. * @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.)
  105961. */
  105962. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105963. /** 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.) */
  105964. maxDepth?: number);
  105965. /**
  105966. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105967. * @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);
  105968. * @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);
  105969. * @param entries meshes to be added to the octree blocks
  105970. */
  105971. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105972. /**
  105973. * Adds a mesh to the octree
  105974. * @param entry Mesh to add to the octree
  105975. */
  105976. addMesh(entry: T): void;
  105977. /**
  105978. * Remove an element from the octree
  105979. * @param entry defines the element to remove
  105980. */
  105981. removeMesh(entry: T): void;
  105982. /**
  105983. * Selects an array of meshes within the frustum
  105984. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105985. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105986. * @returns array of meshes within the frustum
  105987. */
  105988. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105989. /**
  105990. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105991. * @param sphereCenter defines the bounding sphere center
  105992. * @param sphereRadius defines the bounding sphere radius
  105993. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105994. * @returns an array of objects that intersect the sphere
  105995. */
  105996. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105997. /**
  105998. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105999. * @param ray defines the ray to test with
  106000. * @returns array of intersected objects
  106001. */
  106002. intersectsRay(ray: Ray): SmartArray<T>;
  106003. /**
  106004. * Adds a mesh into the octree block if it intersects the block
  106005. */
  106006. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  106007. /**
  106008. * Adds a submesh into the octree block if it intersects the block
  106009. */
  106010. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  106011. }
  106012. }
  106013. declare module BABYLON {
  106014. interface Scene {
  106015. /**
  106016. * @hidden
  106017. * Backing Filed
  106018. */
  106019. _selectionOctree: Octree<AbstractMesh>;
  106020. /**
  106021. * Gets the octree used to boost mesh selection (picking)
  106022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106023. */
  106024. selectionOctree: Octree<AbstractMesh>;
  106025. /**
  106026. * Creates or updates the octree used to boost selection (picking)
  106027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106028. * @param maxCapacity defines the maximum capacity per leaf
  106029. * @param maxDepth defines the maximum depth of the octree
  106030. * @returns an octree of AbstractMesh
  106031. */
  106032. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  106033. }
  106034. interface AbstractMesh {
  106035. /**
  106036. * @hidden
  106037. * Backing Field
  106038. */
  106039. _submeshesOctree: Octree<SubMesh>;
  106040. /**
  106041. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  106042. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106043. * @param maxCapacity defines the maximum size of each block (64 by default)
  106044. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  106045. * @returns the new octree
  106046. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  106047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106048. */
  106049. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  106050. }
  106051. /**
  106052. * Defines the octree scene component responsible to manage any octrees
  106053. * in a given scene.
  106054. */
  106055. export class OctreeSceneComponent {
  106056. /**
  106057. * The component name help to identify the component in the list of scene components.
  106058. */
  106059. readonly name: string;
  106060. /**
  106061. * The scene the component belongs to.
  106062. */
  106063. scene: Scene;
  106064. /**
  106065. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106066. */
  106067. readonly checksIsEnabled: boolean;
  106068. /**
  106069. * Creates a new instance of the component for the given scene
  106070. * @param scene Defines the scene to register the component in
  106071. */
  106072. constructor(scene: Scene);
  106073. /**
  106074. * Registers the component in a given scene
  106075. */
  106076. register(): void;
  106077. /**
  106078. * Return the list of active meshes
  106079. * @returns the list of active meshes
  106080. */
  106081. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106082. /**
  106083. * Return the list of active sub meshes
  106084. * @param mesh The mesh to get the candidates sub meshes from
  106085. * @returns the list of active sub meshes
  106086. */
  106087. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106088. private _tempRay;
  106089. /**
  106090. * Return the list of sub meshes intersecting with a given local ray
  106091. * @param mesh defines the mesh to find the submesh for
  106092. * @param localRay defines the ray in local space
  106093. * @returns the list of intersecting sub meshes
  106094. */
  106095. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106096. /**
  106097. * Return the list of sub meshes colliding with a collider
  106098. * @param mesh defines the mesh to find the submesh for
  106099. * @param collider defines the collider to evaluate the collision against
  106100. * @returns the list of colliding sub meshes
  106101. */
  106102. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106103. /**
  106104. * Rebuilds the elements related to this component in case of
  106105. * context lost for instance.
  106106. */
  106107. rebuild(): void;
  106108. /**
  106109. * Disposes the component and the associated ressources.
  106110. */
  106111. dispose(): void;
  106112. }
  106113. }
  106114. declare module BABYLON {
  106115. /**
  106116. * Renders a layer on top of an existing scene
  106117. */
  106118. export class UtilityLayerRenderer implements IDisposable {
  106119. /** the original scene that will be rendered on top of */
  106120. originalScene: Scene;
  106121. private _pointerCaptures;
  106122. private _lastPointerEvents;
  106123. private static _DefaultUtilityLayer;
  106124. private static _DefaultKeepDepthUtilityLayer;
  106125. private _sharedGizmoLight;
  106126. private _renderCamera;
  106127. /**
  106128. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106129. * @returns the camera that is used when rendering the utility layer
  106130. */
  106131. getRenderCamera(): Nullable<Camera>;
  106132. /**
  106133. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106134. * @param cam the camera that should be used when rendering the utility layer
  106135. */
  106136. setRenderCamera(cam: Nullable<Camera>): void;
  106137. /**
  106138. * @hidden
  106139. * Light which used by gizmos to get light shading
  106140. */
  106141. _getSharedGizmoLight(): HemisphericLight;
  106142. /**
  106143. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106144. */
  106145. pickUtilitySceneFirst: boolean;
  106146. /**
  106147. * 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)
  106148. */
  106149. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106150. /**
  106151. * 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)
  106152. */
  106153. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106154. /**
  106155. * The scene that is rendered on top of the original scene
  106156. */
  106157. utilityLayerScene: Scene;
  106158. /**
  106159. * If the utility layer should automatically be rendered on top of existing scene
  106160. */
  106161. shouldRender: boolean;
  106162. /**
  106163. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106164. */
  106165. onlyCheckPointerDownEvents: boolean;
  106166. /**
  106167. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  106168. */
  106169. processAllEvents: boolean;
  106170. /**
  106171. * Observable raised when the pointer move from the utility layer scene to the main scene
  106172. */
  106173. onPointerOutObservable: Observable<number>;
  106174. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  106175. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  106176. private _afterRenderObserver;
  106177. private _sceneDisposeObserver;
  106178. private _originalPointerObserver;
  106179. /**
  106180. * Instantiates a UtilityLayerRenderer
  106181. * @param originalScene the original scene that will be rendered on top of
  106182. * @param handleEvents boolean indicating if the utility layer should handle events
  106183. */
  106184. constructor(
  106185. /** the original scene that will be rendered on top of */
  106186. originalScene: Scene, handleEvents?: boolean);
  106187. private _notifyObservers;
  106188. /**
  106189. * Renders the utility layers scene on top of the original scene
  106190. */
  106191. render(): void;
  106192. /**
  106193. * Disposes of the renderer
  106194. */
  106195. dispose(): void;
  106196. private _updateCamera;
  106197. }
  106198. }
  106199. declare module BABYLON {
  106200. /**
  106201. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  106202. */
  106203. export class Gizmo implements IDisposable {
  106204. /** The utility layer the gizmo will be added to */
  106205. gizmoLayer: UtilityLayerRenderer;
  106206. /**
  106207. * The root mesh of the gizmo
  106208. */
  106209. _rootMesh: Mesh;
  106210. private _attachedMesh;
  106211. /**
  106212. * Ratio for the scale of the gizmo (Default: 1)
  106213. */
  106214. scaleRatio: number;
  106215. /**
  106216. * If a custom mesh has been set (Default: false)
  106217. */
  106218. protected _customMeshSet: boolean;
  106219. /**
  106220. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  106221. * * When set, interactions will be enabled
  106222. */
  106223. attachedMesh: Nullable<AbstractMesh>;
  106224. /**
  106225. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106226. * @param mesh The mesh to replace the default mesh of the gizmo
  106227. */
  106228. setCustomMesh(mesh: Mesh): void;
  106229. /**
  106230. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  106231. */
  106232. updateGizmoRotationToMatchAttachedMesh: boolean;
  106233. /**
  106234. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  106235. */
  106236. updateGizmoPositionToMatchAttachedMesh: boolean;
  106237. /**
  106238. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  106239. */
  106240. updateScale: boolean;
  106241. protected _interactionsEnabled: boolean;
  106242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106243. private _beforeRenderObserver;
  106244. private _tempVector;
  106245. /**
  106246. * Creates a gizmo
  106247. * @param gizmoLayer The utility layer the gizmo will be added to
  106248. */
  106249. constructor(
  106250. /** The utility layer the gizmo will be added to */
  106251. gizmoLayer?: UtilityLayerRenderer);
  106252. /**
  106253. * Updates the gizmo to match the attached mesh's position/rotation
  106254. */
  106255. protected _update(): void;
  106256. /**
  106257. * Disposes of the gizmo
  106258. */
  106259. dispose(): void;
  106260. }
  106261. }
  106262. declare module BABYLON {
  106263. /**
  106264. * Single plane drag gizmo
  106265. */
  106266. export class PlaneDragGizmo extends Gizmo {
  106267. /**
  106268. * Drag behavior responsible for the gizmos dragging interactions
  106269. */
  106270. dragBehavior: PointerDragBehavior;
  106271. private _pointerObserver;
  106272. /**
  106273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106274. */
  106275. snapDistance: number;
  106276. /**
  106277. * Event that fires each time the gizmo snaps to a new location.
  106278. * * snapDistance is the the change in distance
  106279. */
  106280. onSnapObservable: Observable<{
  106281. snapDistance: number;
  106282. }>;
  106283. private _plane;
  106284. private _coloredMaterial;
  106285. private _hoverMaterial;
  106286. private _isEnabled;
  106287. private _parent;
  106288. /** @hidden */
  106289. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106290. /** @hidden */
  106291. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106292. /**
  106293. * Creates a PlaneDragGizmo
  106294. * @param gizmoLayer The utility layer the gizmo will be added to
  106295. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106296. * @param color The color of the gizmo
  106297. */
  106298. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106299. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106300. /**
  106301. * If the gizmo is enabled
  106302. */
  106303. isEnabled: boolean;
  106304. /**
  106305. * Disposes of the gizmo
  106306. */
  106307. dispose(): void;
  106308. }
  106309. }
  106310. declare module BABYLON {
  106311. /**
  106312. * Gizmo that enables dragging a mesh along 3 axis
  106313. */
  106314. export class PositionGizmo extends Gizmo {
  106315. /**
  106316. * Internal gizmo used for interactions on the x axis
  106317. */
  106318. xGizmo: AxisDragGizmo;
  106319. /**
  106320. * Internal gizmo used for interactions on the y axis
  106321. */
  106322. yGizmo: AxisDragGizmo;
  106323. /**
  106324. * Internal gizmo used for interactions on the z axis
  106325. */
  106326. zGizmo: AxisDragGizmo;
  106327. /**
  106328. * Internal gizmo used for interactions on the yz plane
  106329. */
  106330. xPlaneGizmo: PlaneDragGizmo;
  106331. /**
  106332. * Internal gizmo used for interactions on the xz plane
  106333. */
  106334. yPlaneGizmo: PlaneDragGizmo;
  106335. /**
  106336. * Internal gizmo used for interactions on the xy plane
  106337. */
  106338. zPlaneGizmo: PlaneDragGizmo;
  106339. /**
  106340. * private variables
  106341. */
  106342. private _meshAttached;
  106343. private _updateGizmoRotationToMatchAttachedMesh;
  106344. private _snapDistance;
  106345. private _scaleRatio;
  106346. /** Fires an event when any of it's sub gizmos are dragged */
  106347. onDragStartObservable: Observable<unknown>;
  106348. /** Fires an event when any of it's sub gizmos are released from dragging */
  106349. onDragEndObservable: Observable<unknown>;
  106350. /**
  106351. * If set to true, planar drag is enabled
  106352. */
  106353. private _planarGizmoEnabled;
  106354. attachedMesh: Nullable<AbstractMesh>;
  106355. /**
  106356. * Creates a PositionGizmo
  106357. * @param gizmoLayer The utility layer the gizmo will be added to
  106358. */
  106359. constructor(gizmoLayer?: UtilityLayerRenderer);
  106360. /**
  106361. * If the planar drag gizmo is enabled
  106362. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106363. */
  106364. planarGizmoEnabled: boolean;
  106365. updateGizmoRotationToMatchAttachedMesh: boolean;
  106366. /**
  106367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106368. */
  106369. snapDistance: number;
  106370. /**
  106371. * Ratio for the scale of the gizmo (Default: 1)
  106372. */
  106373. scaleRatio: number;
  106374. /**
  106375. * Disposes of the gizmo
  106376. */
  106377. dispose(): void;
  106378. /**
  106379. * CustomMeshes are not supported by this gizmo
  106380. * @param mesh The mesh to replace the default mesh of the gizmo
  106381. */
  106382. setCustomMesh(mesh: Mesh): void;
  106383. }
  106384. }
  106385. declare module BABYLON {
  106386. /**
  106387. * Single axis drag gizmo
  106388. */
  106389. export class AxisDragGizmo extends Gizmo {
  106390. /**
  106391. * Drag behavior responsible for the gizmos dragging interactions
  106392. */
  106393. dragBehavior: PointerDragBehavior;
  106394. private _pointerObserver;
  106395. /**
  106396. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106397. */
  106398. snapDistance: number;
  106399. /**
  106400. * Event that fires each time the gizmo snaps to a new location.
  106401. * * snapDistance is the the change in distance
  106402. */
  106403. onSnapObservable: Observable<{
  106404. snapDistance: number;
  106405. }>;
  106406. private _isEnabled;
  106407. private _parent;
  106408. private _arrow;
  106409. private _coloredMaterial;
  106410. private _hoverMaterial;
  106411. /** @hidden */
  106412. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106413. /** @hidden */
  106414. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106415. /**
  106416. * Creates an AxisDragGizmo
  106417. * @param gizmoLayer The utility layer the gizmo will be added to
  106418. * @param dragAxis The axis which the gizmo will be able to drag on
  106419. * @param color The color of the gizmo
  106420. */
  106421. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106423. /**
  106424. * If the gizmo is enabled
  106425. */
  106426. isEnabled: boolean;
  106427. /**
  106428. * Disposes of the gizmo
  106429. */
  106430. dispose(): void;
  106431. }
  106432. }
  106433. declare module BABYLON.Debug {
  106434. /**
  106435. * The Axes viewer will show 3 axes in a specific point in space
  106436. */
  106437. export class AxesViewer {
  106438. private _xAxis;
  106439. private _yAxis;
  106440. private _zAxis;
  106441. private _scaleLinesFactor;
  106442. private _instanced;
  106443. /**
  106444. * Gets the hosting scene
  106445. */
  106446. scene: Scene;
  106447. /**
  106448. * Gets or sets a number used to scale line length
  106449. */
  106450. scaleLines: number;
  106451. /** Gets the node hierarchy used to render x-axis */
  106452. readonly xAxis: TransformNode;
  106453. /** Gets the node hierarchy used to render y-axis */
  106454. readonly yAxis: TransformNode;
  106455. /** Gets the node hierarchy used to render z-axis */
  106456. readonly zAxis: TransformNode;
  106457. /**
  106458. * Creates a new AxesViewer
  106459. * @param scene defines the hosting scene
  106460. * @param scaleLines defines a number used to scale line length (1 by default)
  106461. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106462. * @param xAxis defines the node hierarchy used to render the x-axis
  106463. * @param yAxis defines the node hierarchy used to render the y-axis
  106464. * @param zAxis defines the node hierarchy used to render the z-axis
  106465. */
  106466. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106467. /**
  106468. * Force the viewer to update
  106469. * @param position defines the position of the viewer
  106470. * @param xaxis defines the x axis of the viewer
  106471. * @param yaxis defines the y axis of the viewer
  106472. * @param zaxis defines the z axis of the viewer
  106473. */
  106474. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106475. /**
  106476. * Creates an instance of this axes viewer.
  106477. * @returns a new axes viewer with instanced meshes
  106478. */
  106479. createInstance(): AxesViewer;
  106480. /** Releases resources */
  106481. dispose(): void;
  106482. private static _SetRenderingGroupId;
  106483. }
  106484. }
  106485. declare module BABYLON.Debug {
  106486. /**
  106487. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106488. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106489. */
  106490. export class BoneAxesViewer extends AxesViewer {
  106491. /**
  106492. * Gets or sets the target mesh where to display the axes viewer
  106493. */
  106494. mesh: Nullable<Mesh>;
  106495. /**
  106496. * Gets or sets the target bone where to display the axes viewer
  106497. */
  106498. bone: Nullable<Bone>;
  106499. /** Gets current position */
  106500. pos: Vector3;
  106501. /** Gets direction of X axis */
  106502. xaxis: Vector3;
  106503. /** Gets direction of Y axis */
  106504. yaxis: Vector3;
  106505. /** Gets direction of Z axis */
  106506. zaxis: Vector3;
  106507. /**
  106508. * Creates a new BoneAxesViewer
  106509. * @param scene defines the hosting scene
  106510. * @param bone defines the target bone
  106511. * @param mesh defines the target mesh
  106512. * @param scaleLines defines a scaling factor for line length (1 by default)
  106513. */
  106514. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106515. /**
  106516. * Force the viewer to update
  106517. */
  106518. update(): void;
  106519. /** Releases resources */
  106520. dispose(): void;
  106521. }
  106522. }
  106523. declare module BABYLON {
  106524. /**
  106525. * Interface used to define scene explorer extensibility option
  106526. */
  106527. export interface IExplorerExtensibilityOption {
  106528. /**
  106529. * Define the option label
  106530. */
  106531. label: string;
  106532. /**
  106533. * Defines the action to execute on click
  106534. */
  106535. action: (entity: any) => void;
  106536. }
  106537. /**
  106538. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  106539. */
  106540. export interface IExplorerExtensibilityGroup {
  106541. /**
  106542. * Defines a predicate to test if a given type mut be extended
  106543. */
  106544. predicate: (entity: any) => boolean;
  106545. /**
  106546. * Gets the list of options added to a type
  106547. */
  106548. entries: IExplorerExtensibilityOption[];
  106549. }
  106550. /**
  106551. * Interface used to define the options to use to create the Inspector
  106552. */
  106553. export interface IInspectorOptions {
  106554. /**
  106555. * Display in overlay mode (default: false)
  106556. */
  106557. overlay?: boolean;
  106558. /**
  106559. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  106560. */
  106561. globalRoot?: HTMLElement;
  106562. /**
  106563. * Display the Scene explorer
  106564. */
  106565. showExplorer?: boolean;
  106566. /**
  106567. * Display the property inspector
  106568. */
  106569. showInspector?: boolean;
  106570. /**
  106571. * Display in embed mode (both panes on the right)
  106572. */
  106573. embedMode?: boolean;
  106574. /**
  106575. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106576. */
  106577. handleResize?: boolean;
  106578. /**
  106579. * Allow the panes to popup (default: true)
  106580. */
  106581. enablePopup?: boolean;
  106582. /**
  106583. * Allow the panes to be closed by users (default: true)
  106584. */
  106585. enableClose?: boolean;
  106586. /**
  106587. * Optional list of extensibility entries
  106588. */
  106589. explorerExtensibility?: IExplorerExtensibilityGroup[];
  106590. /**
  106591. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  106592. */
  106593. inspectorURL?: string;
  106594. }
  106595. interface Scene {
  106596. /**
  106597. * @hidden
  106598. * Backing field
  106599. */
  106600. _debugLayer: DebugLayer;
  106601. /**
  106602. * Gets the debug layer (aka Inspector) associated with the scene
  106603. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106604. */
  106605. debugLayer: DebugLayer;
  106606. }
  106607. /**
  106608. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106609. * what is happening in your scene
  106610. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106611. */
  106612. export class DebugLayer {
  106613. /**
  106614. * Define the url to get the inspector script from.
  106615. * By default it uses the babylonjs CDN.
  106616. * @ignoreNaming
  106617. */
  106618. static InspectorURL: string;
  106619. private _scene;
  106620. private BJSINSPECTOR;
  106621. private _onPropertyChangedObservable?;
  106622. /**
  106623. * Observable triggered when a property is changed through the inspector.
  106624. */
  106625. readonly onPropertyChangedObservable: any;
  106626. /**
  106627. * Instantiates a new debug layer.
  106628. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106629. * what is happening in your scene
  106630. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106631. * @param scene Defines the scene to inspect
  106632. */
  106633. constructor(scene: Scene);
  106634. /** Creates the inspector window. */
  106635. private _createInspector;
  106636. /**
  106637. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  106638. * @param entity defines the entity to select
  106639. * @param lineContainerTitle defines the specific block to highlight
  106640. */
  106641. select(entity: any, lineContainerTitle?: string): void;
  106642. /** Get the inspector from bundle or global */
  106643. private _getGlobalInspector;
  106644. /**
  106645. * Get if the inspector is visible or not.
  106646. * @returns true if visible otherwise, false
  106647. */
  106648. isVisible(): boolean;
  106649. /**
  106650. * Hide the inspector and close its window.
  106651. */
  106652. hide(): void;
  106653. /**
  106654. * Launch the debugLayer.
  106655. * @param config Define the configuration of the inspector
  106656. * @return a promise fulfilled when the debug layer is visible
  106657. */
  106658. show(config?: IInspectorOptions): Promise<DebugLayer>;
  106659. }
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * Class containing static functions to help procedurally build meshes
  106664. */
  106665. export class BoxBuilder {
  106666. /**
  106667. * Creates a box mesh
  106668. * * The parameter `size` sets the size (float) of each box side (default 1)
  106669. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106670. * * 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)
  106671. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106675. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106676. * @param name defines the name of the mesh
  106677. * @param options defines the options used to create the mesh
  106678. * @param scene defines the hosting scene
  106679. * @returns the box mesh
  106680. */
  106681. static CreateBox(name: string, options: {
  106682. size?: number;
  106683. width?: number;
  106684. height?: number;
  106685. depth?: number;
  106686. faceUV?: Vector4[];
  106687. faceColors?: Color4[];
  106688. sideOrientation?: number;
  106689. frontUVs?: Vector4;
  106690. backUVs?: Vector4;
  106691. wrap?: boolean;
  106692. topBaseAt?: number;
  106693. bottomBaseAt?: number;
  106694. updatable?: boolean;
  106695. }, scene?: Nullable<Scene>): Mesh;
  106696. }
  106697. }
  106698. declare module BABYLON {
  106699. /**
  106700. * Class containing static functions to help procedurally build meshes
  106701. */
  106702. export class SphereBuilder {
  106703. /**
  106704. * Creates a sphere mesh
  106705. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106706. * * 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`)
  106707. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106708. * * 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
  106709. * * 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)
  106710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106713. * @param name defines the name of the mesh
  106714. * @param options defines the options used to create the mesh
  106715. * @param scene defines the hosting scene
  106716. * @returns the sphere mesh
  106717. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106718. */
  106719. static CreateSphere(name: string, options: {
  106720. segments?: number;
  106721. diameter?: number;
  106722. diameterX?: number;
  106723. diameterY?: number;
  106724. diameterZ?: number;
  106725. arc?: number;
  106726. slice?: number;
  106727. sideOrientation?: number;
  106728. frontUVs?: Vector4;
  106729. backUVs?: Vector4;
  106730. updatable?: boolean;
  106731. }, scene: any): Mesh;
  106732. }
  106733. }
  106734. declare module BABYLON.Debug {
  106735. /**
  106736. * Used to show the physics impostor around the specific mesh
  106737. */
  106738. export class PhysicsViewer {
  106739. /** @hidden */
  106740. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  106741. /** @hidden */
  106742. protected _meshes: Array<Nullable<AbstractMesh>>;
  106743. /** @hidden */
  106744. protected _scene: Nullable<Scene>;
  106745. /** @hidden */
  106746. protected _numMeshes: number;
  106747. /** @hidden */
  106748. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  106749. private _renderFunction;
  106750. private _utilityLayer;
  106751. private _debugBoxMesh;
  106752. private _debugSphereMesh;
  106753. private _debugCylinderMesh;
  106754. private _debugMaterial;
  106755. private _debugMeshMeshes;
  106756. /**
  106757. * Creates a new PhysicsViewer
  106758. * @param scene defines the hosting scene
  106759. */
  106760. constructor(scene: Scene);
  106761. /** @hidden */
  106762. protected _updateDebugMeshes(): void;
  106763. /**
  106764. * Renders a specified physic impostor
  106765. * @param impostor defines the impostor to render
  106766. * @param targetMesh defines the mesh represented by the impostor
  106767. * @returns the new debug mesh used to render the impostor
  106768. */
  106769. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  106770. /**
  106771. * Hides a specified physic impostor
  106772. * @param impostor defines the impostor to hide
  106773. */
  106774. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  106775. private _getDebugMaterial;
  106776. private _getDebugBoxMesh;
  106777. private _getDebugSphereMesh;
  106778. private _getDebugCylinderMesh;
  106779. private _getDebugMeshMesh;
  106780. private _getDebugMesh;
  106781. /** Releases all resources */
  106782. dispose(): void;
  106783. }
  106784. }
  106785. declare module BABYLON {
  106786. /**
  106787. * Class containing static functions to help procedurally build meshes
  106788. */
  106789. export class LinesBuilder {
  106790. /**
  106791. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106792. * * 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
  106793. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106794. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106795. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106796. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106797. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106798. * * 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
  106799. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106801. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106802. * @param name defines the name of the new line system
  106803. * @param options defines the options used to create the line system
  106804. * @param scene defines the hosting scene
  106805. * @returns a new line system mesh
  106806. */
  106807. static CreateLineSystem(name: string, options: {
  106808. lines: Vector3[][];
  106809. updatable?: boolean;
  106810. instance?: Nullable<LinesMesh>;
  106811. colors?: Nullable<Color4[][]>;
  106812. useVertexAlpha?: boolean;
  106813. }, scene: Nullable<Scene>): LinesMesh;
  106814. /**
  106815. * Creates a line mesh
  106816. * 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
  106817. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106818. * * The parameter `points` is an array successive Vector3
  106819. * * 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
  106820. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106821. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106822. * * When updating an instance, remember that only point positions can change, not the number of points
  106823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106825. * @param name defines the name of the new line system
  106826. * @param options defines the options used to create the line system
  106827. * @param scene defines the hosting scene
  106828. * @returns a new line mesh
  106829. */
  106830. static CreateLines(name: string, options: {
  106831. points: Vector3[];
  106832. updatable?: boolean;
  106833. instance?: Nullable<LinesMesh>;
  106834. colors?: Color4[];
  106835. useVertexAlpha?: boolean;
  106836. }, scene?: Nullable<Scene>): LinesMesh;
  106837. /**
  106838. * Creates a dashed line mesh
  106839. * * 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
  106840. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106841. * * The parameter `points` is an array successive Vector3
  106842. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106843. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106844. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106845. * * 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
  106846. * * When updating an instance, remember that only point positions can change, not the number of points
  106847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106848. * @param name defines the name of the mesh
  106849. * @param options defines the options used to create the mesh
  106850. * @param scene defines the hosting scene
  106851. * @returns the dashed line mesh
  106852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106853. */
  106854. static CreateDashedLines(name: string, options: {
  106855. points: Vector3[];
  106856. dashSize?: number;
  106857. gapSize?: number;
  106858. dashNb?: number;
  106859. updatable?: boolean;
  106860. instance?: LinesMesh;
  106861. }, scene?: Nullable<Scene>): LinesMesh;
  106862. }
  106863. }
  106864. declare module BABYLON {
  106865. /**
  106866. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106867. * in order to better appreciate the issue one might have.
  106868. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106869. */
  106870. export class RayHelper {
  106871. /**
  106872. * Defines the ray we are currently tryin to visualize.
  106873. */
  106874. ray: Nullable<Ray>;
  106875. private _renderPoints;
  106876. private _renderLine;
  106877. private _renderFunction;
  106878. private _scene;
  106879. private _updateToMeshFunction;
  106880. private _attachedToMesh;
  106881. private _meshSpaceDirection;
  106882. private _meshSpaceOrigin;
  106883. /**
  106884. * Helper function to create a colored helper in a scene in one line.
  106885. * @param ray Defines the ray we are currently tryin to visualize
  106886. * @param scene Defines the scene the ray is used in
  106887. * @param color Defines the color we want to see the ray in
  106888. * @returns The newly created ray helper.
  106889. */
  106890. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  106891. /**
  106892. * Instantiate a new ray helper.
  106893. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106894. * in order to better appreciate the issue one might have.
  106895. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106896. * @param ray Defines the ray we are currently tryin to visualize
  106897. */
  106898. constructor(ray: Ray);
  106899. /**
  106900. * Shows the ray we are willing to debug.
  106901. * @param scene Defines the scene the ray needs to be rendered in
  106902. * @param color Defines the color the ray needs to be rendered in
  106903. */
  106904. show(scene: Scene, color?: Color3): void;
  106905. /**
  106906. * Hides the ray we are debugging.
  106907. */
  106908. hide(): void;
  106909. private _render;
  106910. /**
  106911. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106912. * @param mesh Defines the mesh we want the helper attached to
  106913. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106914. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106915. * @param length Defines the length of the ray
  106916. */
  106917. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106918. /**
  106919. * Detach the ray helper from the mesh it has previously been attached to.
  106920. */
  106921. detachFromMesh(): void;
  106922. private _updateToMesh;
  106923. /**
  106924. * Dispose the helper and release its associated resources.
  106925. */
  106926. dispose(): void;
  106927. }
  106928. }
  106929. declare module BABYLON.Debug {
  106930. /**
  106931. * Class used to render a debug view of a given skeleton
  106932. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106933. */
  106934. export class SkeletonViewer {
  106935. /** defines the skeleton to render */
  106936. skeleton: Skeleton;
  106937. /** defines the mesh attached to the skeleton */
  106938. mesh: AbstractMesh;
  106939. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106940. autoUpdateBonesMatrices: boolean;
  106941. /** defines the rendering group id to use with the viewer */
  106942. renderingGroupId: number;
  106943. /** Gets or sets the color used to render the skeleton */
  106944. color: Color3;
  106945. private _scene;
  106946. private _debugLines;
  106947. private _debugMesh;
  106948. private _isEnabled;
  106949. private _renderFunction;
  106950. private _utilityLayer;
  106951. /**
  106952. * Returns the mesh used to render the bones
  106953. */
  106954. readonly debugMesh: Nullable<LinesMesh>;
  106955. /**
  106956. * Creates a new SkeletonViewer
  106957. * @param skeleton defines the skeleton to render
  106958. * @param mesh defines the mesh attached to the skeleton
  106959. * @param scene defines the hosting scene
  106960. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106961. * @param renderingGroupId defines the rendering group id to use with the viewer
  106962. */
  106963. constructor(
  106964. /** defines the skeleton to render */
  106965. skeleton: Skeleton,
  106966. /** defines the mesh attached to the skeleton */
  106967. mesh: AbstractMesh, scene: Scene,
  106968. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106969. autoUpdateBonesMatrices?: boolean,
  106970. /** defines the rendering group id to use with the viewer */
  106971. renderingGroupId?: number);
  106972. /** Gets or sets a boolean indicating if the viewer is enabled */
  106973. isEnabled: boolean;
  106974. private _getBonePosition;
  106975. private _getLinesForBonesWithLength;
  106976. private _getLinesForBonesNoLength;
  106977. /** Update the viewer to sync with current skeleton state */
  106978. update(): void;
  106979. /** Release associated resources */
  106980. dispose(): void;
  106981. }
  106982. }
  106983. declare module BABYLON {
  106984. /**
  106985. * Options to create the null engine
  106986. */
  106987. export class NullEngineOptions {
  106988. /**
  106989. * Render width (Default: 512)
  106990. */
  106991. renderWidth: number;
  106992. /**
  106993. * Render height (Default: 256)
  106994. */
  106995. renderHeight: number;
  106996. /**
  106997. * Texture size (Default: 512)
  106998. */
  106999. textureSize: number;
  107000. /**
  107001. * If delta time between frames should be constant
  107002. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107003. */
  107004. deterministicLockstep: boolean;
  107005. /**
  107006. * Maximum about of steps between frames (Default: 4)
  107007. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107008. */
  107009. lockstepMaxSteps: number;
  107010. }
  107011. /**
  107012. * The null engine class provides support for headless version of babylon.js.
  107013. * This can be used in server side scenario or for testing purposes
  107014. */
  107015. export class NullEngine extends Engine {
  107016. private _options;
  107017. /**
  107018. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107019. */
  107020. isDeterministicLockStep(): boolean;
  107021. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  107022. getLockstepMaxSteps(): number;
  107023. /**
  107024. * Sets hardware scaling, used to save performance if needed
  107025. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  107026. */
  107027. getHardwareScalingLevel(): number;
  107028. constructor(options?: NullEngineOptions);
  107029. createVertexBuffer(vertices: FloatArray): DataBuffer;
  107030. createIndexBuffer(indices: IndicesArray): DataBuffer;
  107031. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107032. getRenderWidth(useScreen?: boolean): number;
  107033. getRenderHeight(useScreen?: boolean): number;
  107034. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107035. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  107036. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107037. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107038. bindSamplers(effect: Effect): void;
  107039. enableEffect(effect: Effect): void;
  107040. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107041. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  107042. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  107043. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  107044. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  107045. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  107046. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  107047. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  107048. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  107049. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  107050. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  107051. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  107052. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  107053. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107054. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107055. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107056. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107057. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107058. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107059. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107060. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107062. bindBuffers(vertexBuffers: {
  107063. [key: string]: VertexBuffer;
  107064. }, indexBuffer: DataBuffer, effect: Effect): void;
  107065. wipeCaches(bruteForce?: boolean): void;
  107066. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107067. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107068. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107069. /** @hidden */
  107070. _createTexture(): WebGLTexture;
  107071. /** @hidden */
  107072. _releaseTexture(texture: InternalTexture): void;
  107073. 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;
  107074. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107075. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107076. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107077. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107078. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107079. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107080. areAllEffectsReady(): boolean;
  107081. /**
  107082. * @hidden
  107083. * Get the current error code of the webGL context
  107084. * @returns the error code
  107085. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107086. */
  107087. getError(): number;
  107088. /** @hidden */
  107089. _getUnpackAlignement(): number;
  107090. /** @hidden */
  107091. _unpackFlipY(value: boolean): void;
  107092. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107093. /**
  107094. * Updates a dynamic vertex buffer.
  107095. * @param vertexBuffer the vertex buffer to update
  107096. * @param data the data used to update the vertex buffer
  107097. * @param byteOffset the byte offset of the data (optional)
  107098. * @param byteLength the byte length of the data (optional)
  107099. */
  107100. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107101. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107102. /** @hidden */
  107103. _bindTexture(channel: number, texture: InternalTexture): void;
  107104. /** @hidden */
  107105. _releaseBuffer(buffer: DataBuffer): boolean;
  107106. releaseEffects(): void;
  107107. displayLoadingUI(): void;
  107108. hideLoadingUI(): void;
  107109. /** @hidden */
  107110. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107111. /** @hidden */
  107112. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107113. /** @hidden */
  107114. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107115. /** @hidden */
  107116. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107117. }
  107118. }
  107119. declare module BABYLON {
  107120. /** @hidden */
  107121. export class _OcclusionDataStorage {
  107122. /** @hidden */
  107123. occlusionInternalRetryCounter: number;
  107124. /** @hidden */
  107125. isOcclusionQueryInProgress: boolean;
  107126. /** @hidden */
  107127. isOccluded: boolean;
  107128. /** @hidden */
  107129. occlusionRetryCount: number;
  107130. /** @hidden */
  107131. occlusionType: number;
  107132. /** @hidden */
  107133. occlusionQueryAlgorithmType: number;
  107134. }
  107135. interface Engine {
  107136. /**
  107137. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107138. * @return the new query
  107139. */
  107140. createQuery(): WebGLQuery;
  107141. /**
  107142. * Delete and release a webGL query
  107143. * @param query defines the query to delete
  107144. * @return the current engine
  107145. */
  107146. deleteQuery(query: WebGLQuery): Engine;
  107147. /**
  107148. * Check if a given query has resolved and got its value
  107149. * @param query defines the query to check
  107150. * @returns true if the query got its value
  107151. */
  107152. isQueryResultAvailable(query: WebGLQuery): boolean;
  107153. /**
  107154. * Gets the value of a given query
  107155. * @param query defines the query to check
  107156. * @returns the value of the query
  107157. */
  107158. getQueryResult(query: WebGLQuery): number;
  107159. /**
  107160. * Initiates an occlusion query
  107161. * @param algorithmType defines the algorithm to use
  107162. * @param query defines the query to use
  107163. * @returns the current engine
  107164. * @see http://doc.babylonjs.com/features/occlusionquery
  107165. */
  107166. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107167. /**
  107168. * Ends an occlusion query
  107169. * @see http://doc.babylonjs.com/features/occlusionquery
  107170. * @param algorithmType defines the algorithm to use
  107171. * @returns the current engine
  107172. */
  107173. endOcclusionQuery(algorithmType: number): Engine;
  107174. /**
  107175. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  107176. * Please note that only one query can be issued at a time
  107177. * @returns a time token used to track the time span
  107178. */
  107179. startTimeQuery(): Nullable<_TimeToken>;
  107180. /**
  107181. * Ends a time query
  107182. * @param token defines the token used to measure the time span
  107183. * @returns the time spent (in ns)
  107184. */
  107185. endTimeQuery(token: _TimeToken): int;
  107186. /** @hidden */
  107187. _currentNonTimestampToken: Nullable<_TimeToken>;
  107188. /** @hidden */
  107189. _createTimeQuery(): WebGLQuery;
  107190. /** @hidden */
  107191. _deleteTimeQuery(query: WebGLQuery): void;
  107192. /** @hidden */
  107193. _getGlAlgorithmType(algorithmType: number): number;
  107194. /** @hidden */
  107195. _getTimeQueryResult(query: WebGLQuery): any;
  107196. /** @hidden */
  107197. _getTimeQueryAvailability(query: WebGLQuery): any;
  107198. }
  107199. interface AbstractMesh {
  107200. /**
  107201. * Backing filed
  107202. * @hidden
  107203. */
  107204. __occlusionDataStorage: _OcclusionDataStorage;
  107205. /**
  107206. * Access property
  107207. * @hidden
  107208. */
  107209. _occlusionDataStorage: _OcclusionDataStorage;
  107210. /**
  107211. * 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.
  107212. * The default value is -1 which means don't break the query and wait till the result
  107213. * @see http://doc.babylonjs.com/features/occlusionquery
  107214. */
  107215. occlusionRetryCount: number;
  107216. /**
  107217. * 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:
  107218. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  107219. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  107220. * * 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.
  107221. * @see http://doc.babylonjs.com/features/occlusionquery
  107222. */
  107223. occlusionType: number;
  107224. /**
  107225. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  107226. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  107227. * * 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.
  107228. * @see http://doc.babylonjs.com/features/occlusionquery
  107229. */
  107230. occlusionQueryAlgorithmType: number;
  107231. /**
  107232. * 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
  107233. * @see http://doc.babylonjs.com/features/occlusionquery
  107234. */
  107235. isOccluded: boolean;
  107236. /**
  107237. * Flag to check the progress status of the query
  107238. * @see http://doc.babylonjs.com/features/occlusionquery
  107239. */
  107240. isOcclusionQueryInProgress: boolean;
  107241. }
  107242. }
  107243. declare module BABYLON {
  107244. /** @hidden */
  107245. export var _forceTransformFeedbackToBundle: boolean;
  107246. interface Engine {
  107247. /**
  107248. * Creates a webGL transform feedback object
  107249. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107250. * @returns the webGL transform feedback object
  107251. */
  107252. createTransformFeedback(): WebGLTransformFeedback;
  107253. /**
  107254. * Delete a webGL transform feedback object
  107255. * @param value defines the webGL transform feedback object to delete
  107256. */
  107257. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107258. /**
  107259. * Bind a webGL transform feedback object to the webgl context
  107260. * @param value defines the webGL transform feedback object to bind
  107261. */
  107262. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107263. /**
  107264. * Begins a transform feedback operation
  107265. * @param usePoints defines if points or triangles must be used
  107266. */
  107267. beginTransformFeedback(usePoints: boolean): void;
  107268. /**
  107269. * Ends a transform feedback operation
  107270. */
  107271. endTransformFeedback(): void;
  107272. /**
  107273. * Specify the varyings to use with transform feedback
  107274. * @param program defines the associated webGL program
  107275. * @param value defines the list of strings representing the varying names
  107276. */
  107277. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107278. /**
  107279. * Bind a webGL buffer for a transform feedback operation
  107280. * @param value defines the webGL buffer to bind
  107281. */
  107282. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107283. }
  107284. }
  107285. declare module BABYLON {
  107286. /**
  107287. * Creation options of the multi render target texture.
  107288. */
  107289. export interface IMultiRenderTargetOptions {
  107290. /**
  107291. * Define if the texture needs to create mip maps after render.
  107292. */
  107293. generateMipMaps?: boolean;
  107294. /**
  107295. * Define the types of all the draw buffers we want to create
  107296. */
  107297. types?: number[];
  107298. /**
  107299. * Define the sampling modes of all the draw buffers we want to create
  107300. */
  107301. samplingModes?: number[];
  107302. /**
  107303. * Define if a depth buffer is required
  107304. */
  107305. generateDepthBuffer?: boolean;
  107306. /**
  107307. * Define if a stencil buffer is required
  107308. */
  107309. generateStencilBuffer?: boolean;
  107310. /**
  107311. * Define if a depth texture is required instead of a depth buffer
  107312. */
  107313. generateDepthTexture?: boolean;
  107314. /**
  107315. * Define the number of desired draw buffers
  107316. */
  107317. textureCount?: number;
  107318. /**
  107319. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107320. */
  107321. doNotChangeAspectRatio?: boolean;
  107322. /**
  107323. * Define the default type of the buffers we are creating
  107324. */
  107325. defaultType?: number;
  107326. }
  107327. /**
  107328. * A multi render target, like a render target provides the ability to render to a texture.
  107329. * Unlike the render target, it can render to several draw buffers in one draw.
  107330. * This is specially interesting in deferred rendering or for any effects requiring more than
  107331. * just one color from a single pass.
  107332. */
  107333. export class MultiRenderTarget extends RenderTargetTexture {
  107334. private _internalTextures;
  107335. private _textures;
  107336. private _multiRenderTargetOptions;
  107337. /**
  107338. * Get if draw buffers are currently supported by the used hardware and browser.
  107339. */
  107340. readonly isSupported: boolean;
  107341. /**
  107342. * Get the list of textures generated by the multi render target.
  107343. */
  107344. readonly textures: Texture[];
  107345. /**
  107346. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107347. */
  107348. readonly depthTexture: Texture;
  107349. /**
  107350. * Set the wrapping mode on U of all the textures we are rendering to.
  107351. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107352. */
  107353. wrapU: number;
  107354. /**
  107355. * Set the wrapping mode on V of all the textures we are rendering to.
  107356. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107357. */
  107358. wrapV: number;
  107359. /**
  107360. * Instantiate a new multi render target texture.
  107361. * A multi render target, like a render target provides the ability to render to a texture.
  107362. * Unlike the render target, it can render to several draw buffers in one draw.
  107363. * This is specially interesting in deferred rendering or for any effects requiring more than
  107364. * just one color from a single pass.
  107365. * @param name Define the name of the texture
  107366. * @param size Define the size of the buffers to render to
  107367. * @param count Define the number of target we are rendering into
  107368. * @param scene Define the scene the texture belongs to
  107369. * @param options Define the options used to create the multi render target
  107370. */
  107371. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107372. /** @hidden */
  107373. _rebuild(): void;
  107374. private _createInternalTextures;
  107375. private _createTextures;
  107376. /**
  107377. * Define the number of samples used if MSAA is enabled.
  107378. */
  107379. samples: number;
  107380. /**
  107381. * Resize all the textures in the multi render target.
  107382. * Be carrefull as it will recreate all the data in the new texture.
  107383. * @param size Define the new size
  107384. */
  107385. resize(size: any): void;
  107386. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107387. /**
  107388. * Dispose the render targets and their associated resources
  107389. */
  107390. dispose(): void;
  107391. /**
  107392. * Release all the underlying texture used as draw buffers.
  107393. */
  107394. releaseInternalTextures(): void;
  107395. }
  107396. }
  107397. declare module BABYLON {
  107398. interface Engine {
  107399. /**
  107400. * Unbind a list of render target textures from the webGL context
  107401. * This is used only when drawBuffer extension or webGL2 are active
  107402. * @param textures defines the render target textures to unbind
  107403. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107404. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107405. */
  107406. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107407. /**
  107408. * Create a multi render target texture
  107409. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107410. * @param size defines the size of the texture
  107411. * @param options defines the creation options
  107412. * @returns the cube texture as an InternalTexture
  107413. */
  107414. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107415. /**
  107416. * Update the sample count for a given multiple render target texture
  107417. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107418. * @param textures defines the textures to update
  107419. * @param samples defines the sample count to set
  107420. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107421. */
  107422. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107423. }
  107424. }
  107425. declare module BABYLON {
  107426. /**
  107427. * Gather the list of clipboard event types as constants.
  107428. */
  107429. export class ClipboardEventTypes {
  107430. /**
  107431. * The clipboard event is fired when a copy command is active (pressed).
  107432. */
  107433. static readonly COPY: number;
  107434. /**
  107435. * The clipboard event is fired when a cut command is active (pressed).
  107436. */
  107437. static readonly CUT: number;
  107438. /**
  107439. * The clipboard event is fired when a paste command is active (pressed).
  107440. */
  107441. static readonly PASTE: number;
  107442. }
  107443. /**
  107444. * This class is used to store clipboard related info for the onClipboardObservable event.
  107445. */
  107446. export class ClipboardInfo {
  107447. /**
  107448. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107449. */
  107450. type: number;
  107451. /**
  107452. * Defines the related dom event
  107453. */
  107454. event: ClipboardEvent;
  107455. /**
  107456. *Creates an instance of ClipboardInfo.
  107457. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107458. * @param event Defines the related dom event
  107459. */
  107460. constructor(
  107461. /**
  107462. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107463. */
  107464. type: number,
  107465. /**
  107466. * Defines the related dom event
  107467. */
  107468. event: ClipboardEvent);
  107469. /**
  107470. * Get the clipboard event's type from the keycode.
  107471. * @param keyCode Defines the keyCode for the current keyboard event.
  107472. * @return {number}
  107473. */
  107474. static GetTypeFromCharacter(keyCode: number): number;
  107475. }
  107476. }
  107477. declare module BABYLON {
  107478. /**
  107479. * Google Daydream controller
  107480. */
  107481. export class DaydreamController extends WebVRController {
  107482. /**
  107483. * Base Url for the controller model.
  107484. */
  107485. static MODEL_BASE_URL: string;
  107486. /**
  107487. * File name for the controller model.
  107488. */
  107489. static MODEL_FILENAME: string;
  107490. /**
  107491. * Gamepad Id prefix used to identify Daydream Controller.
  107492. */
  107493. static readonly GAMEPAD_ID_PREFIX: string;
  107494. /**
  107495. * Creates a new DaydreamController from a gamepad
  107496. * @param vrGamepad the gamepad that the controller should be created from
  107497. */
  107498. constructor(vrGamepad: any);
  107499. /**
  107500. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107501. * @param scene scene in which to add meshes
  107502. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107503. */
  107504. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107505. /**
  107506. * Called once for each button that changed state since the last frame
  107507. * @param buttonIdx Which button index changed
  107508. * @param state New state of the button
  107509. * @param changes Which properties on the state changed since last frame
  107510. */
  107511. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107512. }
  107513. }
  107514. declare module BABYLON {
  107515. /**
  107516. * Gear VR Controller
  107517. */
  107518. export class GearVRController extends WebVRController {
  107519. /**
  107520. * Base Url for the controller model.
  107521. */
  107522. static MODEL_BASE_URL: string;
  107523. /**
  107524. * File name for the controller model.
  107525. */
  107526. static MODEL_FILENAME: string;
  107527. /**
  107528. * Gamepad Id prefix used to identify this controller.
  107529. */
  107530. static readonly GAMEPAD_ID_PREFIX: string;
  107531. private readonly _buttonIndexToObservableNameMap;
  107532. /**
  107533. * Creates a new GearVRController from a gamepad
  107534. * @param vrGamepad the gamepad that the controller should be created from
  107535. */
  107536. constructor(vrGamepad: any);
  107537. /**
  107538. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107539. * @param scene scene in which to add meshes
  107540. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107541. */
  107542. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107543. /**
  107544. * Called once for each button that changed state since the last frame
  107545. * @param buttonIdx Which button index changed
  107546. * @param state New state of the button
  107547. * @param changes Which properties on the state changed since last frame
  107548. */
  107549. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107550. }
  107551. }
  107552. declare module BABYLON {
  107553. /**
  107554. * Class containing static functions to help procedurally build meshes
  107555. */
  107556. export class PolyhedronBuilder {
  107557. /**
  107558. * Creates a polyhedron mesh
  107559. * * 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
  107560. * * The parameter `size` (positive float, default 1) sets the polygon size
  107561. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107562. * * 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`
  107563. * * 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
  107564. * * 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)`)
  107565. * * 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
  107566. * * 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
  107567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107570. * @param name defines the name of the mesh
  107571. * @param options defines the options used to create the mesh
  107572. * @param scene defines the hosting scene
  107573. * @returns the polyhedron mesh
  107574. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107575. */
  107576. static CreatePolyhedron(name: string, options: {
  107577. type?: number;
  107578. size?: number;
  107579. sizeX?: number;
  107580. sizeY?: number;
  107581. sizeZ?: number;
  107582. custom?: any;
  107583. faceUV?: Vector4[];
  107584. faceColors?: Color4[];
  107585. flat?: boolean;
  107586. updatable?: boolean;
  107587. sideOrientation?: number;
  107588. frontUVs?: Vector4;
  107589. backUVs?: Vector4;
  107590. }, scene?: Nullable<Scene>): Mesh;
  107591. }
  107592. }
  107593. declare module BABYLON {
  107594. /**
  107595. * Gizmo that enables scaling a mesh along 3 axis
  107596. */
  107597. export class ScaleGizmo extends Gizmo {
  107598. /**
  107599. * Internal gizmo used for interactions on the x axis
  107600. */
  107601. xGizmo: AxisScaleGizmo;
  107602. /**
  107603. * Internal gizmo used for interactions on the y axis
  107604. */
  107605. yGizmo: AxisScaleGizmo;
  107606. /**
  107607. * Internal gizmo used for interactions on the z axis
  107608. */
  107609. zGizmo: AxisScaleGizmo;
  107610. /**
  107611. * Internal gizmo used to scale all axis equally
  107612. */
  107613. uniformScaleGizmo: AxisScaleGizmo;
  107614. private _meshAttached;
  107615. private _updateGizmoRotationToMatchAttachedMesh;
  107616. private _snapDistance;
  107617. private _scaleRatio;
  107618. private _uniformScalingMesh;
  107619. private _octahedron;
  107620. /** Fires an event when any of it's sub gizmos are dragged */
  107621. onDragStartObservable: Observable<unknown>;
  107622. /** Fires an event when any of it's sub gizmos are released from dragging */
  107623. onDragEndObservable: Observable<unknown>;
  107624. attachedMesh: Nullable<AbstractMesh>;
  107625. /**
  107626. * Creates a ScaleGizmo
  107627. * @param gizmoLayer The utility layer the gizmo will be added to
  107628. */
  107629. constructor(gizmoLayer?: UtilityLayerRenderer);
  107630. updateGizmoRotationToMatchAttachedMesh: boolean;
  107631. /**
  107632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107633. */
  107634. snapDistance: number;
  107635. /**
  107636. * Ratio for the scale of the gizmo (Default: 1)
  107637. */
  107638. scaleRatio: number;
  107639. /**
  107640. * Disposes of the gizmo
  107641. */
  107642. dispose(): void;
  107643. }
  107644. }
  107645. declare module BABYLON {
  107646. /**
  107647. * Single axis scale gizmo
  107648. */
  107649. export class AxisScaleGizmo extends Gizmo {
  107650. /**
  107651. * Drag behavior responsible for the gizmos dragging interactions
  107652. */
  107653. dragBehavior: PointerDragBehavior;
  107654. private _pointerObserver;
  107655. /**
  107656. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107657. */
  107658. snapDistance: number;
  107659. /**
  107660. * Event that fires each time the gizmo snaps to a new location.
  107661. * * snapDistance is the the change in distance
  107662. */
  107663. onSnapObservable: Observable<{
  107664. snapDistance: number;
  107665. }>;
  107666. /**
  107667. * If the scaling operation should be done on all axis (default: false)
  107668. */
  107669. uniformScaling: boolean;
  107670. private _isEnabled;
  107671. private _parent;
  107672. private _arrow;
  107673. private _coloredMaterial;
  107674. private _hoverMaterial;
  107675. /**
  107676. * Creates an AxisScaleGizmo
  107677. * @param gizmoLayer The utility layer the gizmo will be added to
  107678. * @param dragAxis The axis which the gizmo will be able to scale on
  107679. * @param color The color of the gizmo
  107680. */
  107681. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  107682. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107683. /**
  107684. * If the gizmo is enabled
  107685. */
  107686. isEnabled: boolean;
  107687. /**
  107688. * Disposes of the gizmo
  107689. */
  107690. dispose(): void;
  107691. /**
  107692. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107693. * @param mesh The mesh to replace the default mesh of the gizmo
  107694. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  107695. */
  107696. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  107697. }
  107698. }
  107699. declare module BABYLON {
  107700. /**
  107701. * Bounding box gizmo
  107702. */
  107703. export class BoundingBoxGizmo extends Gizmo {
  107704. private _lineBoundingBox;
  107705. private _rotateSpheresParent;
  107706. private _scaleBoxesParent;
  107707. private _boundingDimensions;
  107708. private _renderObserver;
  107709. private _pointerObserver;
  107710. private _scaleDragSpeed;
  107711. private _tmpQuaternion;
  107712. private _tmpVector;
  107713. private _tmpRotationMatrix;
  107714. /**
  107715. * 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)
  107716. */
  107717. ignoreChildren: boolean;
  107718. /**
  107719. * 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)
  107720. */
  107721. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  107722. /**
  107723. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  107724. */
  107725. rotationSphereSize: number;
  107726. /**
  107727. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  107728. */
  107729. scaleBoxSize: number;
  107730. /**
  107731. * 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)
  107732. */
  107733. fixedDragMeshScreenSize: boolean;
  107734. /**
  107735. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  107736. */
  107737. fixedDragMeshScreenSizeDistanceFactor: number;
  107738. /**
  107739. * Fired when a rotation sphere or scale box is dragged
  107740. */
  107741. onDragStartObservable: Observable<{}>;
  107742. /**
  107743. * Fired when a scale box is dragged
  107744. */
  107745. onScaleBoxDragObservable: Observable<{}>;
  107746. /**
  107747. * Fired when a scale box drag is ended
  107748. */
  107749. onScaleBoxDragEndObservable: Observable<{}>;
  107750. /**
  107751. * Fired when a rotation sphere is dragged
  107752. */
  107753. onRotationSphereDragObservable: Observable<{}>;
  107754. /**
  107755. * Fired when a rotation sphere drag is ended
  107756. */
  107757. onRotationSphereDragEndObservable: Observable<{}>;
  107758. /**
  107759. * 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)
  107760. */
  107761. scalePivot: Nullable<Vector3>;
  107762. /**
  107763. * Mesh used as a pivot to rotate the attached mesh
  107764. */
  107765. private _anchorMesh;
  107766. private _existingMeshScale;
  107767. private _dragMesh;
  107768. private pointerDragBehavior;
  107769. private coloredMaterial;
  107770. private hoverColoredMaterial;
  107771. /**
  107772. * Sets the color of the bounding box gizmo
  107773. * @param color the color to set
  107774. */
  107775. setColor(color: Color3): void;
  107776. /**
  107777. * Creates an BoundingBoxGizmo
  107778. * @param gizmoLayer The utility layer the gizmo will be added to
  107779. * @param color The color of the gizmo
  107780. */
  107781. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  107782. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107783. private _selectNode;
  107784. /**
  107785. * Updates the bounding box information for the Gizmo
  107786. */
  107787. updateBoundingBox(): void;
  107788. private _updateRotationSpheres;
  107789. private _updateScaleBoxes;
  107790. /**
  107791. * Enables rotation on the specified axis and disables rotation on the others
  107792. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  107793. */
  107794. setEnabledRotationAxis(axis: string): void;
  107795. /**
  107796. * Enables/disables scaling
  107797. * @param enable if scaling should be enabled
  107798. */
  107799. setEnabledScaling(enable: boolean): void;
  107800. private _updateDummy;
  107801. /**
  107802. * Enables a pointer drag behavior on the bounding box of the gizmo
  107803. */
  107804. enableDragBehavior(): void;
  107805. /**
  107806. * Disposes of the gizmo
  107807. */
  107808. dispose(): void;
  107809. /**
  107810. * 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)
  107811. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  107812. * @returns the bounding box mesh with the passed in mesh as a child
  107813. */
  107814. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  107815. /**
  107816. * CustomMeshes are not supported by this gizmo
  107817. * @param mesh The mesh to replace the default mesh of the gizmo
  107818. */
  107819. setCustomMesh(mesh: Mesh): void;
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /**
  107824. * Single plane rotation gizmo
  107825. */
  107826. export class PlaneRotationGizmo extends Gizmo {
  107827. /**
  107828. * Drag behavior responsible for the gizmos dragging interactions
  107829. */
  107830. dragBehavior: PointerDragBehavior;
  107831. private _pointerObserver;
  107832. /**
  107833. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  107834. */
  107835. snapDistance: number;
  107836. /**
  107837. * Event that fires each time the gizmo snaps to a new location.
  107838. * * snapDistance is the the change in distance
  107839. */
  107840. onSnapObservable: Observable<{
  107841. snapDistance: number;
  107842. }>;
  107843. private _isEnabled;
  107844. private _parent;
  107845. /**
  107846. * Creates a PlaneRotationGizmo
  107847. * @param gizmoLayer The utility layer the gizmo will be added to
  107848. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  107849. * @param color The color of the gizmo
  107850. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107851. */
  107852. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  107853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107854. /**
  107855. * If the gizmo is enabled
  107856. */
  107857. isEnabled: boolean;
  107858. /**
  107859. * Disposes of the gizmo
  107860. */
  107861. dispose(): void;
  107862. }
  107863. }
  107864. declare module BABYLON {
  107865. /**
  107866. * Gizmo that enables rotating a mesh along 3 axis
  107867. */
  107868. export class RotationGizmo extends Gizmo {
  107869. /**
  107870. * Internal gizmo used for interactions on the x axis
  107871. */
  107872. xGizmo: PlaneRotationGizmo;
  107873. /**
  107874. * Internal gizmo used for interactions on the y axis
  107875. */
  107876. yGizmo: PlaneRotationGizmo;
  107877. /**
  107878. * Internal gizmo used for interactions on the z axis
  107879. */
  107880. zGizmo: PlaneRotationGizmo;
  107881. /** Fires an event when any of it's sub gizmos are dragged */
  107882. onDragStartObservable: Observable<unknown>;
  107883. /** Fires an event when any of it's sub gizmos are released from dragging */
  107884. onDragEndObservable: Observable<unknown>;
  107885. private _meshAttached;
  107886. attachedMesh: Nullable<AbstractMesh>;
  107887. /**
  107888. * Creates a RotationGizmo
  107889. * @param gizmoLayer The utility layer the gizmo will be added to
  107890. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107891. */
  107892. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  107893. updateGizmoRotationToMatchAttachedMesh: boolean;
  107894. /**
  107895. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107896. */
  107897. snapDistance: number;
  107898. /**
  107899. * Ratio for the scale of the gizmo (Default: 1)
  107900. */
  107901. scaleRatio: number;
  107902. /**
  107903. * Disposes of the gizmo
  107904. */
  107905. dispose(): void;
  107906. /**
  107907. * CustomMeshes are not supported by this gizmo
  107908. * @param mesh The mesh to replace the default mesh of the gizmo
  107909. */
  107910. setCustomMesh(mesh: Mesh): void;
  107911. }
  107912. }
  107913. declare module BABYLON {
  107914. /**
  107915. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107916. */
  107917. export class GizmoManager implements IDisposable {
  107918. private scene;
  107919. /**
  107920. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107921. */
  107922. gizmos: {
  107923. positionGizmo: Nullable<PositionGizmo>;
  107924. rotationGizmo: Nullable<RotationGizmo>;
  107925. scaleGizmo: Nullable<ScaleGizmo>;
  107926. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107927. };
  107928. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107929. clearGizmoOnEmptyPointerEvent: boolean;
  107930. /** Fires an event when the manager is attached to a mesh */
  107931. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107932. private _gizmosEnabled;
  107933. private _pointerObserver;
  107934. private _attachedMesh;
  107935. private _boundingBoxColor;
  107936. private _defaultUtilityLayer;
  107937. private _defaultKeepDepthUtilityLayer;
  107938. /**
  107939. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107940. */
  107941. boundingBoxDragBehavior: SixDofDragBehavior;
  107942. /**
  107943. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107944. */
  107945. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107946. /**
  107947. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107948. */
  107949. usePointerToAttachGizmos: boolean;
  107950. /**
  107951. * Utility layer that the bounding box gizmo belongs to
  107952. */
  107953. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107954. /**
  107955. * Utility layer that all gizmos besides bounding box belong to
  107956. */
  107957. readonly utilityLayer: UtilityLayerRenderer;
  107958. /**
  107959. * Instatiates a gizmo manager
  107960. * @param scene the scene to overlay the gizmos on top of
  107961. */
  107962. constructor(scene: Scene);
  107963. /**
  107964. * Attaches a set of gizmos to the specified mesh
  107965. * @param mesh The mesh the gizmo's should be attached to
  107966. */
  107967. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107968. /**
  107969. * If the position gizmo is enabled
  107970. */
  107971. positionGizmoEnabled: boolean;
  107972. /**
  107973. * If the rotation gizmo is enabled
  107974. */
  107975. rotationGizmoEnabled: boolean;
  107976. /**
  107977. * If the scale gizmo is enabled
  107978. */
  107979. scaleGizmoEnabled: boolean;
  107980. /**
  107981. * If the boundingBox gizmo is enabled
  107982. */
  107983. boundingBoxGizmoEnabled: boolean;
  107984. /**
  107985. * Disposes of the gizmo manager
  107986. */
  107987. dispose(): void;
  107988. }
  107989. }
  107990. declare module BABYLON {
  107991. /**
  107992. * A directional light is defined by a direction (what a surprise!).
  107993. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107994. * 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.
  107995. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107996. */
  107997. export class DirectionalLight extends ShadowLight {
  107998. private _shadowFrustumSize;
  107999. /**
  108000. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  108001. */
  108002. /**
  108003. * Specifies a fix frustum size for the shadow generation.
  108004. */
  108005. shadowFrustumSize: number;
  108006. private _shadowOrthoScale;
  108007. /**
  108008. * Gets the shadow projection scale against the optimal computed one.
  108009. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108010. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108011. */
  108012. /**
  108013. * Sets the shadow projection scale against the optimal computed one.
  108014. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108015. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108016. */
  108017. shadowOrthoScale: number;
  108018. /**
  108019. * Automatically compute the projection matrix to best fit (including all the casters)
  108020. * on each frame.
  108021. */
  108022. autoUpdateExtends: boolean;
  108023. private _orthoLeft;
  108024. private _orthoRight;
  108025. private _orthoTop;
  108026. private _orthoBottom;
  108027. /**
  108028. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  108029. * The directional light is emitted from everywhere in the given direction.
  108030. * It can cast shadows.
  108031. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108032. * @param name The friendly name of the light
  108033. * @param direction The direction of the light
  108034. * @param scene The scene the light belongs to
  108035. */
  108036. constructor(name: string, direction: Vector3, scene: Scene);
  108037. /**
  108038. * Returns the string "DirectionalLight".
  108039. * @return The class name
  108040. */
  108041. getClassName(): string;
  108042. /**
  108043. * Returns the integer 1.
  108044. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108045. */
  108046. getTypeID(): number;
  108047. /**
  108048. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  108049. * Returns the DirectionalLight Shadow projection matrix.
  108050. */
  108051. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108052. /**
  108053. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108054. * Returns the DirectionalLight Shadow projection matrix.
  108055. */
  108056. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108057. /**
  108058. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108059. * Returns the DirectionalLight Shadow projection matrix.
  108060. */
  108061. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108062. protected _buildUniformLayout(): void;
  108063. /**
  108064. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108065. * @param effect The effect to update
  108066. * @param lightIndex The index of the light in the effect to update
  108067. * @returns The directional light
  108068. */
  108069. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108070. /**
  108071. * Gets the minZ used for shadow according to both the scene and the light.
  108072. *
  108073. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108074. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108075. * @param activeCamera The camera we are returning the min for
  108076. * @returns the depth min z
  108077. */
  108078. getDepthMinZ(activeCamera: Camera): number;
  108079. /**
  108080. * Gets the maxZ used for shadow according to both the scene and the light.
  108081. *
  108082. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108083. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108084. * @param activeCamera The camera we are returning the max for
  108085. * @returns the depth max z
  108086. */
  108087. getDepthMaxZ(activeCamera: Camera): number;
  108088. /**
  108089. * Prepares the list of defines specific to the light type.
  108090. * @param defines the list of defines
  108091. * @param lightIndex defines the index of the light for the effect
  108092. */
  108093. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108094. }
  108095. }
  108096. declare module BABYLON {
  108097. /**
  108098. * Class containing static functions to help procedurally build meshes
  108099. */
  108100. export class HemisphereBuilder {
  108101. /**
  108102. * Creates a hemisphere mesh
  108103. * @param name defines the name of the mesh
  108104. * @param options defines the options used to create the mesh
  108105. * @param scene defines the hosting scene
  108106. * @returns the hemisphere mesh
  108107. */
  108108. static CreateHemisphere(name: string, options: {
  108109. segments?: number;
  108110. diameter?: number;
  108111. sideOrientation?: number;
  108112. }, scene: any): Mesh;
  108113. }
  108114. }
  108115. declare module BABYLON {
  108116. /**
  108117. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108118. * These values define a cone of light starting from the position, emitting toward the direction.
  108119. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108120. * and the exponent defines the speed of the decay of the light with distance (reach).
  108121. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108122. */
  108123. export class SpotLight extends ShadowLight {
  108124. private _angle;
  108125. private _innerAngle;
  108126. private _cosHalfAngle;
  108127. private _lightAngleScale;
  108128. private _lightAngleOffset;
  108129. /**
  108130. * Gets the cone angle of the spot light in Radians.
  108131. */
  108132. /**
  108133. * Sets the cone angle of the spot light in Radians.
  108134. */
  108135. angle: number;
  108136. /**
  108137. * Only used in gltf falloff mode, this defines the angle where
  108138. * the directional falloff will start before cutting at angle which could be seen
  108139. * as outer angle.
  108140. */
  108141. /**
  108142. * Only used in gltf falloff mode, this defines the angle where
  108143. * the directional falloff will start before cutting at angle which could be seen
  108144. * as outer angle.
  108145. */
  108146. innerAngle: number;
  108147. private _shadowAngleScale;
  108148. /**
  108149. * Allows scaling the angle of the light for shadow generation only.
  108150. */
  108151. /**
  108152. * Allows scaling the angle of the light for shadow generation only.
  108153. */
  108154. shadowAngleScale: number;
  108155. /**
  108156. * The light decay speed with the distance from the emission spot.
  108157. */
  108158. exponent: number;
  108159. private _projectionTextureMatrix;
  108160. /**
  108161. * Allows reading the projecton texture
  108162. */
  108163. readonly projectionTextureMatrix: Matrix;
  108164. protected _projectionTextureLightNear: number;
  108165. /**
  108166. * Gets the near clip of the Spotlight for texture projection.
  108167. */
  108168. /**
  108169. * Sets the near clip of the Spotlight for texture projection.
  108170. */
  108171. projectionTextureLightNear: number;
  108172. protected _projectionTextureLightFar: number;
  108173. /**
  108174. * Gets the far clip of the Spotlight for texture projection.
  108175. */
  108176. /**
  108177. * Sets the far clip of the Spotlight for texture projection.
  108178. */
  108179. projectionTextureLightFar: number;
  108180. protected _projectionTextureUpDirection: Vector3;
  108181. /**
  108182. * Gets the Up vector of the Spotlight for texture projection.
  108183. */
  108184. /**
  108185. * Sets the Up vector of the Spotlight for texture projection.
  108186. */
  108187. projectionTextureUpDirection: Vector3;
  108188. private _projectionTexture;
  108189. /**
  108190. * Gets the projection texture of the light.
  108191. */
  108192. /**
  108193. * Sets the projection texture of the light.
  108194. */
  108195. projectionTexture: Nullable<BaseTexture>;
  108196. private _projectionTextureViewLightDirty;
  108197. private _projectionTextureProjectionLightDirty;
  108198. private _projectionTextureDirty;
  108199. private _projectionTextureViewTargetVector;
  108200. private _projectionTextureViewLightMatrix;
  108201. private _projectionTextureProjectionLightMatrix;
  108202. private _projectionTextureScalingMatrix;
  108203. /**
  108204. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  108205. * It can cast shadows.
  108206. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108207. * @param name The light friendly name
  108208. * @param position The position of the spot light in the scene
  108209. * @param direction The direction of the light in the scene
  108210. * @param angle The cone angle of the light in Radians
  108211. * @param exponent The light decay speed with the distance from the emission spot
  108212. * @param scene The scene the lights belongs to
  108213. */
  108214. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  108215. /**
  108216. * Returns the string "SpotLight".
  108217. * @returns the class name
  108218. */
  108219. getClassName(): string;
  108220. /**
  108221. * Returns the integer 2.
  108222. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108223. */
  108224. getTypeID(): number;
  108225. /**
  108226. * Overrides the direction setter to recompute the projection texture view light Matrix.
  108227. */
  108228. protected _setDirection(value: Vector3): void;
  108229. /**
  108230. * Overrides the position setter to recompute the projection texture view light Matrix.
  108231. */
  108232. protected _setPosition(value: Vector3): void;
  108233. /**
  108234. * 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.
  108235. * Returns the SpotLight.
  108236. */
  108237. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108238. protected _computeProjectionTextureViewLightMatrix(): void;
  108239. protected _computeProjectionTextureProjectionLightMatrix(): void;
  108240. /**
  108241. * Main function for light texture projection matrix computing.
  108242. */
  108243. protected _computeProjectionTextureMatrix(): void;
  108244. protected _buildUniformLayout(): void;
  108245. private _computeAngleValues;
  108246. /**
  108247. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108248. * @param effect The effect to update
  108249. * @param lightIndex The index of the light in the effect to update
  108250. * @returns The spot light
  108251. */
  108252. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108253. /**
  108254. * Disposes the light and the associated resources.
  108255. */
  108256. dispose(): void;
  108257. /**
  108258. * Prepares the list of defines specific to the light type.
  108259. * @param defines the list of defines
  108260. * @param lightIndex defines the index of the light for the effect
  108261. */
  108262. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108263. }
  108264. }
  108265. declare module BABYLON {
  108266. /**
  108267. * Gizmo that enables viewing a light
  108268. */
  108269. export class LightGizmo extends Gizmo {
  108270. private _lightMesh;
  108271. private _material;
  108272. private cachedPosition;
  108273. private cachedForward;
  108274. /**
  108275. * Creates a LightGizmo
  108276. * @param gizmoLayer The utility layer the gizmo will be added to
  108277. */
  108278. constructor(gizmoLayer?: UtilityLayerRenderer);
  108279. private _light;
  108280. /**
  108281. * The light that the gizmo is attached to
  108282. */
  108283. light: Nullable<Light>;
  108284. /**
  108285. * @hidden
  108286. * Updates the gizmo to match the attached mesh's position/rotation
  108287. */
  108288. protected _update(): void;
  108289. private static _Scale;
  108290. /**
  108291. * Creates the lines for a light mesh
  108292. */
  108293. private static _createLightLines;
  108294. /**
  108295. * Disposes of the light gizmo
  108296. */
  108297. dispose(): void;
  108298. private static _CreateHemisphericLightMesh;
  108299. private static _CreatePointLightMesh;
  108300. private static _CreateSpotLightMesh;
  108301. private static _CreateDirectionalLightMesh;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /** @hidden */
  108306. export var backgroundFragmentDeclaration: {
  108307. name: string;
  108308. shader: string;
  108309. };
  108310. }
  108311. declare module BABYLON {
  108312. /** @hidden */
  108313. export var backgroundUboDeclaration: {
  108314. name: string;
  108315. shader: string;
  108316. };
  108317. }
  108318. declare module BABYLON {
  108319. /** @hidden */
  108320. export var backgroundPixelShader: {
  108321. name: string;
  108322. shader: string;
  108323. };
  108324. }
  108325. declare module BABYLON {
  108326. /** @hidden */
  108327. export var backgroundVertexDeclaration: {
  108328. name: string;
  108329. shader: string;
  108330. };
  108331. }
  108332. declare module BABYLON {
  108333. /** @hidden */
  108334. export var backgroundVertexShader: {
  108335. name: string;
  108336. shader: string;
  108337. };
  108338. }
  108339. declare module BABYLON {
  108340. /**
  108341. * Background material used to create an efficient environement around your scene.
  108342. */
  108343. export class BackgroundMaterial extends PushMaterial {
  108344. /**
  108345. * Standard reflectance value at parallel view angle.
  108346. */
  108347. static StandardReflectance0: number;
  108348. /**
  108349. * Standard reflectance value at grazing angle.
  108350. */
  108351. static StandardReflectance90: number;
  108352. protected _primaryColor: Color3;
  108353. /**
  108354. * Key light Color (multiply against the environement texture)
  108355. */
  108356. primaryColor: Color3;
  108357. protected __perceptualColor: Nullable<Color3>;
  108358. /**
  108359. * Experimental Internal Use Only.
  108360. *
  108361. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108362. * This acts as a helper to set the primary color to a more "human friendly" value.
  108363. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108364. * output color as close as possible from the chosen value.
  108365. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108366. * part of lighting setup.)
  108367. */
  108368. _perceptualColor: Nullable<Color3>;
  108369. protected _primaryColorShadowLevel: float;
  108370. /**
  108371. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108372. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108373. */
  108374. primaryColorShadowLevel: float;
  108375. protected _primaryColorHighlightLevel: float;
  108376. /**
  108377. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108378. * The primary color is used at the level chosen to define what the white area would look.
  108379. */
  108380. primaryColorHighlightLevel: float;
  108381. protected _reflectionTexture: Nullable<BaseTexture>;
  108382. /**
  108383. * Reflection Texture used in the material.
  108384. * Should be author in a specific way for the best result (refer to the documentation).
  108385. */
  108386. reflectionTexture: Nullable<BaseTexture>;
  108387. protected _reflectionBlur: float;
  108388. /**
  108389. * Reflection Texture level of blur.
  108390. *
  108391. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108392. * texture twice.
  108393. */
  108394. reflectionBlur: float;
  108395. protected _diffuseTexture: Nullable<BaseTexture>;
  108396. /**
  108397. * Diffuse Texture used in the material.
  108398. * Should be author in a specific way for the best result (refer to the documentation).
  108399. */
  108400. diffuseTexture: Nullable<BaseTexture>;
  108401. protected _shadowLights: Nullable<IShadowLight[]>;
  108402. /**
  108403. * Specify the list of lights casting shadow on the material.
  108404. * All scene shadow lights will be included if null.
  108405. */
  108406. shadowLights: Nullable<IShadowLight[]>;
  108407. protected _shadowLevel: float;
  108408. /**
  108409. * Helps adjusting the shadow to a softer level if required.
  108410. * 0 means black shadows and 1 means no shadows.
  108411. */
  108412. shadowLevel: float;
  108413. protected _sceneCenter: Vector3;
  108414. /**
  108415. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108416. * It is usually zero but might be interesting to modify according to your setup.
  108417. */
  108418. sceneCenter: Vector3;
  108419. protected _opacityFresnel: boolean;
  108420. /**
  108421. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108422. * This helps ensuring a nice transition when the camera goes under the ground.
  108423. */
  108424. opacityFresnel: boolean;
  108425. protected _reflectionFresnel: boolean;
  108426. /**
  108427. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108428. * This helps adding a mirror texture on the ground.
  108429. */
  108430. reflectionFresnel: boolean;
  108431. protected _reflectionFalloffDistance: number;
  108432. /**
  108433. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108434. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108435. */
  108436. reflectionFalloffDistance: number;
  108437. protected _reflectionAmount: number;
  108438. /**
  108439. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108440. */
  108441. reflectionAmount: number;
  108442. protected _reflectionReflectance0: number;
  108443. /**
  108444. * This specifies the weight of the reflection at grazing angle.
  108445. */
  108446. reflectionReflectance0: number;
  108447. protected _reflectionReflectance90: number;
  108448. /**
  108449. * This specifies the weight of the reflection at a perpendicular point of view.
  108450. */
  108451. reflectionReflectance90: number;
  108452. /**
  108453. * Sets the reflection reflectance fresnel values according to the default standard
  108454. * empirically know to work well :-)
  108455. */
  108456. reflectionStandardFresnelWeight: number;
  108457. protected _useRGBColor: boolean;
  108458. /**
  108459. * Helps to directly use the maps channels instead of their level.
  108460. */
  108461. useRGBColor: boolean;
  108462. protected _enableNoise: boolean;
  108463. /**
  108464. * This helps reducing the banding effect that could occur on the background.
  108465. */
  108466. enableNoise: boolean;
  108467. /**
  108468. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108469. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108470. * Recommended to be keep at 1.0 except for special cases.
  108471. */
  108472. fovMultiplier: number;
  108473. private _fovMultiplier;
  108474. /**
  108475. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108476. */
  108477. useEquirectangularFOV: boolean;
  108478. private _maxSimultaneousLights;
  108479. /**
  108480. * Number of Simultaneous lights allowed on the material.
  108481. */
  108482. maxSimultaneousLights: int;
  108483. /**
  108484. * Default configuration related to image processing available in the Background Material.
  108485. */
  108486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108487. /**
  108488. * Keep track of the image processing observer to allow dispose and replace.
  108489. */
  108490. private _imageProcessingObserver;
  108491. /**
  108492. * Attaches a new image processing configuration to the PBR Material.
  108493. * @param configuration (if null the scene configuration will be use)
  108494. */
  108495. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108496. /**
  108497. * Gets the image processing configuration used either in this material.
  108498. */
  108499. /**
  108500. * Sets the Default image processing configuration used either in the this material.
  108501. *
  108502. * If sets to null, the scene one is in use.
  108503. */
  108504. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108505. /**
  108506. * Gets wether the color curves effect is enabled.
  108507. */
  108508. /**
  108509. * Sets wether the color curves effect is enabled.
  108510. */
  108511. cameraColorCurvesEnabled: boolean;
  108512. /**
  108513. * Gets wether the color grading effect is enabled.
  108514. */
  108515. /**
  108516. * Gets wether the color grading effect is enabled.
  108517. */
  108518. cameraColorGradingEnabled: boolean;
  108519. /**
  108520. * Gets wether tonemapping is enabled or not.
  108521. */
  108522. /**
  108523. * Sets wether tonemapping is enabled or not
  108524. */
  108525. cameraToneMappingEnabled: boolean;
  108526. /**
  108527. * The camera exposure used on this material.
  108528. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108529. * This corresponds to a photographic exposure.
  108530. */
  108531. /**
  108532. * The camera exposure used on this material.
  108533. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108534. * This corresponds to a photographic exposure.
  108535. */
  108536. cameraExposure: float;
  108537. /**
  108538. * Gets The camera contrast used on this material.
  108539. */
  108540. /**
  108541. * Sets The camera contrast used on this material.
  108542. */
  108543. cameraContrast: float;
  108544. /**
  108545. * Gets the Color Grading 2D Lookup Texture.
  108546. */
  108547. /**
  108548. * Sets the Color Grading 2D Lookup Texture.
  108549. */
  108550. cameraColorGradingTexture: Nullable<BaseTexture>;
  108551. /**
  108552. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108553. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108554. * 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;
  108555. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108556. */
  108557. /**
  108558. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108559. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108560. * 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;
  108561. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108562. */
  108563. cameraColorCurves: Nullable<ColorCurves>;
  108564. /**
  108565. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  108566. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  108567. */
  108568. switchToBGR: boolean;
  108569. private _renderTargets;
  108570. private _reflectionControls;
  108571. private _white;
  108572. private _primaryShadowColor;
  108573. private _primaryHighlightColor;
  108574. /**
  108575. * Instantiates a Background Material in the given scene
  108576. * @param name The friendly name of the material
  108577. * @param scene The scene to add the material to
  108578. */
  108579. constructor(name: string, scene: Scene);
  108580. /**
  108581. * Gets a boolean indicating that current material needs to register RTT
  108582. */
  108583. readonly hasRenderTargetTextures: boolean;
  108584. /**
  108585. * The entire material has been created in order to prevent overdraw.
  108586. * @returns false
  108587. */
  108588. needAlphaTesting(): boolean;
  108589. /**
  108590. * The entire material has been created in order to prevent overdraw.
  108591. * @returns true if blending is enable
  108592. */
  108593. needAlphaBlending(): boolean;
  108594. /**
  108595. * Checks wether the material is ready to be rendered for a given mesh.
  108596. * @param mesh The mesh to render
  108597. * @param subMesh The submesh to check against
  108598. * @param useInstances Specify wether or not the material is used with instances
  108599. * @returns true if all the dependencies are ready (Textures, Effects...)
  108600. */
  108601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108602. /**
  108603. * Compute the primary color according to the chosen perceptual color.
  108604. */
  108605. private _computePrimaryColorFromPerceptualColor;
  108606. /**
  108607. * Compute the highlights and shadow colors according to their chosen levels.
  108608. */
  108609. private _computePrimaryColors;
  108610. /**
  108611. * Build the uniform buffer used in the material.
  108612. */
  108613. buildUniformLayout(): void;
  108614. /**
  108615. * Unbind the material.
  108616. */
  108617. unbind(): void;
  108618. /**
  108619. * Bind only the world matrix to the material.
  108620. * @param world The world matrix to bind.
  108621. */
  108622. bindOnlyWorldMatrix(world: Matrix): void;
  108623. /**
  108624. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  108625. * @param world The world matrix to bind.
  108626. * @param subMesh The submesh to bind for.
  108627. */
  108628. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108629. /**
  108630. * Dispose the material.
  108631. * @param forceDisposeEffect Force disposal of the associated effect.
  108632. * @param forceDisposeTextures Force disposal of the associated textures.
  108633. */
  108634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108635. /**
  108636. * Clones the material.
  108637. * @param name The cloned name.
  108638. * @returns The cloned material.
  108639. */
  108640. clone(name: string): BackgroundMaterial;
  108641. /**
  108642. * Serializes the current material to its JSON representation.
  108643. * @returns The JSON representation.
  108644. */
  108645. serialize(): any;
  108646. /**
  108647. * Gets the class name of the material
  108648. * @returns "BackgroundMaterial"
  108649. */
  108650. getClassName(): string;
  108651. /**
  108652. * Parse a JSON input to create back a background material.
  108653. * @param source The JSON data to parse
  108654. * @param scene The scene to create the parsed material in
  108655. * @param rootUrl The root url of the assets the material depends upon
  108656. * @returns the instantiated BackgroundMaterial.
  108657. */
  108658. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  108659. }
  108660. }
  108661. declare module BABYLON {
  108662. /**
  108663. * Represents the different options available during the creation of
  108664. * a Environment helper.
  108665. *
  108666. * This can control the default ground, skybox and image processing setup of your scene.
  108667. */
  108668. export interface IEnvironmentHelperOptions {
  108669. /**
  108670. * Specifies wether or not to create a ground.
  108671. * True by default.
  108672. */
  108673. createGround: boolean;
  108674. /**
  108675. * Specifies the ground size.
  108676. * 15 by default.
  108677. */
  108678. groundSize: number;
  108679. /**
  108680. * The texture used on the ground for the main color.
  108681. * Comes from the BabylonJS CDN by default.
  108682. *
  108683. * Remarks: Can be either a texture or a url.
  108684. */
  108685. groundTexture: string | BaseTexture;
  108686. /**
  108687. * The color mixed in the ground texture by default.
  108688. * BabylonJS clearColor by default.
  108689. */
  108690. groundColor: Color3;
  108691. /**
  108692. * Specifies the ground opacity.
  108693. * 1 by default.
  108694. */
  108695. groundOpacity: number;
  108696. /**
  108697. * Enables the ground to receive shadows.
  108698. * True by default.
  108699. */
  108700. enableGroundShadow: boolean;
  108701. /**
  108702. * Helps preventing the shadow to be fully black on the ground.
  108703. * 0.5 by default.
  108704. */
  108705. groundShadowLevel: number;
  108706. /**
  108707. * Creates a mirror texture attach to the ground.
  108708. * false by default.
  108709. */
  108710. enableGroundMirror: boolean;
  108711. /**
  108712. * Specifies the ground mirror size ratio.
  108713. * 0.3 by default as the default kernel is 64.
  108714. */
  108715. groundMirrorSizeRatio: number;
  108716. /**
  108717. * Specifies the ground mirror blur kernel size.
  108718. * 64 by default.
  108719. */
  108720. groundMirrorBlurKernel: number;
  108721. /**
  108722. * Specifies the ground mirror visibility amount.
  108723. * 1 by default
  108724. */
  108725. groundMirrorAmount: number;
  108726. /**
  108727. * Specifies the ground mirror reflectance weight.
  108728. * This uses the standard weight of the background material to setup the fresnel effect
  108729. * of the mirror.
  108730. * 1 by default.
  108731. */
  108732. groundMirrorFresnelWeight: number;
  108733. /**
  108734. * Specifies the ground mirror Falloff distance.
  108735. * This can helps reducing the size of the reflection.
  108736. * 0 by Default.
  108737. */
  108738. groundMirrorFallOffDistance: number;
  108739. /**
  108740. * Specifies the ground mirror texture type.
  108741. * Unsigned Int by Default.
  108742. */
  108743. groundMirrorTextureType: number;
  108744. /**
  108745. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  108746. * the shown objects.
  108747. */
  108748. groundYBias: number;
  108749. /**
  108750. * Specifies wether or not to create a skybox.
  108751. * True by default.
  108752. */
  108753. createSkybox: boolean;
  108754. /**
  108755. * Specifies the skybox size.
  108756. * 20 by default.
  108757. */
  108758. skyboxSize: number;
  108759. /**
  108760. * The texture used on the skybox for the main color.
  108761. * Comes from the BabylonJS CDN by default.
  108762. *
  108763. * Remarks: Can be either a texture or a url.
  108764. */
  108765. skyboxTexture: string | BaseTexture;
  108766. /**
  108767. * The color mixed in the skybox texture by default.
  108768. * BabylonJS clearColor by default.
  108769. */
  108770. skyboxColor: Color3;
  108771. /**
  108772. * The background rotation around the Y axis of the scene.
  108773. * This helps aligning the key lights of your scene with the background.
  108774. * 0 by default.
  108775. */
  108776. backgroundYRotation: number;
  108777. /**
  108778. * Compute automatically the size of the elements to best fit with the scene.
  108779. */
  108780. sizeAuto: boolean;
  108781. /**
  108782. * Default position of the rootMesh if autoSize is not true.
  108783. */
  108784. rootPosition: Vector3;
  108785. /**
  108786. * Sets up the image processing in the scene.
  108787. * true by default.
  108788. */
  108789. setupImageProcessing: boolean;
  108790. /**
  108791. * The texture used as your environment texture in the scene.
  108792. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  108793. *
  108794. * Remarks: Can be either a texture or a url.
  108795. */
  108796. environmentTexture: string | BaseTexture;
  108797. /**
  108798. * The value of the exposure to apply to the scene.
  108799. * 0.6 by default if setupImageProcessing is true.
  108800. */
  108801. cameraExposure: number;
  108802. /**
  108803. * The value of the contrast to apply to the scene.
  108804. * 1.6 by default if setupImageProcessing is true.
  108805. */
  108806. cameraContrast: number;
  108807. /**
  108808. * Specifies wether or not tonemapping should be enabled in the scene.
  108809. * true by default if setupImageProcessing is true.
  108810. */
  108811. toneMappingEnabled: boolean;
  108812. }
  108813. /**
  108814. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  108815. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  108816. * It also helps with the default setup of your imageProcessing configuration.
  108817. */
  108818. export class EnvironmentHelper {
  108819. /**
  108820. * Default ground texture URL.
  108821. */
  108822. private static _groundTextureCDNUrl;
  108823. /**
  108824. * Default skybox texture URL.
  108825. */
  108826. private static _skyboxTextureCDNUrl;
  108827. /**
  108828. * Default environment texture URL.
  108829. */
  108830. private static _environmentTextureCDNUrl;
  108831. /**
  108832. * Creates the default options for the helper.
  108833. */
  108834. private static _getDefaultOptions;
  108835. private _rootMesh;
  108836. /**
  108837. * Gets the root mesh created by the helper.
  108838. */
  108839. readonly rootMesh: Mesh;
  108840. private _skybox;
  108841. /**
  108842. * Gets the skybox created by the helper.
  108843. */
  108844. readonly skybox: Nullable<Mesh>;
  108845. private _skyboxTexture;
  108846. /**
  108847. * Gets the skybox texture created by the helper.
  108848. */
  108849. readonly skyboxTexture: Nullable<BaseTexture>;
  108850. private _skyboxMaterial;
  108851. /**
  108852. * Gets the skybox material created by the helper.
  108853. */
  108854. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  108855. private _ground;
  108856. /**
  108857. * Gets the ground mesh created by the helper.
  108858. */
  108859. readonly ground: Nullable<Mesh>;
  108860. private _groundTexture;
  108861. /**
  108862. * Gets the ground texture created by the helper.
  108863. */
  108864. readonly groundTexture: Nullable<BaseTexture>;
  108865. private _groundMirror;
  108866. /**
  108867. * Gets the ground mirror created by the helper.
  108868. */
  108869. readonly groundMirror: Nullable<MirrorTexture>;
  108870. /**
  108871. * Gets the ground mirror render list to helps pushing the meshes
  108872. * you wish in the ground reflection.
  108873. */
  108874. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  108875. private _groundMaterial;
  108876. /**
  108877. * Gets the ground material created by the helper.
  108878. */
  108879. readonly groundMaterial: Nullable<BackgroundMaterial>;
  108880. /**
  108881. * Stores the creation options.
  108882. */
  108883. private readonly _scene;
  108884. private _options;
  108885. /**
  108886. * This observable will be notified with any error during the creation of the environment,
  108887. * mainly texture creation errors.
  108888. */
  108889. onErrorObservable: Observable<{
  108890. message?: string;
  108891. exception?: any;
  108892. }>;
  108893. /**
  108894. * constructor
  108895. * @param options Defines the options we want to customize the helper
  108896. * @param scene The scene to add the material to
  108897. */
  108898. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  108899. /**
  108900. * Updates the background according to the new options
  108901. * @param options
  108902. */
  108903. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  108904. /**
  108905. * Sets the primary color of all the available elements.
  108906. * @param color the main color to affect to the ground and the background
  108907. */
  108908. setMainColor(color: Color3): void;
  108909. /**
  108910. * Setup the image processing according to the specified options.
  108911. */
  108912. private _setupImageProcessing;
  108913. /**
  108914. * Setup the environment texture according to the specified options.
  108915. */
  108916. private _setupEnvironmentTexture;
  108917. /**
  108918. * Setup the background according to the specified options.
  108919. */
  108920. private _setupBackground;
  108921. /**
  108922. * Get the scene sizes according to the setup.
  108923. */
  108924. private _getSceneSize;
  108925. /**
  108926. * Setup the ground according to the specified options.
  108927. */
  108928. private _setupGround;
  108929. /**
  108930. * Setup the ground material according to the specified options.
  108931. */
  108932. private _setupGroundMaterial;
  108933. /**
  108934. * Setup the ground diffuse texture according to the specified options.
  108935. */
  108936. private _setupGroundDiffuseTexture;
  108937. /**
  108938. * Setup the ground mirror texture according to the specified options.
  108939. */
  108940. private _setupGroundMirrorTexture;
  108941. /**
  108942. * Setup the ground to receive the mirror texture.
  108943. */
  108944. private _setupMirrorInGroundMaterial;
  108945. /**
  108946. * Setup the skybox according to the specified options.
  108947. */
  108948. private _setupSkybox;
  108949. /**
  108950. * Setup the skybox material according to the specified options.
  108951. */
  108952. private _setupSkyboxMaterial;
  108953. /**
  108954. * Setup the skybox reflection texture according to the specified options.
  108955. */
  108956. private _setupSkyboxReflectionTexture;
  108957. private _errorHandler;
  108958. /**
  108959. * Dispose all the elements created by the Helper.
  108960. */
  108961. dispose(): void;
  108962. }
  108963. }
  108964. declare module BABYLON {
  108965. /**
  108966. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108967. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108968. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108969. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108970. */
  108971. export class PhotoDome extends TransformNode {
  108972. /**
  108973. * Define the image as a Monoscopic panoramic 360 image.
  108974. */
  108975. static readonly MODE_MONOSCOPIC: number;
  108976. /**
  108977. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108978. */
  108979. static readonly MODE_TOPBOTTOM: number;
  108980. /**
  108981. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108982. */
  108983. static readonly MODE_SIDEBYSIDE: number;
  108984. private _useDirectMapping;
  108985. /**
  108986. * The texture being displayed on the sphere
  108987. */
  108988. protected _photoTexture: Texture;
  108989. /**
  108990. * Gets or sets the texture being displayed on the sphere
  108991. */
  108992. photoTexture: Texture;
  108993. /**
  108994. * Observable raised when an error occured while loading the 360 image
  108995. */
  108996. onLoadErrorObservable: Observable<string>;
  108997. /**
  108998. * The skybox material
  108999. */
  109000. protected _material: BackgroundMaterial;
  109001. /**
  109002. * The surface used for the skybox
  109003. */
  109004. protected _mesh: Mesh;
  109005. /**
  109006. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109007. * Also see the options.resolution property.
  109008. */
  109009. fovMultiplier: number;
  109010. private _imageMode;
  109011. /**
  109012. * Gets or set the current video mode for the video. It can be:
  109013. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  109014. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109015. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109016. */
  109017. imageMode: number;
  109018. /**
  109019. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  109020. * @param name Element's name, child elements will append suffixes for their own names.
  109021. * @param urlsOfPhoto defines the url of the photo to display
  109022. * @param options defines an object containing optional or exposed sub element properties
  109023. * @param onError defines a callback called when an error occured while loading the texture
  109024. */
  109025. constructor(name: string, urlOfPhoto: string, options: {
  109026. resolution?: number;
  109027. size?: number;
  109028. useDirectMapping?: boolean;
  109029. faceForward?: boolean;
  109030. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  109031. private _onBeforeCameraRenderObserver;
  109032. private _changeImageMode;
  109033. /**
  109034. * Releases resources associated with this node.
  109035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109037. */
  109038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109039. }
  109040. }
  109041. declare module BABYLON {
  109042. /** @hidden */
  109043. export var rgbdDecodePixelShader: {
  109044. name: string;
  109045. shader: string;
  109046. };
  109047. }
  109048. declare module BABYLON {
  109049. /**
  109050. * Class used to host texture specific utilities
  109051. */
  109052. export class BRDFTextureTools {
  109053. /**
  109054. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109055. * @param texture the texture to expand.
  109056. */
  109057. private static _ExpandDefaultBRDFTexture;
  109058. /**
  109059. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109060. * @param scene defines the hosting scene
  109061. * @returns the environment BRDF texture
  109062. */
  109063. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109064. private static _environmentBRDFBase64Texture;
  109065. }
  109066. }
  109067. declare module BABYLON {
  109068. /**
  109069. * @hidden
  109070. */
  109071. export interface IMaterialClearCoatDefines {
  109072. CLEARCOAT: boolean;
  109073. CLEARCOAT_DEFAULTIOR: boolean;
  109074. CLEARCOAT_TEXTURE: boolean;
  109075. CLEARCOAT_TEXTUREDIRECTUV: number;
  109076. CLEARCOAT_BUMP: boolean;
  109077. CLEARCOAT_BUMPDIRECTUV: number;
  109078. CLEARCOAT_TINT: boolean;
  109079. CLEARCOAT_TINT_TEXTURE: boolean;
  109080. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109081. /** @hidden */
  109082. _areTexturesDirty: boolean;
  109083. }
  109084. /**
  109085. * Define the code related to the clear coat parameters of the pbr material.
  109086. */
  109087. export class PBRClearCoatConfiguration {
  109088. /**
  109089. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109090. * The default fits with a polyurethane material.
  109091. */
  109092. private static readonly _DefaultIndexOfRefraction;
  109093. private _isEnabled;
  109094. /**
  109095. * Defines if the clear coat is enabled in the material.
  109096. */
  109097. isEnabled: boolean;
  109098. /**
  109099. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109100. */
  109101. intensity: number;
  109102. /**
  109103. * Defines the clear coat layer roughness.
  109104. */
  109105. roughness: number;
  109106. private _indexOfRefraction;
  109107. /**
  109108. * Defines the index of refraction of the clear coat.
  109109. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109110. * The default fits with a polyurethane material.
  109111. * Changing the default value is more performance intensive.
  109112. */
  109113. indexOfRefraction: number;
  109114. private _texture;
  109115. /**
  109116. * Stores the clear coat values in a texture.
  109117. */
  109118. texture: Nullable<BaseTexture>;
  109119. private _bumpTexture;
  109120. /**
  109121. * Define the clear coat specific bump texture.
  109122. */
  109123. bumpTexture: Nullable<BaseTexture>;
  109124. private _isTintEnabled;
  109125. /**
  109126. * Defines if the clear coat tint is enabled in the material.
  109127. */
  109128. isTintEnabled: boolean;
  109129. /**
  109130. * Defines the clear coat tint of the material.
  109131. * This is only use if tint is enabled
  109132. */
  109133. tintColor: Color3;
  109134. /**
  109135. * Defines the distance at which the tint color should be found in the
  109136. * clear coat media.
  109137. * This is only use if tint is enabled
  109138. */
  109139. tintColorAtDistance: number;
  109140. /**
  109141. * Defines the clear coat layer thickness.
  109142. * This is only use if tint is enabled
  109143. */
  109144. tintThickness: number;
  109145. private _tintTexture;
  109146. /**
  109147. * Stores the clear tint values in a texture.
  109148. * rgb is tint
  109149. * a is a thickness factor
  109150. */
  109151. tintTexture: Nullable<BaseTexture>;
  109152. /** @hidden */
  109153. private _internalMarkAllSubMeshesAsTexturesDirty;
  109154. /** @hidden */
  109155. _markAllSubMeshesAsTexturesDirty(): void;
  109156. /**
  109157. * Instantiate a new istance of clear coat configuration.
  109158. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109159. */
  109160. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109161. /**
  109162. * Gets wehter the submesh is ready to be used or not.
  109163. * @param defines the list of "defines" to update.
  109164. * @param scene defines the scene the material belongs to.
  109165. * @param engine defines the engine the material belongs to.
  109166. * @param disableBumpMap defines wether the material disables bump or not.
  109167. * @returns - boolean indicating that the submesh is ready or not.
  109168. */
  109169. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  109170. /**
  109171. * Checks to see if a texture is used in the material.
  109172. * @param defines the list of "defines" to update.
  109173. * @param scene defines the scene to the material belongs to.
  109174. */
  109175. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  109176. /**
  109177. * Binds the material data.
  109178. * @param uniformBuffer defines the Uniform buffer to fill in.
  109179. * @param scene defines the scene the material belongs to.
  109180. * @param engine defines the engine the material belongs to.
  109181. * @param disableBumpMap defines wether the material disables bump or not.
  109182. * @param isFrozen defines wether the material is frozen or not.
  109183. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109184. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109185. */
  109186. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  109187. /**
  109188. * Checks to see if a texture is used in the material.
  109189. * @param texture - Base texture to use.
  109190. * @returns - Boolean specifying if a texture is used in the material.
  109191. */
  109192. hasTexture(texture: BaseTexture): boolean;
  109193. /**
  109194. * Returns an array of the actively used textures.
  109195. * @param activeTextures Array of BaseTextures
  109196. */
  109197. getActiveTextures(activeTextures: BaseTexture[]): void;
  109198. /**
  109199. * Returns the animatable textures.
  109200. * @param animatables Array of animatable textures.
  109201. */
  109202. getAnimatables(animatables: IAnimatable[]): void;
  109203. /**
  109204. * Disposes the resources of the material.
  109205. * @param forceDisposeTextures - Forces the disposal of all textures.
  109206. */
  109207. dispose(forceDisposeTextures?: boolean): void;
  109208. /**
  109209. * Get the current class name of the texture useful for serialization or dynamic coding.
  109210. * @returns "PBRClearCoatConfiguration"
  109211. */
  109212. getClassName(): string;
  109213. /**
  109214. * Add fallbacks to the effect fallbacks list.
  109215. * @param defines defines the Base texture to use.
  109216. * @param fallbacks defines the current fallback list.
  109217. * @param currentRank defines the current fallback rank.
  109218. * @returns the new fallback rank.
  109219. */
  109220. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109221. /**
  109222. * Add the required uniforms to the current list.
  109223. * @param uniforms defines the current uniform list.
  109224. */
  109225. static AddUniforms(uniforms: string[]): void;
  109226. /**
  109227. * Add the required samplers to the current list.
  109228. * @param samplers defines the current sampler list.
  109229. */
  109230. static AddSamplers(samplers: string[]): void;
  109231. /**
  109232. * Add the required uniforms to the current buffer.
  109233. * @param uniformBuffer defines the current uniform buffer.
  109234. */
  109235. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109236. /**
  109237. * Makes a duplicate of the current configuration into another one.
  109238. * @param clearCoatConfiguration define the config where to copy the info
  109239. */
  109240. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  109241. /**
  109242. * Serializes this clear coat configuration.
  109243. * @returns - An object with the serialized config.
  109244. */
  109245. serialize(): any;
  109246. /**
  109247. * Parses a anisotropy Configuration from a serialized object.
  109248. * @param source - Serialized object.
  109249. * @param scene Defines the scene we are parsing for
  109250. * @param rootUrl Defines the rootUrl to load from
  109251. */
  109252. parse(source: any, scene: Scene, rootUrl: string): void;
  109253. }
  109254. }
  109255. declare module BABYLON {
  109256. /**
  109257. * @hidden
  109258. */
  109259. export interface IMaterialAnisotropicDefines {
  109260. ANISOTROPIC: boolean;
  109261. ANISOTROPIC_TEXTURE: boolean;
  109262. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109263. MAINUV1: boolean;
  109264. _areTexturesDirty: boolean;
  109265. _needUVs: boolean;
  109266. }
  109267. /**
  109268. * Define the code related to the anisotropic parameters of the pbr material.
  109269. */
  109270. export class PBRAnisotropicConfiguration {
  109271. private _isEnabled;
  109272. /**
  109273. * Defines if the anisotropy is enabled in the material.
  109274. */
  109275. isEnabled: boolean;
  109276. /**
  109277. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109278. */
  109279. intensity: number;
  109280. /**
  109281. * Defines if the effect is along the tangents, bitangents or in between.
  109282. * By default, the effect is "strectching" the highlights along the tangents.
  109283. */
  109284. direction: Vector2;
  109285. private _texture;
  109286. /**
  109287. * Stores the anisotropy values in a texture.
  109288. * rg is direction (like normal from -1 to 1)
  109289. * b is a intensity
  109290. */
  109291. texture: Nullable<BaseTexture>;
  109292. /** @hidden */
  109293. private _internalMarkAllSubMeshesAsTexturesDirty;
  109294. /** @hidden */
  109295. _markAllSubMeshesAsTexturesDirty(): void;
  109296. /**
  109297. * Instantiate a new istance of anisotropy configuration.
  109298. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109299. */
  109300. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109301. /**
  109302. * Specifies that the submesh is ready to be used.
  109303. * @param defines the list of "defines" to update.
  109304. * @param scene defines the scene the material belongs to.
  109305. * @returns - boolean indicating that the submesh is ready or not.
  109306. */
  109307. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109308. /**
  109309. * Checks to see if a texture is used in the material.
  109310. * @param defines the list of "defines" to update.
  109311. * @param mesh the mesh we are preparing the defines for.
  109312. * @param scene defines the scene the material belongs to.
  109313. */
  109314. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109315. /**
  109316. * Binds the material data.
  109317. * @param uniformBuffer defines the Uniform buffer to fill in.
  109318. * @param scene defines the scene the material belongs to.
  109319. * @param isFrozen defines wether the material is frozen or not.
  109320. */
  109321. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109322. /**
  109323. * Checks to see if a texture is used in the material.
  109324. * @param texture - Base texture to use.
  109325. * @returns - Boolean specifying if a texture is used in the material.
  109326. */
  109327. hasTexture(texture: BaseTexture): boolean;
  109328. /**
  109329. * Returns an array of the actively used textures.
  109330. * @param activeTextures Array of BaseTextures
  109331. */
  109332. getActiveTextures(activeTextures: BaseTexture[]): void;
  109333. /**
  109334. * Returns the animatable textures.
  109335. * @param animatables Array of animatable textures.
  109336. */
  109337. getAnimatables(animatables: IAnimatable[]): void;
  109338. /**
  109339. * Disposes the resources of the material.
  109340. * @param forceDisposeTextures - Forces the disposal of all textures.
  109341. */
  109342. dispose(forceDisposeTextures?: boolean): void;
  109343. /**
  109344. * Get the current class name of the texture useful for serialization or dynamic coding.
  109345. * @returns "PBRAnisotropicConfiguration"
  109346. */
  109347. getClassName(): string;
  109348. /**
  109349. * Add fallbacks to the effect fallbacks list.
  109350. * @param defines defines the Base texture to use.
  109351. * @param fallbacks defines the current fallback list.
  109352. * @param currentRank defines the current fallback rank.
  109353. * @returns the new fallback rank.
  109354. */
  109355. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109356. /**
  109357. * Add the required uniforms to the current list.
  109358. * @param uniforms defines the current uniform list.
  109359. */
  109360. static AddUniforms(uniforms: string[]): void;
  109361. /**
  109362. * Add the required uniforms to the current buffer.
  109363. * @param uniformBuffer defines the current uniform buffer.
  109364. */
  109365. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109366. /**
  109367. * Add the required samplers to the current list.
  109368. * @param samplers defines the current sampler list.
  109369. */
  109370. static AddSamplers(samplers: string[]): void;
  109371. /**
  109372. * Makes a duplicate of the current configuration into another one.
  109373. * @param anisotropicConfiguration define the config where to copy the info
  109374. */
  109375. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109376. /**
  109377. * Serializes this anisotropy configuration.
  109378. * @returns - An object with the serialized config.
  109379. */
  109380. serialize(): any;
  109381. /**
  109382. * Parses a anisotropy Configuration from a serialized object.
  109383. * @param source - Serialized object.
  109384. * @param scene Defines the scene we are parsing for
  109385. * @param rootUrl Defines the rootUrl to load from
  109386. */
  109387. parse(source: any, scene: Scene, rootUrl: string): void;
  109388. }
  109389. }
  109390. declare module BABYLON {
  109391. /**
  109392. * @hidden
  109393. */
  109394. export interface IMaterialBRDFDefines {
  109395. BRDF_V_HEIGHT_CORRELATED: boolean;
  109396. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109397. SPHERICAL_HARMONICS: boolean;
  109398. /** @hidden */
  109399. _areMiscDirty: boolean;
  109400. }
  109401. /**
  109402. * Define the code related to the BRDF parameters of the pbr material.
  109403. */
  109404. export class PBRBRDFConfiguration {
  109405. /**
  109406. * Default value used for the energy conservation.
  109407. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109408. */
  109409. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109410. /**
  109411. * Default value used for the Smith Visibility Height Correlated mode.
  109412. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109413. */
  109414. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109415. /**
  109416. * Default value used for the IBL diffuse part.
  109417. * This can help switching back to the polynomials mode globally which is a tiny bit
  109418. * less GPU intensive at the drawback of a lower quality.
  109419. */
  109420. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109421. private _useEnergyConservation;
  109422. /**
  109423. * Defines if the material uses energy conservation.
  109424. */
  109425. useEnergyConservation: boolean;
  109426. private _useSmithVisibilityHeightCorrelated;
  109427. /**
  109428. * LEGACY Mode set to false
  109429. * Defines if the material uses height smith correlated visibility term.
  109430. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109431. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109432. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109433. * Not relying on height correlated will also disable energy conservation.
  109434. */
  109435. useSmithVisibilityHeightCorrelated: boolean;
  109436. private _useSphericalHarmonics;
  109437. /**
  109438. * LEGACY Mode set to false
  109439. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109440. * diffuse part of the IBL.
  109441. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109442. * to the ground truth.
  109443. */
  109444. useSphericalHarmonics: boolean;
  109445. /** @hidden */
  109446. private _internalMarkAllSubMeshesAsMiscDirty;
  109447. /** @hidden */
  109448. _markAllSubMeshesAsMiscDirty(): void;
  109449. /**
  109450. * Instantiate a new istance of clear coat configuration.
  109451. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109452. */
  109453. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109454. /**
  109455. * Checks to see if a texture is used in the material.
  109456. * @param defines the list of "defines" to update.
  109457. */
  109458. prepareDefines(defines: IMaterialBRDFDefines): void;
  109459. /**
  109460. * Get the current class name of the texture useful for serialization or dynamic coding.
  109461. * @returns "PBRClearCoatConfiguration"
  109462. */
  109463. getClassName(): string;
  109464. /**
  109465. * Makes a duplicate of the current configuration into another one.
  109466. * @param brdfConfiguration define the config where to copy the info
  109467. */
  109468. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109469. /**
  109470. * Serializes this BRDF configuration.
  109471. * @returns - An object with the serialized config.
  109472. */
  109473. serialize(): any;
  109474. /**
  109475. * Parses a anisotropy Configuration from a serialized object.
  109476. * @param source - Serialized object.
  109477. * @param scene Defines the scene we are parsing for
  109478. * @param rootUrl Defines the rootUrl to load from
  109479. */
  109480. parse(source: any, scene: Scene, rootUrl: string): void;
  109481. }
  109482. }
  109483. declare module BABYLON {
  109484. /**
  109485. * @hidden
  109486. */
  109487. export interface IMaterialSheenDefines {
  109488. SHEEN: boolean;
  109489. SHEEN_TEXTURE: boolean;
  109490. SHEEN_TEXTUREDIRECTUV: number;
  109491. SHEEN_LINKWITHALBEDO: boolean;
  109492. /** @hidden */
  109493. _areTexturesDirty: boolean;
  109494. }
  109495. /**
  109496. * Define the code related to the Sheen parameters of the pbr material.
  109497. */
  109498. export class PBRSheenConfiguration {
  109499. private _isEnabled;
  109500. /**
  109501. * Defines if the material uses sheen.
  109502. */
  109503. isEnabled: boolean;
  109504. private _linkSheenWithAlbedo;
  109505. /**
  109506. * Defines if the sheen is linked to the sheen color.
  109507. */
  109508. linkSheenWithAlbedo: boolean;
  109509. /**
  109510. * Defines the sheen intensity.
  109511. */
  109512. intensity: number;
  109513. /**
  109514. * Defines the sheen color.
  109515. */
  109516. color: Color3;
  109517. private _texture;
  109518. /**
  109519. * Stores the sheen tint values in a texture.
  109520. * rgb is tint
  109521. * a is a intensity
  109522. */
  109523. texture: Nullable<BaseTexture>;
  109524. /** @hidden */
  109525. private _internalMarkAllSubMeshesAsTexturesDirty;
  109526. /** @hidden */
  109527. _markAllSubMeshesAsTexturesDirty(): void;
  109528. /**
  109529. * Instantiate a new istance of clear coat configuration.
  109530. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109531. */
  109532. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109533. /**
  109534. * Specifies that the submesh is ready to be used.
  109535. * @param defines the list of "defines" to update.
  109536. * @param scene defines the scene the material belongs to.
  109537. * @returns - boolean indicating that the submesh is ready or not.
  109538. */
  109539. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  109540. /**
  109541. * Checks to see if a texture is used in the material.
  109542. * @param defines the list of "defines" to update.
  109543. * @param scene defines the scene the material belongs to.
  109544. */
  109545. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  109546. /**
  109547. * Binds the material data.
  109548. * @param uniformBuffer defines the Uniform buffer to fill in.
  109549. * @param scene defines the scene the material belongs to.
  109550. * @param isFrozen defines wether the material is frozen or not.
  109551. */
  109552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109553. /**
  109554. * Checks to see if a texture is used in the material.
  109555. * @param texture - Base texture to use.
  109556. * @returns - Boolean specifying if a texture is used in the material.
  109557. */
  109558. hasTexture(texture: BaseTexture): boolean;
  109559. /**
  109560. * Returns an array of the actively used textures.
  109561. * @param activeTextures Array of BaseTextures
  109562. */
  109563. getActiveTextures(activeTextures: BaseTexture[]): void;
  109564. /**
  109565. * Returns the animatable textures.
  109566. * @param animatables Array of animatable textures.
  109567. */
  109568. getAnimatables(animatables: IAnimatable[]): void;
  109569. /**
  109570. * Disposes the resources of the material.
  109571. * @param forceDisposeTextures - Forces the disposal of all textures.
  109572. */
  109573. dispose(forceDisposeTextures?: boolean): void;
  109574. /**
  109575. * Get the current class name of the texture useful for serialization or dynamic coding.
  109576. * @returns "PBRSheenConfiguration"
  109577. */
  109578. getClassName(): string;
  109579. /**
  109580. * Add fallbacks to the effect fallbacks list.
  109581. * @param defines defines the Base texture to use.
  109582. * @param fallbacks defines the current fallback list.
  109583. * @param currentRank defines the current fallback rank.
  109584. * @returns the new fallback rank.
  109585. */
  109586. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109587. /**
  109588. * Add the required uniforms to the current list.
  109589. * @param uniforms defines the current uniform list.
  109590. */
  109591. static AddUniforms(uniforms: string[]): void;
  109592. /**
  109593. * Add the required uniforms to the current buffer.
  109594. * @param uniformBuffer defines the current uniform buffer.
  109595. */
  109596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109597. /**
  109598. * Add the required samplers to the current list.
  109599. * @param samplers defines the current sampler list.
  109600. */
  109601. static AddSamplers(samplers: string[]): void;
  109602. /**
  109603. * Makes a duplicate of the current configuration into another one.
  109604. * @param sheenConfiguration define the config where to copy the info
  109605. */
  109606. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  109607. /**
  109608. * Serializes this BRDF configuration.
  109609. * @returns - An object with the serialized config.
  109610. */
  109611. serialize(): any;
  109612. /**
  109613. * Parses a anisotropy Configuration from a serialized object.
  109614. * @param source - Serialized object.
  109615. * @param scene Defines the scene we are parsing for
  109616. * @param rootUrl Defines the rootUrl to load from
  109617. */
  109618. parse(source: any, scene: Scene, rootUrl: string): void;
  109619. }
  109620. }
  109621. declare module BABYLON {
  109622. /**
  109623. * @hidden
  109624. */
  109625. export interface IMaterialSubSurfaceDefines {
  109626. SUBSURFACE: boolean;
  109627. SS_REFRACTION: boolean;
  109628. SS_TRANSLUCENCY: boolean;
  109629. SS_SCATERRING: boolean;
  109630. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109631. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109632. SS_REFRACTIONMAP_3D: boolean;
  109633. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109634. SS_LODINREFRACTIONALPHA: boolean;
  109635. SS_GAMMAREFRACTION: boolean;
  109636. SS_RGBDREFRACTION: boolean;
  109637. SS_LINEARSPECULARREFRACTION: boolean;
  109638. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109639. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109640. /** @hidden */
  109641. _areTexturesDirty: boolean;
  109642. }
  109643. /**
  109644. * Define the code related to the sub surface parameters of the pbr material.
  109645. */
  109646. export class PBRSubSurfaceConfiguration {
  109647. private _isRefractionEnabled;
  109648. /**
  109649. * Defines if the refraction is enabled in the material.
  109650. */
  109651. isRefractionEnabled: boolean;
  109652. private _isTranslucencyEnabled;
  109653. /**
  109654. * Defines if the translucency is enabled in the material.
  109655. */
  109656. isTranslucencyEnabled: boolean;
  109657. private _isScatteringEnabled;
  109658. /**
  109659. * Defines the refraction intensity of the material.
  109660. * The refraction when enabled replaces the Diffuse part of the material.
  109661. * The intensity helps transitionning between diffuse and refraction.
  109662. */
  109663. refractionIntensity: number;
  109664. /**
  109665. * Defines the translucency intensity of the material.
  109666. * When translucency has been enabled, this defines how much of the "translucency"
  109667. * is addded to the diffuse part of the material.
  109668. */
  109669. translucencyIntensity: number;
  109670. /**
  109671. * Defines the scattering intensity of the material.
  109672. * When scattering has been enabled, this defines how much of the "scattered light"
  109673. * is addded to the diffuse part of the material.
  109674. */
  109675. scatteringIntensity: number;
  109676. private _thicknessTexture;
  109677. /**
  109678. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  109679. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  109680. * 0 would mean minimumThickness
  109681. * 1 would mean maximumThickness
  109682. * The other channels might be use as a mask to vary the different effects intensity.
  109683. */
  109684. thicknessTexture: Nullable<BaseTexture>;
  109685. private _refractionTexture;
  109686. /**
  109687. * Defines the texture to use for refraction.
  109688. */
  109689. refractionTexture: Nullable<BaseTexture>;
  109690. private _indexOfRefraction;
  109691. /**
  109692. * Defines the index of refraction used in the material.
  109693. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  109694. */
  109695. indexOfRefraction: number;
  109696. private _invertRefractionY;
  109697. /**
  109698. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109699. */
  109700. invertRefractionY: boolean;
  109701. private _linkRefractionWithTransparency;
  109702. /**
  109703. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109704. * Materials half opaque for instance using refraction could benefit from this control.
  109705. */
  109706. linkRefractionWithTransparency: boolean;
  109707. /**
  109708. * Defines the minimum thickness stored in the thickness map.
  109709. * If no thickness map is defined, this value will be used to simulate thickness.
  109710. */
  109711. minimumThickness: number;
  109712. /**
  109713. * Defines the maximum thickness stored in the thickness map.
  109714. */
  109715. maximumThickness: number;
  109716. /**
  109717. * Defines the volume tint of the material.
  109718. * This is used for both translucency and scattering.
  109719. */
  109720. tintColor: Color3;
  109721. /**
  109722. * Defines the distance at which the tint color should be found in the media.
  109723. * This is used for refraction only.
  109724. */
  109725. tintColorAtDistance: number;
  109726. /**
  109727. * Defines how far each channel transmit through the media.
  109728. * It is defined as a color to simplify it selection.
  109729. */
  109730. diffusionDistance: Color3;
  109731. private _useMaskFromThicknessTexture;
  109732. /**
  109733. * Stores the intensity of the different subsurface effects in the thickness texture.
  109734. * * the green channel is the translucency intensity.
  109735. * * the blue channel is the scattering intensity.
  109736. * * the alpha channel is the refraction intensity.
  109737. */
  109738. useMaskFromThicknessTexture: boolean;
  109739. /** @hidden */
  109740. private _internalMarkAllSubMeshesAsTexturesDirty;
  109741. /** @hidden */
  109742. _markAllSubMeshesAsTexturesDirty(): void;
  109743. /**
  109744. * Instantiate a new istance of sub surface configuration.
  109745. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109746. */
  109747. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109748. /**
  109749. * Gets wehter the submesh is ready to be used or not.
  109750. * @param defines the list of "defines" to update.
  109751. * @param scene defines the scene the material belongs to.
  109752. * @returns - boolean indicating that the submesh is ready or not.
  109753. */
  109754. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  109755. /**
  109756. * Checks to see if a texture is used in the material.
  109757. * @param defines the list of "defines" to update.
  109758. * @param scene defines the scene to the material belongs to.
  109759. */
  109760. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  109761. /**
  109762. * Binds the material data.
  109763. * @param uniformBuffer defines the Uniform buffer to fill in.
  109764. * @param scene defines the scene the material belongs to.
  109765. * @param engine defines the engine the material belongs to.
  109766. * @param isFrozen defines wether the material is frozen or not.
  109767. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  109768. */
  109769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  109770. /**
  109771. * Unbinds the material from the mesh.
  109772. * @param activeEffect defines the effect that should be unbound from.
  109773. * @returns true if unbound, otherwise false
  109774. */
  109775. unbind(activeEffect: Effect): boolean;
  109776. /**
  109777. * Returns the texture used for refraction or null if none is used.
  109778. * @param scene defines the scene the material belongs to.
  109779. * @returns - Refraction texture if present. If no refraction texture and refraction
  109780. * is linked with transparency, returns environment texture. Otherwise, returns null.
  109781. */
  109782. private _getRefractionTexture;
  109783. /**
  109784. * Returns true if alpha blending should be disabled.
  109785. */
  109786. readonly disableAlphaBlending: boolean;
  109787. /**
  109788. * Fills the list of render target textures.
  109789. * @param renderTargets the list of render targets to update
  109790. */
  109791. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  109792. /**
  109793. * Checks to see if a texture is used in the material.
  109794. * @param texture - Base texture to use.
  109795. * @returns - Boolean specifying if a texture is used in the material.
  109796. */
  109797. hasTexture(texture: BaseTexture): boolean;
  109798. /**
  109799. * Gets a boolean indicating that current material needs to register RTT
  109800. * @returns true if this uses a render target otherwise false.
  109801. */
  109802. hasRenderTargetTextures(): boolean;
  109803. /**
  109804. * Returns an array of the actively used textures.
  109805. * @param activeTextures Array of BaseTextures
  109806. */
  109807. getActiveTextures(activeTextures: BaseTexture[]): void;
  109808. /**
  109809. * Returns the animatable textures.
  109810. * @param animatables Array of animatable textures.
  109811. */
  109812. getAnimatables(animatables: IAnimatable[]): void;
  109813. /**
  109814. * Disposes the resources of the material.
  109815. * @param forceDisposeTextures - Forces the disposal of all textures.
  109816. */
  109817. dispose(forceDisposeTextures?: boolean): void;
  109818. /**
  109819. * Get the current class name of the texture useful for serialization or dynamic coding.
  109820. * @returns "PBRSubSurfaceConfiguration"
  109821. */
  109822. getClassName(): string;
  109823. /**
  109824. * Add fallbacks to the effect fallbacks list.
  109825. * @param defines defines the Base texture to use.
  109826. * @param fallbacks defines the current fallback list.
  109827. * @param currentRank defines the current fallback rank.
  109828. * @returns the new fallback rank.
  109829. */
  109830. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109831. /**
  109832. * Add the required uniforms to the current list.
  109833. * @param uniforms defines the current uniform list.
  109834. */
  109835. static AddUniforms(uniforms: string[]): void;
  109836. /**
  109837. * Add the required samplers to the current list.
  109838. * @param samplers defines the current sampler list.
  109839. */
  109840. static AddSamplers(samplers: string[]): void;
  109841. /**
  109842. * Add the required uniforms to the current buffer.
  109843. * @param uniformBuffer defines the current uniform buffer.
  109844. */
  109845. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109846. /**
  109847. * Makes a duplicate of the current configuration into another one.
  109848. * @param configuration define the config where to copy the info
  109849. */
  109850. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  109851. /**
  109852. * Serializes this Sub Surface configuration.
  109853. * @returns - An object with the serialized config.
  109854. */
  109855. serialize(): any;
  109856. /**
  109857. * Parses a anisotropy Configuration from a serialized object.
  109858. * @param source - Serialized object.
  109859. * @param scene Defines the scene we are parsing for
  109860. * @param rootUrl Defines the rootUrl to load from
  109861. */
  109862. parse(source: any, scene: Scene, rootUrl: string): void;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. /** @hidden */
  109867. export var pbrFragmentDeclaration: {
  109868. name: string;
  109869. shader: string;
  109870. };
  109871. }
  109872. declare module BABYLON {
  109873. /** @hidden */
  109874. export var pbrUboDeclaration: {
  109875. name: string;
  109876. shader: string;
  109877. };
  109878. }
  109879. declare module BABYLON {
  109880. /** @hidden */
  109881. export var pbrFragmentExtraDeclaration: {
  109882. name: string;
  109883. shader: string;
  109884. };
  109885. }
  109886. declare module BABYLON {
  109887. /** @hidden */
  109888. export var pbrFragmentSamplersDeclaration: {
  109889. name: string;
  109890. shader: string;
  109891. };
  109892. }
  109893. declare module BABYLON {
  109894. /** @hidden */
  109895. export var pbrHelperFunctions: {
  109896. name: string;
  109897. shader: string;
  109898. };
  109899. }
  109900. declare module BABYLON {
  109901. /** @hidden */
  109902. export var harmonicsFunctions: {
  109903. name: string;
  109904. shader: string;
  109905. };
  109906. }
  109907. declare module BABYLON {
  109908. /** @hidden */
  109909. export var pbrDirectLightingSetupFunctions: {
  109910. name: string;
  109911. shader: string;
  109912. };
  109913. }
  109914. declare module BABYLON {
  109915. /** @hidden */
  109916. export var pbrDirectLightingFalloffFunctions: {
  109917. name: string;
  109918. shader: string;
  109919. };
  109920. }
  109921. declare module BABYLON {
  109922. /** @hidden */
  109923. export var pbrBRDFFunctions: {
  109924. name: string;
  109925. shader: string;
  109926. };
  109927. }
  109928. declare module BABYLON {
  109929. /** @hidden */
  109930. export var pbrDirectLightingFunctions: {
  109931. name: string;
  109932. shader: string;
  109933. };
  109934. }
  109935. declare module BABYLON {
  109936. /** @hidden */
  109937. export var pbrIBLFunctions: {
  109938. name: string;
  109939. shader: string;
  109940. };
  109941. }
  109942. declare module BABYLON {
  109943. /** @hidden */
  109944. export var pbrDebug: {
  109945. name: string;
  109946. shader: string;
  109947. };
  109948. }
  109949. declare module BABYLON {
  109950. /** @hidden */
  109951. export var pbrPixelShader: {
  109952. name: string;
  109953. shader: string;
  109954. };
  109955. }
  109956. declare module BABYLON {
  109957. /** @hidden */
  109958. export var pbrVertexDeclaration: {
  109959. name: string;
  109960. shader: string;
  109961. };
  109962. }
  109963. declare module BABYLON {
  109964. /** @hidden */
  109965. export var pbrVertexShader: {
  109966. name: string;
  109967. shader: string;
  109968. };
  109969. }
  109970. declare module BABYLON {
  109971. /**
  109972. * Manages the defines for the PBR Material.
  109973. * @hidden
  109974. */
  109975. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109976. PBR: boolean;
  109977. MAINUV1: boolean;
  109978. MAINUV2: boolean;
  109979. UV1: boolean;
  109980. UV2: boolean;
  109981. ALBEDO: boolean;
  109982. ALBEDODIRECTUV: number;
  109983. VERTEXCOLOR: boolean;
  109984. AMBIENT: boolean;
  109985. AMBIENTDIRECTUV: number;
  109986. AMBIENTINGRAYSCALE: boolean;
  109987. OPACITY: boolean;
  109988. VERTEXALPHA: boolean;
  109989. OPACITYDIRECTUV: number;
  109990. OPACITYRGB: boolean;
  109991. ALPHATEST: boolean;
  109992. DEPTHPREPASS: boolean;
  109993. ALPHABLEND: boolean;
  109994. ALPHAFROMALBEDO: boolean;
  109995. ALPHATESTVALUE: string;
  109996. SPECULAROVERALPHA: boolean;
  109997. RADIANCEOVERALPHA: boolean;
  109998. ALPHAFRESNEL: boolean;
  109999. LINEARALPHAFRESNEL: boolean;
  110000. PREMULTIPLYALPHA: boolean;
  110001. EMISSIVE: boolean;
  110002. EMISSIVEDIRECTUV: number;
  110003. REFLECTIVITY: boolean;
  110004. REFLECTIVITYDIRECTUV: number;
  110005. SPECULARTERM: boolean;
  110006. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  110007. MICROSURFACEAUTOMATIC: boolean;
  110008. LODBASEDMICROSFURACE: boolean;
  110009. MICROSURFACEMAP: boolean;
  110010. MICROSURFACEMAPDIRECTUV: number;
  110011. METALLICWORKFLOW: boolean;
  110012. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  110013. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  110014. METALLNESSSTOREINMETALMAPBLUE: boolean;
  110015. AOSTOREINMETALMAPRED: boolean;
  110016. ENVIRONMENTBRDF: boolean;
  110017. ENVIRONMENTBRDF_RGBD: boolean;
  110018. NORMAL: boolean;
  110019. TANGENT: boolean;
  110020. BUMP: boolean;
  110021. BUMPDIRECTUV: number;
  110022. OBJECTSPACE_NORMALMAP: boolean;
  110023. PARALLAX: boolean;
  110024. PARALLAXOCCLUSION: boolean;
  110025. NORMALXYSCALE: boolean;
  110026. LIGHTMAP: boolean;
  110027. LIGHTMAPDIRECTUV: number;
  110028. USELIGHTMAPASSHADOWMAP: boolean;
  110029. GAMMALIGHTMAP: boolean;
  110030. REFLECTION: boolean;
  110031. REFLECTIONMAP_3D: boolean;
  110032. REFLECTIONMAP_SPHERICAL: boolean;
  110033. REFLECTIONMAP_PLANAR: boolean;
  110034. REFLECTIONMAP_CUBIC: boolean;
  110035. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110036. REFLECTIONMAP_PROJECTION: boolean;
  110037. REFLECTIONMAP_SKYBOX: boolean;
  110038. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  110039. REFLECTIONMAP_EXPLICIT: boolean;
  110040. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110041. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110042. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110043. INVERTCUBICMAP: boolean;
  110044. USESPHERICALFROMREFLECTIONMAP: boolean;
  110045. USEIRRADIANCEMAP: boolean;
  110046. SPHERICAL_HARMONICS: boolean;
  110047. USESPHERICALINVERTEX: boolean;
  110048. REFLECTIONMAP_OPPOSITEZ: boolean;
  110049. LODINREFLECTIONALPHA: boolean;
  110050. GAMMAREFLECTION: boolean;
  110051. RGBDREFLECTION: boolean;
  110052. LINEARSPECULARREFLECTION: boolean;
  110053. RADIANCEOCCLUSION: boolean;
  110054. HORIZONOCCLUSION: boolean;
  110055. INSTANCES: boolean;
  110056. NUM_BONE_INFLUENCERS: number;
  110057. BonesPerMesh: number;
  110058. BONETEXTURE: boolean;
  110059. NONUNIFORMSCALING: boolean;
  110060. MORPHTARGETS: boolean;
  110061. MORPHTARGETS_NORMAL: boolean;
  110062. MORPHTARGETS_TANGENT: boolean;
  110063. MORPHTARGETS_UV: boolean;
  110064. NUM_MORPH_INFLUENCERS: number;
  110065. IMAGEPROCESSING: boolean;
  110066. VIGNETTE: boolean;
  110067. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110068. VIGNETTEBLENDMODEOPAQUE: boolean;
  110069. TONEMAPPING: boolean;
  110070. TONEMAPPING_ACES: boolean;
  110071. CONTRAST: boolean;
  110072. COLORCURVES: boolean;
  110073. COLORGRADING: boolean;
  110074. COLORGRADING3D: boolean;
  110075. SAMPLER3DGREENDEPTH: boolean;
  110076. SAMPLER3DBGRMAP: boolean;
  110077. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110078. EXPOSURE: boolean;
  110079. MULTIVIEW: boolean;
  110080. USEPHYSICALLIGHTFALLOFF: boolean;
  110081. USEGLTFLIGHTFALLOFF: boolean;
  110082. TWOSIDEDLIGHTING: boolean;
  110083. SHADOWFLOAT: boolean;
  110084. CLIPPLANE: boolean;
  110085. CLIPPLANE2: boolean;
  110086. CLIPPLANE3: boolean;
  110087. CLIPPLANE4: boolean;
  110088. POINTSIZE: boolean;
  110089. FOG: boolean;
  110090. LOGARITHMICDEPTH: boolean;
  110091. FORCENORMALFORWARD: boolean;
  110092. SPECULARAA: boolean;
  110093. CLEARCOAT: boolean;
  110094. CLEARCOAT_DEFAULTIOR: boolean;
  110095. CLEARCOAT_TEXTURE: boolean;
  110096. CLEARCOAT_TEXTUREDIRECTUV: number;
  110097. CLEARCOAT_BUMP: boolean;
  110098. CLEARCOAT_BUMPDIRECTUV: number;
  110099. CLEARCOAT_TINT: boolean;
  110100. CLEARCOAT_TINT_TEXTURE: boolean;
  110101. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110102. ANISOTROPIC: boolean;
  110103. ANISOTROPIC_TEXTURE: boolean;
  110104. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110105. BRDF_V_HEIGHT_CORRELATED: boolean;
  110106. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110107. SHEEN: boolean;
  110108. SHEEN_TEXTURE: boolean;
  110109. SHEEN_TEXTUREDIRECTUV: number;
  110110. SHEEN_LINKWITHALBEDO: boolean;
  110111. SUBSURFACE: boolean;
  110112. SS_REFRACTION: boolean;
  110113. SS_TRANSLUCENCY: boolean;
  110114. SS_SCATERRING: boolean;
  110115. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110116. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110117. SS_REFRACTIONMAP_3D: boolean;
  110118. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110119. SS_LODINREFRACTIONALPHA: boolean;
  110120. SS_GAMMAREFRACTION: boolean;
  110121. SS_RGBDREFRACTION: boolean;
  110122. SS_LINEARSPECULARREFRACTION: boolean;
  110123. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110124. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110125. UNLIT: boolean;
  110126. DEBUGMODE: number;
  110127. /**
  110128. * Initializes the PBR Material defines.
  110129. */
  110130. constructor();
  110131. /**
  110132. * Resets the PBR Material defines.
  110133. */
  110134. reset(): void;
  110135. }
  110136. /**
  110137. * The Physically based material base class of BJS.
  110138. *
  110139. * This offers the main features of a standard PBR material.
  110140. * For more information, please refer to the documentation :
  110141. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110142. */
  110143. export abstract class PBRBaseMaterial extends PushMaterial {
  110144. /**
  110145. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110146. */
  110147. static readonly PBRMATERIAL_OPAQUE: number;
  110148. /**
  110149. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110150. */
  110151. static readonly PBRMATERIAL_ALPHATEST: number;
  110152. /**
  110153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110154. */
  110155. static readonly PBRMATERIAL_ALPHABLEND: number;
  110156. /**
  110157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110158. * They are also discarded below the alpha cutoff threshold to improve performances.
  110159. */
  110160. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110161. /**
  110162. * Defines the default value of how much AO map is occluding the analytical lights
  110163. * (point spot...).
  110164. */
  110165. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110166. /**
  110167. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  110168. */
  110169. static readonly LIGHTFALLOFF_PHYSICAL: number;
  110170. /**
  110171. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  110172. * to enhance interoperability with other engines.
  110173. */
  110174. static readonly LIGHTFALLOFF_GLTF: number;
  110175. /**
  110176. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  110177. * to enhance interoperability with other materials.
  110178. */
  110179. static readonly LIGHTFALLOFF_STANDARD: number;
  110180. /**
  110181. * Intensity of the direct lights e.g. the four lights available in your scene.
  110182. * This impacts both the direct diffuse and specular highlights.
  110183. */
  110184. protected _directIntensity: number;
  110185. /**
  110186. * Intensity of the emissive part of the material.
  110187. * This helps controlling the emissive effect without modifying the emissive color.
  110188. */
  110189. protected _emissiveIntensity: number;
  110190. /**
  110191. * Intensity of the environment e.g. how much the environment will light the object
  110192. * either through harmonics for rough material or through the refelction for shiny ones.
  110193. */
  110194. protected _environmentIntensity: number;
  110195. /**
  110196. * This is a special control allowing the reduction of the specular highlights coming from the
  110197. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110198. */
  110199. protected _specularIntensity: number;
  110200. /**
  110201. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  110202. */
  110203. private _lightingInfos;
  110204. /**
  110205. * Debug Control allowing disabling the bump map on this material.
  110206. */
  110207. protected _disableBumpMap: boolean;
  110208. /**
  110209. * AKA Diffuse Texture in standard nomenclature.
  110210. */
  110211. protected _albedoTexture: Nullable<BaseTexture>;
  110212. /**
  110213. * AKA Occlusion Texture in other nomenclature.
  110214. */
  110215. protected _ambientTexture: Nullable<BaseTexture>;
  110216. /**
  110217. * AKA Occlusion Texture Intensity in other nomenclature.
  110218. */
  110219. protected _ambientTextureStrength: number;
  110220. /**
  110221. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110222. * 1 means it completely occludes it
  110223. * 0 mean it has no impact
  110224. */
  110225. protected _ambientTextureImpactOnAnalyticalLights: number;
  110226. /**
  110227. * Stores the alpha values in a texture.
  110228. */
  110229. protected _opacityTexture: Nullable<BaseTexture>;
  110230. /**
  110231. * Stores the reflection values in a texture.
  110232. */
  110233. protected _reflectionTexture: Nullable<BaseTexture>;
  110234. /**
  110235. * Stores the emissive values in a texture.
  110236. */
  110237. protected _emissiveTexture: Nullable<BaseTexture>;
  110238. /**
  110239. * AKA Specular texture in other nomenclature.
  110240. */
  110241. protected _reflectivityTexture: Nullable<BaseTexture>;
  110242. /**
  110243. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110244. */
  110245. protected _metallicTexture: Nullable<BaseTexture>;
  110246. /**
  110247. * Specifies the metallic scalar of the metallic/roughness workflow.
  110248. * Can also be used to scale the metalness values of the metallic texture.
  110249. */
  110250. protected _metallic: Nullable<number>;
  110251. /**
  110252. * Specifies the roughness scalar of the metallic/roughness workflow.
  110253. * Can also be used to scale the roughness values of the metallic texture.
  110254. */
  110255. protected _roughness: Nullable<number>;
  110256. /**
  110257. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110258. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110259. */
  110260. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110261. /**
  110262. * Stores surface normal data used to displace a mesh in a texture.
  110263. */
  110264. protected _bumpTexture: Nullable<BaseTexture>;
  110265. /**
  110266. * Stores the pre-calculated light information of a mesh in a texture.
  110267. */
  110268. protected _lightmapTexture: Nullable<BaseTexture>;
  110269. /**
  110270. * The color of a material in ambient lighting.
  110271. */
  110272. protected _ambientColor: Color3;
  110273. /**
  110274. * AKA Diffuse Color in other nomenclature.
  110275. */
  110276. protected _albedoColor: Color3;
  110277. /**
  110278. * AKA Specular Color in other nomenclature.
  110279. */
  110280. protected _reflectivityColor: Color3;
  110281. /**
  110282. * The color applied when light is reflected from a material.
  110283. */
  110284. protected _reflectionColor: Color3;
  110285. /**
  110286. * The color applied when light is emitted from a material.
  110287. */
  110288. protected _emissiveColor: Color3;
  110289. /**
  110290. * AKA Glossiness in other nomenclature.
  110291. */
  110292. protected _microSurface: number;
  110293. /**
  110294. * Specifies that the material will use the light map as a show map.
  110295. */
  110296. protected _useLightmapAsShadowmap: boolean;
  110297. /**
  110298. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110299. * makes the reflect vector face the model (under horizon).
  110300. */
  110301. protected _useHorizonOcclusion: boolean;
  110302. /**
  110303. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110304. * too much the area relying on ambient texture to define their ambient occlusion.
  110305. */
  110306. protected _useRadianceOcclusion: boolean;
  110307. /**
  110308. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110309. */
  110310. protected _useAlphaFromAlbedoTexture: boolean;
  110311. /**
  110312. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110313. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110314. */
  110315. protected _useSpecularOverAlpha: boolean;
  110316. /**
  110317. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110318. */
  110319. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110320. /**
  110321. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110322. */
  110323. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110324. /**
  110325. * Specifies if the metallic texture contains the roughness information in its green channel.
  110326. */
  110327. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110328. /**
  110329. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110330. */
  110331. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110332. /**
  110333. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110334. */
  110335. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110336. /**
  110337. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110338. */
  110339. protected _useAmbientInGrayScale: boolean;
  110340. /**
  110341. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110342. * The material will try to infer what glossiness each pixel should be.
  110343. */
  110344. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110345. /**
  110346. * Defines the falloff type used in this material.
  110347. * It by default is Physical.
  110348. */
  110349. protected _lightFalloff: number;
  110350. /**
  110351. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110352. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110353. */
  110354. protected _useRadianceOverAlpha: boolean;
  110355. /**
  110356. * Allows using an object space normal map (instead of tangent space).
  110357. */
  110358. protected _useObjectSpaceNormalMap: boolean;
  110359. /**
  110360. * Allows using the bump map in parallax mode.
  110361. */
  110362. protected _useParallax: boolean;
  110363. /**
  110364. * Allows using the bump map in parallax occlusion mode.
  110365. */
  110366. protected _useParallaxOcclusion: boolean;
  110367. /**
  110368. * Controls the scale bias of the parallax mode.
  110369. */
  110370. protected _parallaxScaleBias: number;
  110371. /**
  110372. * If sets to true, disables all the lights affecting the material.
  110373. */
  110374. protected _disableLighting: boolean;
  110375. /**
  110376. * Number of Simultaneous lights allowed on the material.
  110377. */
  110378. protected _maxSimultaneousLights: number;
  110379. /**
  110380. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110381. */
  110382. protected _invertNormalMapX: boolean;
  110383. /**
  110384. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110385. */
  110386. protected _invertNormalMapY: boolean;
  110387. /**
  110388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110389. */
  110390. protected _twoSidedLighting: boolean;
  110391. /**
  110392. * Defines the alpha limits in alpha test mode.
  110393. */
  110394. protected _alphaCutOff: number;
  110395. /**
  110396. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110397. */
  110398. protected _forceAlphaTest: boolean;
  110399. /**
  110400. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110401. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110402. */
  110403. protected _useAlphaFresnel: boolean;
  110404. /**
  110405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110406. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110407. */
  110408. protected _useLinearAlphaFresnel: boolean;
  110409. /**
  110410. * The transparency mode of the material.
  110411. */
  110412. protected _transparencyMode: Nullable<number>;
  110413. /**
  110414. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110415. * from cos thetav and roughness:
  110416. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110417. */
  110418. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110419. /**
  110420. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110421. */
  110422. protected _forceIrradianceInFragment: boolean;
  110423. /**
  110424. * Force normal to face away from face.
  110425. */
  110426. protected _forceNormalForward: boolean;
  110427. /**
  110428. * Enables specular anti aliasing in the PBR shader.
  110429. * It will both interacts on the Geometry for analytical and IBL lighting.
  110430. * It also prefilter the roughness map based on the bump values.
  110431. */
  110432. protected _enableSpecularAntiAliasing: boolean;
  110433. /**
  110434. * Default configuration related to image processing available in the PBR Material.
  110435. */
  110436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110437. /**
  110438. * Keep track of the image processing observer to allow dispose and replace.
  110439. */
  110440. private _imageProcessingObserver;
  110441. /**
  110442. * Attaches a new image processing configuration to the PBR Material.
  110443. * @param configuration
  110444. */
  110445. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110446. /**
  110447. * Stores the available render targets.
  110448. */
  110449. private _renderTargets;
  110450. /**
  110451. * Sets the global ambient color for the material used in lighting calculations.
  110452. */
  110453. private _globalAmbientColor;
  110454. /**
  110455. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110456. */
  110457. private _useLogarithmicDepth;
  110458. /**
  110459. * If set to true, no lighting calculations will be applied.
  110460. */
  110461. private _unlit;
  110462. private _debugMode;
  110463. /**
  110464. * @hidden
  110465. * This is reserved for the inspector.
  110466. * Defines the material debug mode.
  110467. * It helps seeing only some components of the material while troubleshooting.
  110468. */
  110469. debugMode: number;
  110470. /**
  110471. * @hidden
  110472. * This is reserved for the inspector.
  110473. * Specify from where on screen the debug mode should start.
  110474. * The value goes from -1 (full screen) to 1 (not visible)
  110475. * It helps with side by side comparison against the final render
  110476. * This defaults to -1
  110477. */
  110478. private debugLimit;
  110479. /**
  110480. * @hidden
  110481. * This is reserved for the inspector.
  110482. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110483. * You can use the factor to better multiply the final value.
  110484. */
  110485. private debugFactor;
  110486. /**
  110487. * Defines the clear coat layer parameters for the material.
  110488. */
  110489. readonly clearCoat: PBRClearCoatConfiguration;
  110490. /**
  110491. * Defines the anisotropic parameters for the material.
  110492. */
  110493. readonly anisotropy: PBRAnisotropicConfiguration;
  110494. /**
  110495. * Defines the BRDF parameters for the material.
  110496. */
  110497. readonly brdf: PBRBRDFConfiguration;
  110498. /**
  110499. * Defines the Sheen parameters for the material.
  110500. */
  110501. readonly sheen: PBRSheenConfiguration;
  110502. /**
  110503. * Defines the SubSurface parameters for the material.
  110504. */
  110505. readonly subSurface: PBRSubSurfaceConfiguration;
  110506. /**
  110507. * Custom callback helping to override the default shader used in the material.
  110508. */
  110509. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110510. /**
  110511. * Instantiates a new PBRMaterial instance.
  110512. *
  110513. * @param name The material name
  110514. * @param scene The scene the material will be use in.
  110515. */
  110516. constructor(name: string, scene: Scene);
  110517. /**
  110518. * Gets a boolean indicating that current material needs to register RTT
  110519. */
  110520. readonly hasRenderTargetTextures: boolean;
  110521. /**
  110522. * Gets the name of the material class.
  110523. */
  110524. getClassName(): string;
  110525. /**
  110526. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110527. */
  110528. /**
  110529. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110530. */
  110531. useLogarithmicDepth: boolean;
  110532. /**
  110533. * Gets the current transparency mode.
  110534. */
  110535. /**
  110536. * Sets the transparency mode of the material.
  110537. *
  110538. * | Value | Type | Description |
  110539. * | ----- | ----------------------------------- | ----------- |
  110540. * | 0 | OPAQUE | |
  110541. * | 1 | ALPHATEST | |
  110542. * | 2 | ALPHABLEND | |
  110543. * | 3 | ALPHATESTANDBLEND | |
  110544. *
  110545. */
  110546. transparencyMode: Nullable<number>;
  110547. /**
  110548. * Returns true if alpha blending should be disabled.
  110549. */
  110550. private readonly _disableAlphaBlending;
  110551. /**
  110552. * Specifies whether or not this material should be rendered in alpha blend mode.
  110553. */
  110554. needAlphaBlending(): boolean;
  110555. /**
  110556. * Specifies if the mesh will require alpha blending.
  110557. * @param mesh - BJS mesh.
  110558. */
  110559. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110560. /**
  110561. * Specifies whether or not this material should be rendered in alpha test mode.
  110562. */
  110563. needAlphaTesting(): boolean;
  110564. /**
  110565. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  110566. */
  110567. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  110568. /**
  110569. * Gets the texture used for the alpha test.
  110570. */
  110571. getAlphaTestTexture(): Nullable<BaseTexture>;
  110572. /**
  110573. * Specifies that the submesh is ready to be used.
  110574. * @param mesh - BJS mesh.
  110575. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  110576. * @param useInstances - Specifies that instances should be used.
  110577. * @returns - boolean indicating that the submesh is ready or not.
  110578. */
  110579. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110580. /**
  110581. * Specifies if the material uses metallic roughness workflow.
  110582. * @returns boolean specifiying if the material uses metallic roughness workflow.
  110583. */
  110584. isMetallicWorkflow(): boolean;
  110585. private _prepareEffect;
  110586. private _prepareDefines;
  110587. /**
  110588. * Force shader compilation
  110589. */
  110590. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  110591. clipPlane: boolean;
  110592. }>): void;
  110593. /**
  110594. * Initializes the uniform buffer layout for the shader.
  110595. */
  110596. buildUniformLayout(): void;
  110597. /**
  110598. * Unbinds the material from the mesh
  110599. */
  110600. unbind(): void;
  110601. /**
  110602. * Binds the submesh data.
  110603. * @param world - The world matrix.
  110604. * @param mesh - The BJS mesh.
  110605. * @param subMesh - A submesh of the BJS mesh.
  110606. */
  110607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110608. /**
  110609. * Returns the animatable textures.
  110610. * @returns - Array of animatable textures.
  110611. */
  110612. getAnimatables(): IAnimatable[];
  110613. /**
  110614. * Returns the texture used for reflections.
  110615. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  110616. */
  110617. private _getReflectionTexture;
  110618. /**
  110619. * Returns an array of the actively used textures.
  110620. * @returns - Array of BaseTextures
  110621. */
  110622. getActiveTextures(): BaseTexture[];
  110623. /**
  110624. * Checks to see if a texture is used in the material.
  110625. * @param texture - Base texture to use.
  110626. * @returns - Boolean specifying if a texture is used in the material.
  110627. */
  110628. hasTexture(texture: BaseTexture): boolean;
  110629. /**
  110630. * Disposes the resources of the material.
  110631. * @param forceDisposeEffect - Forces the disposal of effects.
  110632. * @param forceDisposeTextures - Forces the disposal of all textures.
  110633. */
  110634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110635. }
  110636. }
  110637. declare module BABYLON {
  110638. /**
  110639. * The Physically based material of BJS.
  110640. *
  110641. * This offers the main features of a standard PBR material.
  110642. * For more information, please refer to the documentation :
  110643. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110644. */
  110645. export class PBRMaterial extends PBRBaseMaterial {
  110646. /**
  110647. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110648. */
  110649. static readonly PBRMATERIAL_OPAQUE: number;
  110650. /**
  110651. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110652. */
  110653. static readonly PBRMATERIAL_ALPHATEST: number;
  110654. /**
  110655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110656. */
  110657. static readonly PBRMATERIAL_ALPHABLEND: number;
  110658. /**
  110659. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110660. * They are also discarded below the alpha cutoff threshold to improve performances.
  110661. */
  110662. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110663. /**
  110664. * Defines the default value of how much AO map is occluding the analytical lights
  110665. * (point spot...).
  110666. */
  110667. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110668. /**
  110669. * Intensity of the direct lights e.g. the four lights available in your scene.
  110670. * This impacts both the direct diffuse and specular highlights.
  110671. */
  110672. directIntensity: number;
  110673. /**
  110674. * Intensity of the emissive part of the material.
  110675. * This helps controlling the emissive effect without modifying the emissive color.
  110676. */
  110677. emissiveIntensity: number;
  110678. /**
  110679. * Intensity of the environment e.g. how much the environment will light the object
  110680. * either through harmonics for rough material or through the refelction for shiny ones.
  110681. */
  110682. environmentIntensity: number;
  110683. /**
  110684. * This is a special control allowing the reduction of the specular highlights coming from the
  110685. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110686. */
  110687. specularIntensity: number;
  110688. /**
  110689. * Debug Control allowing disabling the bump map on this material.
  110690. */
  110691. disableBumpMap: boolean;
  110692. /**
  110693. * AKA Diffuse Texture in standard nomenclature.
  110694. */
  110695. albedoTexture: BaseTexture;
  110696. /**
  110697. * AKA Occlusion Texture in other nomenclature.
  110698. */
  110699. ambientTexture: BaseTexture;
  110700. /**
  110701. * AKA Occlusion Texture Intensity in other nomenclature.
  110702. */
  110703. ambientTextureStrength: number;
  110704. /**
  110705. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110706. * 1 means it completely occludes it
  110707. * 0 mean it has no impact
  110708. */
  110709. ambientTextureImpactOnAnalyticalLights: number;
  110710. /**
  110711. * Stores the alpha values in a texture.
  110712. */
  110713. opacityTexture: BaseTexture;
  110714. /**
  110715. * Stores the reflection values in a texture.
  110716. */
  110717. reflectionTexture: Nullable<BaseTexture>;
  110718. /**
  110719. * Stores the emissive values in a texture.
  110720. */
  110721. emissiveTexture: BaseTexture;
  110722. /**
  110723. * AKA Specular texture in other nomenclature.
  110724. */
  110725. reflectivityTexture: BaseTexture;
  110726. /**
  110727. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110728. */
  110729. metallicTexture: BaseTexture;
  110730. /**
  110731. * Specifies the metallic scalar of the metallic/roughness workflow.
  110732. * Can also be used to scale the metalness values of the metallic texture.
  110733. */
  110734. metallic: Nullable<number>;
  110735. /**
  110736. * Specifies the roughness scalar of the metallic/roughness workflow.
  110737. * Can also be used to scale the roughness values of the metallic texture.
  110738. */
  110739. roughness: Nullable<number>;
  110740. /**
  110741. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110742. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110743. */
  110744. microSurfaceTexture: BaseTexture;
  110745. /**
  110746. * Stores surface normal data used to displace a mesh in a texture.
  110747. */
  110748. bumpTexture: BaseTexture;
  110749. /**
  110750. * Stores the pre-calculated light information of a mesh in a texture.
  110751. */
  110752. lightmapTexture: BaseTexture;
  110753. /**
  110754. * Stores the refracted light information in a texture.
  110755. */
  110756. refractionTexture: Nullable<BaseTexture>;
  110757. /**
  110758. * The color of a material in ambient lighting.
  110759. */
  110760. ambientColor: Color3;
  110761. /**
  110762. * AKA Diffuse Color in other nomenclature.
  110763. */
  110764. albedoColor: Color3;
  110765. /**
  110766. * AKA Specular Color in other nomenclature.
  110767. */
  110768. reflectivityColor: Color3;
  110769. /**
  110770. * The color reflected from the material.
  110771. */
  110772. reflectionColor: Color3;
  110773. /**
  110774. * The color emitted from the material.
  110775. */
  110776. emissiveColor: Color3;
  110777. /**
  110778. * AKA Glossiness in other nomenclature.
  110779. */
  110780. microSurface: number;
  110781. /**
  110782. * source material index of refraction (IOR)' / 'destination material IOR.
  110783. */
  110784. indexOfRefraction: number;
  110785. /**
  110786. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110787. */
  110788. invertRefractionY: boolean;
  110789. /**
  110790. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110791. * Materials half opaque for instance using refraction could benefit from this control.
  110792. */
  110793. linkRefractionWithTransparency: boolean;
  110794. /**
  110795. * If true, the light map contains occlusion information instead of lighting info.
  110796. */
  110797. useLightmapAsShadowmap: boolean;
  110798. /**
  110799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110800. */
  110801. useAlphaFromAlbedoTexture: boolean;
  110802. /**
  110803. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110804. */
  110805. forceAlphaTest: boolean;
  110806. /**
  110807. * Defines the alpha limits in alpha test mode.
  110808. */
  110809. alphaCutOff: number;
  110810. /**
  110811. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110812. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110813. */
  110814. useSpecularOverAlpha: boolean;
  110815. /**
  110816. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110817. */
  110818. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110819. /**
  110820. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110821. */
  110822. useRoughnessFromMetallicTextureAlpha: boolean;
  110823. /**
  110824. * Specifies if the metallic texture contains the roughness information in its green channel.
  110825. */
  110826. useRoughnessFromMetallicTextureGreen: boolean;
  110827. /**
  110828. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110829. */
  110830. useMetallnessFromMetallicTextureBlue: boolean;
  110831. /**
  110832. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110833. */
  110834. useAmbientOcclusionFromMetallicTextureRed: boolean;
  110835. /**
  110836. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110837. */
  110838. useAmbientInGrayScale: boolean;
  110839. /**
  110840. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110841. * The material will try to infer what glossiness each pixel should be.
  110842. */
  110843. useAutoMicroSurfaceFromReflectivityMap: boolean;
  110844. /**
  110845. * BJS is using an harcoded light falloff based on a manually sets up range.
  110846. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110847. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110848. */
  110849. /**
  110850. * BJS is using an harcoded light falloff based on a manually sets up range.
  110851. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110852. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110853. */
  110854. usePhysicalLightFalloff: boolean;
  110855. /**
  110856. * In order to support the falloff compatibility with gltf, a special mode has been added
  110857. * to reproduce the gltf light falloff.
  110858. */
  110859. /**
  110860. * In order to support the falloff compatibility with gltf, a special mode has been added
  110861. * to reproduce the gltf light falloff.
  110862. */
  110863. useGLTFLightFalloff: boolean;
  110864. /**
  110865. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110866. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110867. */
  110868. useRadianceOverAlpha: boolean;
  110869. /**
  110870. * Allows using an object space normal map (instead of tangent space).
  110871. */
  110872. useObjectSpaceNormalMap: boolean;
  110873. /**
  110874. * Allows using the bump map in parallax mode.
  110875. */
  110876. useParallax: boolean;
  110877. /**
  110878. * Allows using the bump map in parallax occlusion mode.
  110879. */
  110880. useParallaxOcclusion: boolean;
  110881. /**
  110882. * Controls the scale bias of the parallax mode.
  110883. */
  110884. parallaxScaleBias: number;
  110885. /**
  110886. * If sets to true, disables all the lights affecting the material.
  110887. */
  110888. disableLighting: boolean;
  110889. /**
  110890. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110891. */
  110892. forceIrradianceInFragment: boolean;
  110893. /**
  110894. * Number of Simultaneous lights allowed on the material.
  110895. */
  110896. maxSimultaneousLights: number;
  110897. /**
  110898. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110899. */
  110900. invertNormalMapX: boolean;
  110901. /**
  110902. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110903. */
  110904. invertNormalMapY: boolean;
  110905. /**
  110906. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110907. */
  110908. twoSidedLighting: boolean;
  110909. /**
  110910. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110911. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110912. */
  110913. useAlphaFresnel: boolean;
  110914. /**
  110915. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110916. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110917. */
  110918. useLinearAlphaFresnel: boolean;
  110919. /**
  110920. * Let user defines the brdf lookup texture used for IBL.
  110921. * A default 8bit version is embedded but you could point at :
  110922. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110923. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110924. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110925. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110926. */
  110927. environmentBRDFTexture: Nullable<BaseTexture>;
  110928. /**
  110929. * Force normal to face away from face.
  110930. */
  110931. forceNormalForward: boolean;
  110932. /**
  110933. * Enables specular anti aliasing in the PBR shader.
  110934. * It will both interacts on the Geometry for analytical and IBL lighting.
  110935. * It also prefilter the roughness map based on the bump values.
  110936. */
  110937. enableSpecularAntiAliasing: boolean;
  110938. /**
  110939. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110940. * makes the reflect vector face the model (under horizon).
  110941. */
  110942. useHorizonOcclusion: boolean;
  110943. /**
  110944. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110945. * too much the area relying on ambient texture to define their ambient occlusion.
  110946. */
  110947. useRadianceOcclusion: boolean;
  110948. /**
  110949. * If set to true, no lighting calculations will be applied.
  110950. */
  110951. unlit: boolean;
  110952. /**
  110953. * Gets the image processing configuration used either in this material.
  110954. */
  110955. /**
  110956. * Sets the Default image processing configuration used either in the this material.
  110957. *
  110958. * If sets to null, the scene one is in use.
  110959. */
  110960. imageProcessingConfiguration: ImageProcessingConfiguration;
  110961. /**
  110962. * Gets wether the color curves effect is enabled.
  110963. */
  110964. /**
  110965. * Sets wether the color curves effect is enabled.
  110966. */
  110967. cameraColorCurvesEnabled: boolean;
  110968. /**
  110969. * Gets wether the color grading effect is enabled.
  110970. */
  110971. /**
  110972. * Gets wether the color grading effect is enabled.
  110973. */
  110974. cameraColorGradingEnabled: boolean;
  110975. /**
  110976. * Gets wether tonemapping is enabled or not.
  110977. */
  110978. /**
  110979. * Sets wether tonemapping is enabled or not
  110980. */
  110981. cameraToneMappingEnabled: boolean;
  110982. /**
  110983. * The camera exposure used on this material.
  110984. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110985. * This corresponds to a photographic exposure.
  110986. */
  110987. /**
  110988. * The camera exposure used on this material.
  110989. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110990. * This corresponds to a photographic exposure.
  110991. */
  110992. cameraExposure: number;
  110993. /**
  110994. * Gets The camera contrast used on this material.
  110995. */
  110996. /**
  110997. * Sets The camera contrast used on this material.
  110998. */
  110999. cameraContrast: number;
  111000. /**
  111001. * Gets the Color Grading 2D Lookup Texture.
  111002. */
  111003. /**
  111004. * Sets the Color Grading 2D Lookup Texture.
  111005. */
  111006. cameraColorGradingTexture: Nullable<BaseTexture>;
  111007. /**
  111008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111010. * 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;
  111011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111012. */
  111013. /**
  111014. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111015. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111016. * 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;
  111017. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111018. */
  111019. cameraColorCurves: Nullable<ColorCurves>;
  111020. /**
  111021. * Instantiates a new PBRMaterial instance.
  111022. *
  111023. * @param name The material name
  111024. * @param scene The scene the material will be use in.
  111025. */
  111026. constructor(name: string, scene: Scene);
  111027. /**
  111028. * Returns the name of this material class.
  111029. */
  111030. getClassName(): string;
  111031. /**
  111032. * Makes a duplicate of the current material.
  111033. * @param name - name to use for the new material.
  111034. */
  111035. clone(name: string): PBRMaterial;
  111036. /**
  111037. * Serializes this PBR Material.
  111038. * @returns - An object with the serialized material.
  111039. */
  111040. serialize(): any;
  111041. /**
  111042. * Parses a PBR Material from a serialized object.
  111043. * @param source - Serialized object.
  111044. * @param scene - BJS scene instance.
  111045. * @param rootUrl - url for the scene object
  111046. * @returns - PBRMaterial
  111047. */
  111048. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  111049. }
  111050. }
  111051. declare module BABYLON {
  111052. /**
  111053. * Direct draw surface info
  111054. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111055. */
  111056. export interface DDSInfo {
  111057. /**
  111058. * Width of the texture
  111059. */
  111060. width: number;
  111061. /**
  111062. * Width of the texture
  111063. */
  111064. height: number;
  111065. /**
  111066. * Number of Mipmaps for the texture
  111067. * @see https://en.wikipedia.org/wiki/Mipmap
  111068. */
  111069. mipmapCount: number;
  111070. /**
  111071. * If the textures format is a known fourCC format
  111072. * @see https://www.fourcc.org/
  111073. */
  111074. isFourCC: boolean;
  111075. /**
  111076. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111077. */
  111078. isRGB: boolean;
  111079. /**
  111080. * If the texture is a lumincance format
  111081. */
  111082. isLuminance: boolean;
  111083. /**
  111084. * If this is a cube texture
  111085. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111086. */
  111087. isCube: boolean;
  111088. /**
  111089. * If the texture is a compressed format eg. FOURCC_DXT1
  111090. */
  111091. isCompressed: boolean;
  111092. /**
  111093. * The dxgiFormat of the texture
  111094. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111095. */
  111096. dxgiFormat: number;
  111097. /**
  111098. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111099. */
  111100. textureType: number;
  111101. /**
  111102. * Sphericle polynomial created for the dds texture
  111103. */
  111104. sphericalPolynomial?: SphericalPolynomial;
  111105. }
  111106. /**
  111107. * Class used to provide DDS decompression tools
  111108. */
  111109. export class DDSTools {
  111110. /**
  111111. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111112. */
  111113. static StoreLODInAlphaChannel: boolean;
  111114. /**
  111115. * Gets DDS information from an array buffer
  111116. * @param arrayBuffer defines the array buffer to read data from
  111117. * @returns the DDS information
  111118. */
  111119. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111120. private static _FloatView;
  111121. private static _Int32View;
  111122. private static _ToHalfFloat;
  111123. private static _FromHalfFloat;
  111124. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111125. private static _GetHalfFloatRGBAArrayBuffer;
  111126. private static _GetFloatRGBAArrayBuffer;
  111127. private static _GetFloatAsUIntRGBAArrayBuffer;
  111128. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111129. private static _GetRGBAArrayBuffer;
  111130. private static _ExtractLongWordOrder;
  111131. private static _GetRGBArrayBuffer;
  111132. private static _GetLuminanceArrayBuffer;
  111133. /**
  111134. * Uploads DDS Levels to a Babylon Texture
  111135. * @hidden
  111136. */
  111137. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111138. }
  111139. interface Engine {
  111140. /**
  111141. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111142. * @param rootUrl defines the url where the file to load is located
  111143. * @param scene defines the current scene
  111144. * @param lodScale defines scale to apply to the mip map selection
  111145. * @param lodOffset defines offset to apply to the mip map selection
  111146. * @param onLoad defines an optional callback raised when the texture is loaded
  111147. * @param onError defines an optional callback raised if there is an issue to load the texture
  111148. * @param format defines the format of the data
  111149. * @param forcedExtension defines the extension to use to pick the right loader
  111150. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111151. * @returns the cube texture as an InternalTexture
  111152. */
  111153. 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;
  111154. }
  111155. }
  111156. declare module BABYLON {
  111157. /**
  111158. * Implementation of the DDS Texture Loader.
  111159. * @hidden
  111160. */
  111161. export class _DDSTextureLoader implements IInternalTextureLoader {
  111162. /**
  111163. * Defines wether the loader supports cascade loading the different faces.
  111164. */
  111165. readonly supportCascades: boolean;
  111166. /**
  111167. * This returns if the loader support the current file information.
  111168. * @param extension defines the file extension of the file being loaded
  111169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111170. * @param fallback defines the fallback internal texture if any
  111171. * @param isBase64 defines whether the texture is encoded as a base64
  111172. * @param isBuffer defines whether the texture data are stored as a buffer
  111173. * @returns true if the loader can load the specified file
  111174. */
  111175. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111176. /**
  111177. * Transform the url before loading if required.
  111178. * @param rootUrl the url of the texture
  111179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111180. * @returns the transformed texture
  111181. */
  111182. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111183. /**
  111184. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111185. * @param rootUrl the url of the texture
  111186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111187. * @returns the fallback texture
  111188. */
  111189. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111190. /**
  111191. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111192. * @param data contains the texture data
  111193. * @param texture defines the BabylonJS internal texture
  111194. * @param createPolynomials will be true if polynomials have been requested
  111195. * @param onLoad defines the callback to trigger once the texture is ready
  111196. * @param onError defines the callback to trigger in case of error
  111197. */
  111198. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111199. /**
  111200. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111201. * @param data contains the texture data
  111202. * @param texture defines the BabylonJS internal texture
  111203. * @param callback defines the method to call once ready to upload
  111204. */
  111205. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111206. }
  111207. }
  111208. declare module BABYLON {
  111209. /** @hidden */
  111210. export var rgbdEncodePixelShader: {
  111211. name: string;
  111212. shader: string;
  111213. };
  111214. }
  111215. declare module BABYLON {
  111216. /**
  111217. * Raw texture data and descriptor sufficient for WebGL texture upload
  111218. */
  111219. export interface EnvironmentTextureInfo {
  111220. /**
  111221. * Version of the environment map
  111222. */
  111223. version: number;
  111224. /**
  111225. * Width of image
  111226. */
  111227. width: number;
  111228. /**
  111229. * Irradiance information stored in the file.
  111230. */
  111231. irradiance: any;
  111232. /**
  111233. * Specular information stored in the file.
  111234. */
  111235. specular: any;
  111236. }
  111237. /**
  111238. * Sets of helpers addressing the serialization and deserialization of environment texture
  111239. * stored in a BabylonJS env file.
  111240. * Those files are usually stored as .env files.
  111241. */
  111242. export class EnvironmentTextureTools {
  111243. /**
  111244. * Magic number identifying the env file.
  111245. */
  111246. private static _MagicBytes;
  111247. /**
  111248. * Gets the environment info from an env file.
  111249. * @param data The array buffer containing the .env bytes.
  111250. * @returns the environment file info (the json header) if successfully parsed.
  111251. */
  111252. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111253. /**
  111254. * Creates an environment texture from a loaded cube texture.
  111255. * @param texture defines the cube texture to convert in env file
  111256. * @return a promise containing the environment data if succesfull.
  111257. */
  111258. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111259. /**
  111260. * Creates a JSON representation of the spherical data.
  111261. * @param texture defines the texture containing the polynomials
  111262. * @return the JSON representation of the spherical info
  111263. */
  111264. private static _CreateEnvTextureIrradiance;
  111265. /**
  111266. * Uploads the texture info contained in the env file to the GPU.
  111267. * @param texture defines the internal texture to upload to
  111268. * @param arrayBuffer defines the buffer cotaining the data to load
  111269. * @param info defines the texture info retrieved through the GetEnvInfo method
  111270. * @returns a promise
  111271. */
  111272. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111273. /**
  111274. * Uploads the levels of image data to the GPU.
  111275. * @param texture defines the internal texture to upload to
  111276. * @param imageData defines the array buffer views of image data [mipmap][face]
  111277. * @returns a promise
  111278. */
  111279. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111280. /**
  111281. * Uploads spherical polynomials information to the texture.
  111282. * @param texture defines the texture we are trying to upload the information to
  111283. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111284. */
  111285. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111286. /** @hidden */
  111287. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111288. }
  111289. }
  111290. declare module BABYLON {
  111291. /**
  111292. * Implementation of the ENV Texture Loader.
  111293. * @hidden
  111294. */
  111295. export class _ENVTextureLoader implements IInternalTextureLoader {
  111296. /**
  111297. * Defines wether the loader supports cascade loading the different faces.
  111298. */
  111299. readonly supportCascades: boolean;
  111300. /**
  111301. * This returns if the loader support the current file information.
  111302. * @param extension defines the file extension of the file being loaded
  111303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111304. * @param fallback defines the fallback internal texture if any
  111305. * @param isBase64 defines whether the texture is encoded as a base64
  111306. * @param isBuffer defines whether the texture data are stored as a buffer
  111307. * @returns true if the loader can load the specified file
  111308. */
  111309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111310. /**
  111311. * Transform the url before loading if required.
  111312. * @param rootUrl the url of the texture
  111313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111314. * @returns the transformed texture
  111315. */
  111316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111317. /**
  111318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111319. * @param rootUrl the url of the texture
  111320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111321. * @returns the fallback texture
  111322. */
  111323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111324. /**
  111325. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111326. * @param data contains the texture data
  111327. * @param texture defines the BabylonJS internal texture
  111328. * @param createPolynomials will be true if polynomials have been requested
  111329. * @param onLoad defines the callback to trigger once the texture is ready
  111330. * @param onError defines the callback to trigger in case of error
  111331. */
  111332. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111333. /**
  111334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111335. * @param data contains the texture data
  111336. * @param texture defines the BabylonJS internal texture
  111337. * @param callback defines the method to call once ready to upload
  111338. */
  111339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111340. }
  111341. }
  111342. declare module BABYLON {
  111343. /**
  111344. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111345. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111346. */
  111347. export class KhronosTextureContainer {
  111348. /** contents of the KTX container file */
  111349. arrayBuffer: any;
  111350. private static HEADER_LEN;
  111351. private static COMPRESSED_2D;
  111352. private static COMPRESSED_3D;
  111353. private static TEX_2D;
  111354. private static TEX_3D;
  111355. /**
  111356. * Gets the openGL type
  111357. */
  111358. glType: number;
  111359. /**
  111360. * Gets the openGL type size
  111361. */
  111362. glTypeSize: number;
  111363. /**
  111364. * Gets the openGL format
  111365. */
  111366. glFormat: number;
  111367. /**
  111368. * Gets the openGL internal format
  111369. */
  111370. glInternalFormat: number;
  111371. /**
  111372. * Gets the base internal format
  111373. */
  111374. glBaseInternalFormat: number;
  111375. /**
  111376. * Gets image width in pixel
  111377. */
  111378. pixelWidth: number;
  111379. /**
  111380. * Gets image height in pixel
  111381. */
  111382. pixelHeight: number;
  111383. /**
  111384. * Gets image depth in pixels
  111385. */
  111386. pixelDepth: number;
  111387. /**
  111388. * Gets the number of array elements
  111389. */
  111390. numberOfArrayElements: number;
  111391. /**
  111392. * Gets the number of faces
  111393. */
  111394. numberOfFaces: number;
  111395. /**
  111396. * Gets the number of mipmap levels
  111397. */
  111398. numberOfMipmapLevels: number;
  111399. /**
  111400. * Gets the bytes of key value data
  111401. */
  111402. bytesOfKeyValueData: number;
  111403. /**
  111404. * Gets the load type
  111405. */
  111406. loadType: number;
  111407. /**
  111408. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111409. */
  111410. isInvalid: boolean;
  111411. /**
  111412. * Creates a new KhronosTextureContainer
  111413. * @param arrayBuffer contents of the KTX container file
  111414. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111415. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111416. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111417. */
  111418. constructor(
  111419. /** contents of the KTX container file */
  111420. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111421. /**
  111422. * Uploads KTX content to a Babylon Texture.
  111423. * It is assumed that the texture has already been created & is currently bound
  111424. * @hidden
  111425. */
  111426. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111427. private _upload2DCompressedLevels;
  111428. }
  111429. }
  111430. declare module BABYLON {
  111431. /**
  111432. * Implementation of the KTX Texture Loader.
  111433. * @hidden
  111434. */
  111435. export class _KTXTextureLoader implements IInternalTextureLoader {
  111436. /**
  111437. * Defines wether the loader supports cascade loading the different faces.
  111438. */
  111439. readonly supportCascades: boolean;
  111440. /**
  111441. * This returns if the loader support the current file information.
  111442. * @param extension defines the file extension of the file being loaded
  111443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111444. * @param fallback defines the fallback internal texture if any
  111445. * @param isBase64 defines whether the texture is encoded as a base64
  111446. * @param isBuffer defines whether the texture data are stored as a buffer
  111447. * @returns true if the loader can load the specified file
  111448. */
  111449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111450. /**
  111451. * Transform the url before loading if required.
  111452. * @param rootUrl the url of the texture
  111453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111454. * @returns the transformed texture
  111455. */
  111456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111457. /**
  111458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111459. * @param rootUrl the url of the texture
  111460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111461. * @returns the fallback texture
  111462. */
  111463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111464. /**
  111465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111466. * @param data contains the texture data
  111467. * @param texture defines the BabylonJS internal texture
  111468. * @param createPolynomials will be true if polynomials have been requested
  111469. * @param onLoad defines the callback to trigger once the texture is ready
  111470. * @param onError defines the callback to trigger in case of error
  111471. */
  111472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111473. /**
  111474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111475. * @param data contains the texture data
  111476. * @param texture defines the BabylonJS internal texture
  111477. * @param callback defines the method to call once ready to upload
  111478. */
  111479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111480. }
  111481. }
  111482. declare module BABYLON {
  111483. /**
  111484. * Options for the default xr helper
  111485. */
  111486. export class WebXRDefaultExperienceOptions {
  111487. /**
  111488. * Floor meshes that should be used for teleporting
  111489. */
  111490. floorMeshes: Array<AbstractMesh>;
  111491. }
  111492. /**
  111493. * Default experience which provides a similar setup to the previous webVRExperience
  111494. */
  111495. export class WebXRDefaultExperience {
  111496. /**
  111497. * Base experience
  111498. */
  111499. baseExperience: WebXRExperienceHelper;
  111500. /**
  111501. * Input experience extension
  111502. */
  111503. input: WebXRInput;
  111504. /**
  111505. * Loads the controller models
  111506. */
  111507. controllerModelLoader: WebXRControllerModelLoader;
  111508. /**
  111509. * Enables laser pointer and selection
  111510. */
  111511. pointerSelection: WebXRControllerPointerSelection;
  111512. /**
  111513. * Enables teleportation
  111514. */
  111515. teleportation: WebXRControllerTeleportation;
  111516. /**
  111517. * Enables ui for enetering/exiting xr
  111518. */
  111519. enterExitUI: WebXREnterExitUI;
  111520. /**
  111521. * Default output canvas xr should render to
  111522. */
  111523. outputCanvas: WebXRManagedOutputCanvas;
  111524. /**
  111525. * Creates the default xr experience
  111526. * @param scene scene
  111527. * @param options options for basic configuration
  111528. * @returns resulting WebXRDefaultExperience
  111529. */
  111530. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111531. private constructor();
  111532. /**
  111533. * DIsposes of the experience helper
  111534. */
  111535. dispose(): void;
  111536. }
  111537. }
  111538. declare module BABYLON {
  111539. /** @hidden */
  111540. export var _forceSceneHelpersToBundle: boolean;
  111541. interface Scene {
  111542. /**
  111543. * Creates a default light for the scene.
  111544. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  111545. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  111546. */
  111547. createDefaultLight(replace?: boolean): void;
  111548. /**
  111549. * Creates a default camera for the scene.
  111550. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  111551. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111552. * @param replace has default false, when true replaces the active camera in the scene
  111553. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  111554. */
  111555. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111556. /**
  111557. * Creates a default camera and a default light.
  111558. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  111559. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111560. * @param replace has the default false, when true replaces the active camera/light in the scene
  111561. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  111562. */
  111563. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111564. /**
  111565. * Creates a new sky box
  111566. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  111567. * @param environmentTexture defines the texture to use as environment texture
  111568. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  111569. * @param scale defines the overall scale of the skybox
  111570. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  111571. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  111572. * @returns a new mesh holding the sky box
  111573. */
  111574. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  111575. /**
  111576. * Creates a new environment
  111577. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  111578. * @param options defines the options you can use to configure the environment
  111579. * @returns the new EnvironmentHelper
  111580. */
  111581. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  111582. /**
  111583. * Creates a new VREXperienceHelper
  111584. * @see http://doc.babylonjs.com/how_to/webvr_helper
  111585. * @param webVROptions defines the options used to create the new VREXperienceHelper
  111586. * @returns a new VREXperienceHelper
  111587. */
  111588. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  111589. /**
  111590. * Creates a new WebXRDefaultExperience
  111591. * @see http://doc.babylonjs.com/how_to/webxr
  111592. * @param options experience options
  111593. * @returns a promise for a new WebXRDefaultExperience
  111594. */
  111595. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111596. }
  111597. }
  111598. declare module BABYLON {
  111599. /**
  111600. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  111601. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  111602. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  111603. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111604. */
  111605. export class VideoDome extends TransformNode {
  111606. /**
  111607. * Define the video source as a Monoscopic panoramic 360 video.
  111608. */
  111609. static readonly MODE_MONOSCOPIC: number;
  111610. /**
  111611. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111612. */
  111613. static readonly MODE_TOPBOTTOM: number;
  111614. /**
  111615. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111616. */
  111617. static readonly MODE_SIDEBYSIDE: number;
  111618. private _useDirectMapping;
  111619. /**
  111620. * The video texture being displayed on the sphere
  111621. */
  111622. protected _videoTexture: VideoTexture;
  111623. /**
  111624. * Gets the video texture being displayed on the sphere
  111625. */
  111626. readonly videoTexture: VideoTexture;
  111627. /**
  111628. * The skybox material
  111629. */
  111630. protected _material: BackgroundMaterial;
  111631. /**
  111632. * The surface used for the skybox
  111633. */
  111634. protected _mesh: Mesh;
  111635. /**
  111636. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111637. * Also see the options.resolution property.
  111638. */
  111639. fovMultiplier: number;
  111640. private _videoMode;
  111641. /**
  111642. * Gets or set the current video mode for the video. It can be:
  111643. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  111644. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111645. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111646. */
  111647. videoMode: number;
  111648. /**
  111649. * Oberserver used in Stereoscopic VR Mode.
  111650. */
  111651. private _onBeforeCameraRenderObserver;
  111652. /**
  111653. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  111654. * @param name Element's name, child elements will append suffixes for their own names.
  111655. * @param urlsOrVideo defines the url(s) or the video element to use
  111656. * @param options An object containing optional or exposed sub element properties
  111657. */
  111658. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  111659. resolution?: number;
  111660. clickToPlay?: boolean;
  111661. autoPlay?: boolean;
  111662. loop?: boolean;
  111663. size?: number;
  111664. poster?: string;
  111665. faceForward?: boolean;
  111666. useDirectMapping?: boolean;
  111667. }, scene: Scene);
  111668. private _changeVideoMode;
  111669. /**
  111670. * Releases resources associated with this node.
  111671. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111672. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111673. */
  111674. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111675. }
  111676. }
  111677. declare module BABYLON {
  111678. /**
  111679. * This class can be used to get instrumentation data from a Babylon engine
  111680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111681. */
  111682. export class EngineInstrumentation implements IDisposable {
  111683. /**
  111684. * Define the instrumented engine.
  111685. */
  111686. engine: Engine;
  111687. private _captureGPUFrameTime;
  111688. private _gpuFrameTimeToken;
  111689. private _gpuFrameTime;
  111690. private _captureShaderCompilationTime;
  111691. private _shaderCompilationTime;
  111692. private _onBeginFrameObserver;
  111693. private _onEndFrameObserver;
  111694. private _onBeforeShaderCompilationObserver;
  111695. private _onAfterShaderCompilationObserver;
  111696. /**
  111697. * Gets the perf counter used for GPU frame time
  111698. */
  111699. readonly gpuFrameTimeCounter: PerfCounter;
  111700. /**
  111701. * Gets the GPU frame time capture status
  111702. */
  111703. /**
  111704. * Enable or disable the GPU frame time capture
  111705. */
  111706. captureGPUFrameTime: boolean;
  111707. /**
  111708. * Gets the perf counter used for shader compilation time
  111709. */
  111710. readonly shaderCompilationTimeCounter: PerfCounter;
  111711. /**
  111712. * Gets the shader compilation time capture status
  111713. */
  111714. /**
  111715. * Enable or disable the shader compilation time capture
  111716. */
  111717. captureShaderCompilationTime: boolean;
  111718. /**
  111719. * Instantiates a new engine instrumentation.
  111720. * This class can be used to get instrumentation data from a Babylon engine
  111721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111722. * @param engine Defines the engine to instrument
  111723. */
  111724. constructor(
  111725. /**
  111726. * Define the instrumented engine.
  111727. */
  111728. engine: Engine);
  111729. /**
  111730. * Dispose and release associated resources.
  111731. */
  111732. dispose(): void;
  111733. }
  111734. }
  111735. declare module BABYLON {
  111736. /**
  111737. * This class can be used to get instrumentation data from a Babylon engine
  111738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111739. */
  111740. export class SceneInstrumentation implements IDisposable {
  111741. /**
  111742. * Defines the scene to instrument
  111743. */
  111744. scene: Scene;
  111745. private _captureActiveMeshesEvaluationTime;
  111746. private _activeMeshesEvaluationTime;
  111747. private _captureRenderTargetsRenderTime;
  111748. private _renderTargetsRenderTime;
  111749. private _captureFrameTime;
  111750. private _frameTime;
  111751. private _captureRenderTime;
  111752. private _renderTime;
  111753. private _captureInterFrameTime;
  111754. private _interFrameTime;
  111755. private _captureParticlesRenderTime;
  111756. private _particlesRenderTime;
  111757. private _captureSpritesRenderTime;
  111758. private _spritesRenderTime;
  111759. private _capturePhysicsTime;
  111760. private _physicsTime;
  111761. private _captureAnimationsTime;
  111762. private _animationsTime;
  111763. private _captureCameraRenderTime;
  111764. private _cameraRenderTime;
  111765. private _onBeforeActiveMeshesEvaluationObserver;
  111766. private _onAfterActiveMeshesEvaluationObserver;
  111767. private _onBeforeRenderTargetsRenderObserver;
  111768. private _onAfterRenderTargetsRenderObserver;
  111769. private _onAfterRenderObserver;
  111770. private _onBeforeDrawPhaseObserver;
  111771. private _onAfterDrawPhaseObserver;
  111772. private _onBeforeAnimationsObserver;
  111773. private _onBeforeParticlesRenderingObserver;
  111774. private _onAfterParticlesRenderingObserver;
  111775. private _onBeforeSpritesRenderingObserver;
  111776. private _onAfterSpritesRenderingObserver;
  111777. private _onBeforePhysicsObserver;
  111778. private _onAfterPhysicsObserver;
  111779. private _onAfterAnimationsObserver;
  111780. private _onBeforeCameraRenderObserver;
  111781. private _onAfterCameraRenderObserver;
  111782. /**
  111783. * Gets the perf counter used for active meshes evaluation time
  111784. */
  111785. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  111786. /**
  111787. * Gets the active meshes evaluation time capture status
  111788. */
  111789. /**
  111790. * Enable or disable the active meshes evaluation time capture
  111791. */
  111792. captureActiveMeshesEvaluationTime: boolean;
  111793. /**
  111794. * Gets the perf counter used for render targets render time
  111795. */
  111796. readonly renderTargetsRenderTimeCounter: PerfCounter;
  111797. /**
  111798. * Gets the render targets render time capture status
  111799. */
  111800. /**
  111801. * Enable or disable the render targets render time capture
  111802. */
  111803. captureRenderTargetsRenderTime: boolean;
  111804. /**
  111805. * Gets the perf counter used for particles render time
  111806. */
  111807. readonly particlesRenderTimeCounter: PerfCounter;
  111808. /**
  111809. * Gets the particles render time capture status
  111810. */
  111811. /**
  111812. * Enable or disable the particles render time capture
  111813. */
  111814. captureParticlesRenderTime: boolean;
  111815. /**
  111816. * Gets the perf counter used for sprites render time
  111817. */
  111818. readonly spritesRenderTimeCounter: PerfCounter;
  111819. /**
  111820. * Gets the sprites render time capture status
  111821. */
  111822. /**
  111823. * Enable or disable the sprites render time capture
  111824. */
  111825. captureSpritesRenderTime: boolean;
  111826. /**
  111827. * Gets the perf counter used for physics time
  111828. */
  111829. readonly physicsTimeCounter: PerfCounter;
  111830. /**
  111831. * Gets the physics time capture status
  111832. */
  111833. /**
  111834. * Enable or disable the physics time capture
  111835. */
  111836. capturePhysicsTime: boolean;
  111837. /**
  111838. * Gets the perf counter used for animations time
  111839. */
  111840. readonly animationsTimeCounter: PerfCounter;
  111841. /**
  111842. * Gets the animations time capture status
  111843. */
  111844. /**
  111845. * Enable or disable the animations time capture
  111846. */
  111847. captureAnimationsTime: boolean;
  111848. /**
  111849. * Gets the perf counter used for frame time capture
  111850. */
  111851. readonly frameTimeCounter: PerfCounter;
  111852. /**
  111853. * Gets the frame time capture status
  111854. */
  111855. /**
  111856. * Enable or disable the frame time capture
  111857. */
  111858. captureFrameTime: boolean;
  111859. /**
  111860. * Gets the perf counter used for inter-frames time capture
  111861. */
  111862. readonly interFrameTimeCounter: PerfCounter;
  111863. /**
  111864. * Gets the inter-frames time capture status
  111865. */
  111866. /**
  111867. * Enable or disable the inter-frames time capture
  111868. */
  111869. captureInterFrameTime: boolean;
  111870. /**
  111871. * Gets the perf counter used for render time capture
  111872. */
  111873. readonly renderTimeCounter: PerfCounter;
  111874. /**
  111875. * Gets the render time capture status
  111876. */
  111877. /**
  111878. * Enable or disable the render time capture
  111879. */
  111880. captureRenderTime: boolean;
  111881. /**
  111882. * Gets the perf counter used for camera render time capture
  111883. */
  111884. readonly cameraRenderTimeCounter: PerfCounter;
  111885. /**
  111886. * Gets the camera render time capture status
  111887. */
  111888. /**
  111889. * Enable or disable the camera render time capture
  111890. */
  111891. captureCameraRenderTime: boolean;
  111892. /**
  111893. * Gets the perf counter used for draw calls
  111894. */
  111895. readonly drawCallsCounter: PerfCounter;
  111896. /**
  111897. * Instantiates a new scene instrumentation.
  111898. * This class can be used to get instrumentation data from a Babylon engine
  111899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111900. * @param scene Defines the scene to instrument
  111901. */
  111902. constructor(
  111903. /**
  111904. * Defines the scene to instrument
  111905. */
  111906. scene: Scene);
  111907. /**
  111908. * Dispose and release associated resources.
  111909. */
  111910. dispose(): void;
  111911. }
  111912. }
  111913. declare module BABYLON {
  111914. /** @hidden */
  111915. export var glowMapGenerationPixelShader: {
  111916. name: string;
  111917. shader: string;
  111918. };
  111919. }
  111920. declare module BABYLON {
  111921. /** @hidden */
  111922. export var glowMapGenerationVertexShader: {
  111923. name: string;
  111924. shader: string;
  111925. };
  111926. }
  111927. declare module BABYLON {
  111928. /**
  111929. * Effect layer options. This helps customizing the behaviour
  111930. * of the effect layer.
  111931. */
  111932. export interface IEffectLayerOptions {
  111933. /**
  111934. * Multiplication factor apply to the canvas size to compute the render target size
  111935. * used to generated the objects (the smaller the faster).
  111936. */
  111937. mainTextureRatio: number;
  111938. /**
  111939. * Enforces a fixed size texture to ensure effect stability across devices.
  111940. */
  111941. mainTextureFixedSize?: number;
  111942. /**
  111943. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111944. */
  111945. alphaBlendingMode: number;
  111946. /**
  111947. * The camera attached to the layer.
  111948. */
  111949. camera: Nullable<Camera>;
  111950. /**
  111951. * The rendering group to draw the layer in.
  111952. */
  111953. renderingGroupId: number;
  111954. }
  111955. /**
  111956. * The effect layer Helps adding post process effect blended with the main pass.
  111957. *
  111958. * This can be for instance use to generate glow or higlight effects on the scene.
  111959. *
  111960. * The effect layer class can not be used directly and is intented to inherited from to be
  111961. * customized per effects.
  111962. */
  111963. export abstract class EffectLayer {
  111964. private _vertexBuffers;
  111965. private _indexBuffer;
  111966. private _cachedDefines;
  111967. private _effectLayerMapGenerationEffect;
  111968. private _effectLayerOptions;
  111969. private _mergeEffect;
  111970. protected _scene: Scene;
  111971. protected _engine: Engine;
  111972. protected _maxSize: number;
  111973. protected _mainTextureDesiredSize: ISize;
  111974. protected _mainTexture: RenderTargetTexture;
  111975. protected _shouldRender: boolean;
  111976. protected _postProcesses: PostProcess[];
  111977. protected _textures: BaseTexture[];
  111978. protected _emissiveTextureAndColor: {
  111979. texture: Nullable<BaseTexture>;
  111980. color: Color4;
  111981. };
  111982. /**
  111983. * The name of the layer
  111984. */
  111985. name: string;
  111986. /**
  111987. * The clear color of the texture used to generate the glow map.
  111988. */
  111989. neutralColor: Color4;
  111990. /**
  111991. * Specifies wether the highlight layer is enabled or not.
  111992. */
  111993. isEnabled: boolean;
  111994. /**
  111995. * Gets the camera attached to the layer.
  111996. */
  111997. readonly camera: Nullable<Camera>;
  111998. /**
  111999. * Gets the rendering group id the layer should render in.
  112000. */
  112001. renderingGroupId: number;
  112002. /**
  112003. * An event triggered when the effect layer has been disposed.
  112004. */
  112005. onDisposeObservable: Observable<EffectLayer>;
  112006. /**
  112007. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  112008. */
  112009. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  112010. /**
  112011. * An event triggered when the generated texture is being merged in the scene.
  112012. */
  112013. onBeforeComposeObservable: Observable<EffectLayer>;
  112014. /**
  112015. * An event triggered when the generated texture has been merged in the scene.
  112016. */
  112017. onAfterComposeObservable: Observable<EffectLayer>;
  112018. /**
  112019. * An event triggered when the efffect layer changes its size.
  112020. */
  112021. onSizeChangedObservable: Observable<EffectLayer>;
  112022. /** @hidden */
  112023. static _SceneComponentInitialization: (scene: Scene) => void;
  112024. /**
  112025. * Instantiates a new effect Layer and references it in the scene.
  112026. * @param name The name of the layer
  112027. * @param scene The scene to use the layer in
  112028. */
  112029. constructor(
  112030. /** The Friendly of the effect in the scene */
  112031. name: string, scene: Scene);
  112032. /**
  112033. * Get the effect name of the layer.
  112034. * @return The effect name
  112035. */
  112036. abstract getEffectName(): string;
  112037. /**
  112038. * Checks for the readiness of the element composing the layer.
  112039. * @param subMesh the mesh to check for
  112040. * @param useInstances specify wether or not to use instances to render the mesh
  112041. * @return true if ready otherwise, false
  112042. */
  112043. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112044. /**
  112045. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112046. * @returns true if the effect requires stencil during the main canvas render pass.
  112047. */
  112048. abstract needStencil(): boolean;
  112049. /**
  112050. * Create the merge effect. This is the shader use to blit the information back
  112051. * to the main canvas at the end of the scene rendering.
  112052. * @returns The effect containing the shader used to merge the effect on the main canvas
  112053. */
  112054. protected abstract _createMergeEffect(): Effect;
  112055. /**
  112056. * Creates the render target textures and post processes used in the effect layer.
  112057. */
  112058. protected abstract _createTextureAndPostProcesses(): void;
  112059. /**
  112060. * Implementation specific of rendering the generating effect on the main canvas.
  112061. * @param effect The effect used to render through
  112062. */
  112063. protected abstract _internalRender(effect: Effect): void;
  112064. /**
  112065. * Sets the required values for both the emissive texture and and the main color.
  112066. */
  112067. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112068. /**
  112069. * Free any resources and references associated to a mesh.
  112070. * Internal use
  112071. * @param mesh The mesh to free.
  112072. */
  112073. abstract _disposeMesh(mesh: Mesh): void;
  112074. /**
  112075. * Serializes this layer (Glow or Highlight for example)
  112076. * @returns a serialized layer object
  112077. */
  112078. abstract serialize?(): any;
  112079. /**
  112080. * Initializes the effect layer with the required options.
  112081. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112082. */
  112083. protected _init(options: Partial<IEffectLayerOptions>): void;
  112084. /**
  112085. * Generates the index buffer of the full screen quad blending to the main canvas.
  112086. */
  112087. private _generateIndexBuffer;
  112088. /**
  112089. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  112090. */
  112091. private _generateVertexBuffer;
  112092. /**
  112093. * Sets the main texture desired size which is the closest power of two
  112094. * of the engine canvas size.
  112095. */
  112096. private _setMainTextureSize;
  112097. /**
  112098. * Creates the main texture for the effect layer.
  112099. */
  112100. protected _createMainTexture(): void;
  112101. /**
  112102. * Adds specific effects defines.
  112103. * @param defines The defines to add specifics to.
  112104. */
  112105. protected _addCustomEffectDefines(defines: string[]): void;
  112106. /**
  112107. * Checks for the readiness of the element composing the layer.
  112108. * @param subMesh the mesh to check for
  112109. * @param useInstances specify wether or not to use instances to render the mesh
  112110. * @param emissiveTexture the associated emissive texture used to generate the glow
  112111. * @return true if ready otherwise, false
  112112. */
  112113. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  112114. /**
  112115. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  112116. */
  112117. render(): void;
  112118. /**
  112119. * Determine if a given mesh will be used in the current effect.
  112120. * @param mesh mesh to test
  112121. * @returns true if the mesh will be used
  112122. */
  112123. hasMesh(mesh: AbstractMesh): boolean;
  112124. /**
  112125. * Returns true if the layer contains information to display, otherwise false.
  112126. * @returns true if the glow layer should be rendered
  112127. */
  112128. shouldRender(): boolean;
  112129. /**
  112130. * Returns true if the mesh should render, otherwise false.
  112131. * @param mesh The mesh to render
  112132. * @returns true if it should render otherwise false
  112133. */
  112134. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  112135. /**
  112136. * Returns true if the mesh can be rendered, otherwise false.
  112137. * @param mesh The mesh to render
  112138. * @param material The material used on the mesh
  112139. * @returns true if it can be rendered otherwise false
  112140. */
  112141. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112142. /**
  112143. * Returns true if the mesh should render, otherwise false.
  112144. * @param mesh The mesh to render
  112145. * @returns true if it should render otherwise false
  112146. */
  112147. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  112148. /**
  112149. * Renders the submesh passed in parameter to the generation map.
  112150. */
  112151. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  112152. /**
  112153. * Rebuild the required buffers.
  112154. * @hidden Internal use only.
  112155. */
  112156. _rebuild(): void;
  112157. /**
  112158. * Dispose only the render target textures and post process.
  112159. */
  112160. private _disposeTextureAndPostProcesses;
  112161. /**
  112162. * Dispose the highlight layer and free resources.
  112163. */
  112164. dispose(): void;
  112165. /**
  112166. * Gets the class name of the effect layer
  112167. * @returns the string with the class name of the effect layer
  112168. */
  112169. getClassName(): string;
  112170. /**
  112171. * Creates an effect layer from parsed effect layer data
  112172. * @param parsedEffectLayer defines effect layer data
  112173. * @param scene defines the current scene
  112174. * @param rootUrl defines the root URL containing the effect layer information
  112175. * @returns a parsed effect Layer
  112176. */
  112177. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  112178. }
  112179. }
  112180. declare module BABYLON {
  112181. interface AbstractScene {
  112182. /**
  112183. * The list of effect layers (highlights/glow) added to the scene
  112184. * @see http://doc.babylonjs.com/how_to/highlight_layer
  112185. * @see http://doc.babylonjs.com/how_to/glow_layer
  112186. */
  112187. effectLayers: Array<EffectLayer>;
  112188. /**
  112189. * Removes the given effect layer from this scene.
  112190. * @param toRemove defines the effect layer to remove
  112191. * @returns the index of the removed effect layer
  112192. */
  112193. removeEffectLayer(toRemove: EffectLayer): number;
  112194. /**
  112195. * Adds the given effect layer to this scene
  112196. * @param newEffectLayer defines the effect layer to add
  112197. */
  112198. addEffectLayer(newEffectLayer: EffectLayer): void;
  112199. }
  112200. /**
  112201. * Defines the layer scene component responsible to manage any effect layers
  112202. * in a given scene.
  112203. */
  112204. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  112205. /**
  112206. * The component name helpfull to identify the component in the list of scene components.
  112207. */
  112208. readonly name: string;
  112209. /**
  112210. * The scene the component belongs to.
  112211. */
  112212. scene: Scene;
  112213. private _engine;
  112214. private _renderEffects;
  112215. private _needStencil;
  112216. private _previousStencilState;
  112217. /**
  112218. * Creates a new instance of the component for the given scene
  112219. * @param scene Defines the scene to register the component in
  112220. */
  112221. constructor(scene: Scene);
  112222. /**
  112223. * Registers the component in a given scene
  112224. */
  112225. register(): void;
  112226. /**
  112227. * Rebuilds the elements related to this component in case of
  112228. * context lost for instance.
  112229. */
  112230. rebuild(): void;
  112231. /**
  112232. * Serializes the component data to the specified json object
  112233. * @param serializationObject The object to serialize to
  112234. */
  112235. serialize(serializationObject: any): void;
  112236. /**
  112237. * Adds all the elements from the container to the scene
  112238. * @param container the container holding the elements
  112239. */
  112240. addFromContainer(container: AbstractScene): void;
  112241. /**
  112242. * Removes all the elements in the container from the scene
  112243. * @param container contains the elements to remove
  112244. * @param dispose if the removed element should be disposed (default: false)
  112245. */
  112246. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112247. /**
  112248. * Disposes the component and the associated ressources.
  112249. */
  112250. dispose(): void;
  112251. private _isReadyForMesh;
  112252. private _renderMainTexture;
  112253. private _setStencil;
  112254. private _setStencilBack;
  112255. private _draw;
  112256. private _drawCamera;
  112257. private _drawRenderingGroup;
  112258. }
  112259. }
  112260. declare module BABYLON {
  112261. /** @hidden */
  112262. export var glowMapMergePixelShader: {
  112263. name: string;
  112264. shader: string;
  112265. };
  112266. }
  112267. declare module BABYLON {
  112268. /** @hidden */
  112269. export var glowMapMergeVertexShader: {
  112270. name: string;
  112271. shader: string;
  112272. };
  112273. }
  112274. declare module BABYLON {
  112275. interface AbstractScene {
  112276. /**
  112277. * Return a the first highlight layer of the scene with a given name.
  112278. * @param name The name of the highlight layer to look for.
  112279. * @return The highlight layer if found otherwise null.
  112280. */
  112281. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112282. }
  112283. /**
  112284. * Glow layer options. This helps customizing the behaviour
  112285. * of the glow layer.
  112286. */
  112287. export interface IGlowLayerOptions {
  112288. /**
  112289. * Multiplication factor apply to the canvas size to compute the render target size
  112290. * used to generated the glowing objects (the smaller the faster).
  112291. */
  112292. mainTextureRatio: number;
  112293. /**
  112294. * Enforces a fixed size texture to ensure resize independant blur.
  112295. */
  112296. mainTextureFixedSize?: number;
  112297. /**
  112298. * How big is the kernel of the blur texture.
  112299. */
  112300. blurKernelSize: number;
  112301. /**
  112302. * The camera attached to the layer.
  112303. */
  112304. camera: Nullable<Camera>;
  112305. /**
  112306. * Enable MSAA by chosing the number of samples.
  112307. */
  112308. mainTextureSamples?: number;
  112309. /**
  112310. * The rendering group to draw the layer in.
  112311. */
  112312. renderingGroupId: number;
  112313. }
  112314. /**
  112315. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112316. *
  112317. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112318. * glowy meshes to your scene.
  112319. *
  112320. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112321. */
  112322. export class GlowLayer extends EffectLayer {
  112323. /**
  112324. * Effect Name of the layer.
  112325. */
  112326. static readonly EffectName: string;
  112327. /**
  112328. * The default blur kernel size used for the glow.
  112329. */
  112330. static DefaultBlurKernelSize: number;
  112331. /**
  112332. * The default texture size ratio used for the glow.
  112333. */
  112334. static DefaultTextureRatio: number;
  112335. /**
  112336. * Sets the kernel size of the blur.
  112337. */
  112338. /**
  112339. * Gets the kernel size of the blur.
  112340. */
  112341. blurKernelSize: number;
  112342. /**
  112343. * Sets the glow intensity.
  112344. */
  112345. /**
  112346. * Gets the glow intensity.
  112347. */
  112348. intensity: number;
  112349. private _options;
  112350. private _intensity;
  112351. private _horizontalBlurPostprocess1;
  112352. private _verticalBlurPostprocess1;
  112353. private _horizontalBlurPostprocess2;
  112354. private _verticalBlurPostprocess2;
  112355. private _blurTexture1;
  112356. private _blurTexture2;
  112357. private _postProcesses1;
  112358. private _postProcesses2;
  112359. private _includedOnlyMeshes;
  112360. private _excludedMeshes;
  112361. /**
  112362. * Callback used to let the user override the color selection on a per mesh basis
  112363. */
  112364. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112365. /**
  112366. * Callback used to let the user override the texture selection on a per mesh basis
  112367. */
  112368. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112369. /**
  112370. * Instantiates a new glow Layer and references it to the scene.
  112371. * @param name The name of the layer
  112372. * @param scene The scene to use the layer in
  112373. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112374. */
  112375. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112376. /**
  112377. * Get the effect name of the layer.
  112378. * @return The effect name
  112379. */
  112380. getEffectName(): string;
  112381. /**
  112382. * Create the merge effect. This is the shader use to blit the information back
  112383. * to the main canvas at the end of the scene rendering.
  112384. */
  112385. protected _createMergeEffect(): Effect;
  112386. /**
  112387. * Creates the render target textures and post processes used in the glow layer.
  112388. */
  112389. protected _createTextureAndPostProcesses(): void;
  112390. /**
  112391. * Checks for the readiness of the element composing the layer.
  112392. * @param subMesh the mesh to check for
  112393. * @param useInstances specify wether or not to use instances to render the mesh
  112394. * @param emissiveTexture the associated emissive texture used to generate the glow
  112395. * @return true if ready otherwise, false
  112396. */
  112397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112398. /**
  112399. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112400. */
  112401. needStencil(): boolean;
  112402. /**
  112403. * Returns true if the mesh can be rendered, otherwise false.
  112404. * @param mesh The mesh to render
  112405. * @param material The material used on the mesh
  112406. * @returns true if it can be rendered otherwise false
  112407. */
  112408. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112409. /**
  112410. * Implementation specific of rendering the generating effect on the main canvas.
  112411. * @param effect The effect used to render through
  112412. */
  112413. protected _internalRender(effect: Effect): void;
  112414. /**
  112415. * Sets the required values for both the emissive texture and and the main color.
  112416. */
  112417. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112418. /**
  112419. * Returns true if the mesh should render, otherwise false.
  112420. * @param mesh The mesh to render
  112421. * @returns true if it should render otherwise false
  112422. */
  112423. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112424. /**
  112425. * Adds specific effects defines.
  112426. * @param defines The defines to add specifics to.
  112427. */
  112428. protected _addCustomEffectDefines(defines: string[]): void;
  112429. /**
  112430. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112431. * @param mesh The mesh to exclude from the glow layer
  112432. */
  112433. addExcludedMesh(mesh: Mesh): void;
  112434. /**
  112435. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112436. * @param mesh The mesh to remove
  112437. */
  112438. removeExcludedMesh(mesh: Mesh): void;
  112439. /**
  112440. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112441. * @param mesh The mesh to include in the glow layer
  112442. */
  112443. addIncludedOnlyMesh(mesh: Mesh): void;
  112444. /**
  112445. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112446. * @param mesh The mesh to remove
  112447. */
  112448. removeIncludedOnlyMesh(mesh: Mesh): void;
  112449. /**
  112450. * Determine if a given mesh will be used in the glow layer
  112451. * @param mesh The mesh to test
  112452. * @returns true if the mesh will be highlighted by the current glow layer
  112453. */
  112454. hasMesh(mesh: AbstractMesh): boolean;
  112455. /**
  112456. * Free any resources and references associated to a mesh.
  112457. * Internal use
  112458. * @param mesh The mesh to free.
  112459. * @hidden
  112460. */
  112461. _disposeMesh(mesh: Mesh): void;
  112462. /**
  112463. * Gets the class name of the effect layer
  112464. * @returns the string with the class name of the effect layer
  112465. */
  112466. getClassName(): string;
  112467. /**
  112468. * Serializes this glow layer
  112469. * @returns a serialized glow layer object
  112470. */
  112471. serialize(): any;
  112472. /**
  112473. * Creates a Glow Layer from parsed glow layer data
  112474. * @param parsedGlowLayer defines glow layer data
  112475. * @param scene defines the current scene
  112476. * @param rootUrl defines the root URL containing the glow layer information
  112477. * @returns a parsed Glow Layer
  112478. */
  112479. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /** @hidden */
  112484. export var glowBlurPostProcessPixelShader: {
  112485. name: string;
  112486. shader: string;
  112487. };
  112488. }
  112489. declare module BABYLON {
  112490. interface AbstractScene {
  112491. /**
  112492. * Return a the first highlight layer of the scene with a given name.
  112493. * @param name The name of the highlight layer to look for.
  112494. * @return The highlight layer if found otherwise null.
  112495. */
  112496. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112497. }
  112498. /**
  112499. * Highlight layer options. This helps customizing the behaviour
  112500. * of the highlight layer.
  112501. */
  112502. export interface IHighlightLayerOptions {
  112503. /**
  112504. * Multiplication factor apply to the canvas size to compute the render target size
  112505. * used to generated the glowing objects (the smaller the faster).
  112506. */
  112507. mainTextureRatio: number;
  112508. /**
  112509. * Enforces a fixed size texture to ensure resize independant blur.
  112510. */
  112511. mainTextureFixedSize?: number;
  112512. /**
  112513. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112514. * of the picture to blur (the smaller the faster).
  112515. */
  112516. blurTextureSizeRatio: number;
  112517. /**
  112518. * How big in texel of the blur texture is the vertical blur.
  112519. */
  112520. blurVerticalSize: number;
  112521. /**
  112522. * How big in texel of the blur texture is the horizontal blur.
  112523. */
  112524. blurHorizontalSize: number;
  112525. /**
  112526. * Alpha blending mode used to apply the blur. Default is combine.
  112527. */
  112528. alphaBlendingMode: number;
  112529. /**
  112530. * The camera attached to the layer.
  112531. */
  112532. camera: Nullable<Camera>;
  112533. /**
  112534. * Should we display highlight as a solid stroke?
  112535. */
  112536. isStroke?: boolean;
  112537. /**
  112538. * The rendering group to draw the layer in.
  112539. */
  112540. renderingGroupId: number;
  112541. }
  112542. /**
  112543. * The highlight layer Helps adding a glow effect around a mesh.
  112544. *
  112545. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112546. * glowy meshes to your scene.
  112547. *
  112548. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  112549. */
  112550. export class HighlightLayer extends EffectLayer {
  112551. name: string;
  112552. /**
  112553. * Effect Name of the highlight layer.
  112554. */
  112555. static readonly EffectName: string;
  112556. /**
  112557. * The neutral color used during the preparation of the glow effect.
  112558. * This is black by default as the blend operation is a blend operation.
  112559. */
  112560. static NeutralColor: Color4;
  112561. /**
  112562. * Stencil value used for glowing meshes.
  112563. */
  112564. static GlowingMeshStencilReference: number;
  112565. /**
  112566. * Stencil value used for the other meshes in the scene.
  112567. */
  112568. static NormalMeshStencilReference: number;
  112569. /**
  112570. * Specifies whether or not the inner glow is ACTIVE in the layer.
  112571. */
  112572. innerGlow: boolean;
  112573. /**
  112574. * Specifies whether or not the outer glow is ACTIVE in the layer.
  112575. */
  112576. outerGlow: boolean;
  112577. /**
  112578. * Specifies the horizontal size of the blur.
  112579. */
  112580. /**
  112581. * Gets the horizontal size of the blur.
  112582. */
  112583. blurHorizontalSize: number;
  112584. /**
  112585. * Specifies the vertical size of the blur.
  112586. */
  112587. /**
  112588. * Gets the vertical size of the blur.
  112589. */
  112590. blurVerticalSize: number;
  112591. /**
  112592. * An event triggered when the highlight layer is being blurred.
  112593. */
  112594. onBeforeBlurObservable: Observable<HighlightLayer>;
  112595. /**
  112596. * An event triggered when the highlight layer has been blurred.
  112597. */
  112598. onAfterBlurObservable: Observable<HighlightLayer>;
  112599. private _instanceGlowingMeshStencilReference;
  112600. private _options;
  112601. private _downSamplePostprocess;
  112602. private _horizontalBlurPostprocess;
  112603. private _verticalBlurPostprocess;
  112604. private _blurTexture;
  112605. private _meshes;
  112606. private _excludedMeshes;
  112607. /**
  112608. * Instantiates a new highlight Layer and references it to the scene..
  112609. * @param name The name of the layer
  112610. * @param scene The scene to use the layer in
  112611. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  112612. */
  112613. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  112614. /**
  112615. * Get the effect name of the layer.
  112616. * @return The effect name
  112617. */
  112618. getEffectName(): string;
  112619. /**
  112620. * Create the merge effect. This is the shader use to blit the information back
  112621. * to the main canvas at the end of the scene rendering.
  112622. */
  112623. protected _createMergeEffect(): Effect;
  112624. /**
  112625. * Creates the render target textures and post processes used in the highlight layer.
  112626. */
  112627. protected _createTextureAndPostProcesses(): void;
  112628. /**
  112629. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112630. */
  112631. needStencil(): boolean;
  112632. /**
  112633. * Checks for the readiness of the element composing the layer.
  112634. * @param subMesh the mesh to check for
  112635. * @param useInstances specify wether or not to use instances to render the mesh
  112636. * @param emissiveTexture the associated emissive texture used to generate the glow
  112637. * @return true if ready otherwise, false
  112638. */
  112639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112640. /**
  112641. * Implementation specific of rendering the generating effect on the main canvas.
  112642. * @param effect The effect used to render through
  112643. */
  112644. protected _internalRender(effect: Effect): void;
  112645. /**
  112646. * Returns true if the layer contains information to display, otherwise false.
  112647. */
  112648. shouldRender(): boolean;
  112649. /**
  112650. * Returns true if the mesh should render, otherwise false.
  112651. * @param mesh The mesh to render
  112652. * @returns true if it should render otherwise false
  112653. */
  112654. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112655. /**
  112656. * Sets the required values for both the emissive texture and and the main color.
  112657. */
  112658. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112659. /**
  112660. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  112661. * @param mesh The mesh to exclude from the highlight layer
  112662. */
  112663. addExcludedMesh(mesh: Mesh): void;
  112664. /**
  112665. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  112666. * @param mesh The mesh to highlight
  112667. */
  112668. removeExcludedMesh(mesh: Mesh): void;
  112669. /**
  112670. * Determine if a given mesh will be highlighted by the current HighlightLayer
  112671. * @param mesh mesh to test
  112672. * @returns true if the mesh will be highlighted by the current HighlightLayer
  112673. */
  112674. hasMesh(mesh: AbstractMesh): boolean;
  112675. /**
  112676. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  112677. * @param mesh The mesh to highlight
  112678. * @param color The color of the highlight
  112679. * @param glowEmissiveOnly Extract the glow from the emissive texture
  112680. */
  112681. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  112682. /**
  112683. * Remove a mesh from the highlight layer in order to make it stop glowing.
  112684. * @param mesh The mesh to highlight
  112685. */
  112686. removeMesh(mesh: Mesh): void;
  112687. /**
  112688. * Force the stencil to the normal expected value for none glowing parts
  112689. */
  112690. private _defaultStencilReference;
  112691. /**
  112692. * Free any resources and references associated to a mesh.
  112693. * Internal use
  112694. * @param mesh The mesh to free.
  112695. * @hidden
  112696. */
  112697. _disposeMesh(mesh: Mesh): void;
  112698. /**
  112699. * Dispose the highlight layer and free resources.
  112700. */
  112701. dispose(): void;
  112702. /**
  112703. * Gets the class name of the effect layer
  112704. * @returns the string with the class name of the effect layer
  112705. */
  112706. getClassName(): string;
  112707. /**
  112708. * Serializes this Highlight layer
  112709. * @returns a serialized Highlight layer object
  112710. */
  112711. serialize(): any;
  112712. /**
  112713. * Creates a Highlight layer from parsed Highlight layer data
  112714. * @param parsedHightlightLayer defines the Highlight layer data
  112715. * @param scene defines the current scene
  112716. * @param rootUrl defines the root URL containing the Highlight layer information
  112717. * @returns a parsed Highlight layer
  112718. */
  112719. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  112720. }
  112721. }
  112722. declare module BABYLON {
  112723. interface AbstractScene {
  112724. /**
  112725. * The list of layers (background and foreground) of the scene
  112726. */
  112727. layers: Array<Layer>;
  112728. }
  112729. /**
  112730. * Defines the layer scene component responsible to manage any layers
  112731. * in a given scene.
  112732. */
  112733. export class LayerSceneComponent implements ISceneComponent {
  112734. /**
  112735. * The component name helpfull to identify the component in the list of scene components.
  112736. */
  112737. readonly name: string;
  112738. /**
  112739. * The scene the component belongs to.
  112740. */
  112741. scene: Scene;
  112742. private _engine;
  112743. /**
  112744. * Creates a new instance of the component for the given scene
  112745. * @param scene Defines the scene to register the component in
  112746. */
  112747. constructor(scene: Scene);
  112748. /**
  112749. * Registers the component in a given scene
  112750. */
  112751. register(): void;
  112752. /**
  112753. * Rebuilds the elements related to this component in case of
  112754. * context lost for instance.
  112755. */
  112756. rebuild(): void;
  112757. /**
  112758. * Disposes the component and the associated ressources.
  112759. */
  112760. dispose(): void;
  112761. private _draw;
  112762. private _drawCameraPredicate;
  112763. private _drawCameraBackground;
  112764. private _drawCameraForeground;
  112765. private _drawRenderTargetPredicate;
  112766. private _drawRenderTargetBackground;
  112767. private _drawRenderTargetForeground;
  112768. /**
  112769. * Adds all the elements from the container to the scene
  112770. * @param container the container holding the elements
  112771. */
  112772. addFromContainer(container: AbstractScene): void;
  112773. /**
  112774. * Removes all the elements in the container from the scene
  112775. * @param container contains the elements to remove
  112776. * @param dispose if the removed element should be disposed (default: false)
  112777. */
  112778. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112779. }
  112780. }
  112781. declare module BABYLON {
  112782. /** @hidden */
  112783. export var layerPixelShader: {
  112784. name: string;
  112785. shader: string;
  112786. };
  112787. }
  112788. declare module BABYLON {
  112789. /** @hidden */
  112790. export var layerVertexShader: {
  112791. name: string;
  112792. shader: string;
  112793. };
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * This represents a full screen 2d layer.
  112798. * This can be useful to display a picture in the background of your scene for instance.
  112799. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112800. */
  112801. export class Layer {
  112802. /**
  112803. * Define the name of the layer.
  112804. */
  112805. name: string;
  112806. /**
  112807. * Define the texture the layer should display.
  112808. */
  112809. texture: Nullable<Texture>;
  112810. /**
  112811. * Is the layer in background or foreground.
  112812. */
  112813. isBackground: boolean;
  112814. /**
  112815. * Define the color of the layer (instead of texture).
  112816. */
  112817. color: Color4;
  112818. /**
  112819. * Define the scale of the layer in order to zoom in out of the texture.
  112820. */
  112821. scale: Vector2;
  112822. /**
  112823. * Define an offset for the layer in order to shift the texture.
  112824. */
  112825. offset: Vector2;
  112826. /**
  112827. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  112828. */
  112829. alphaBlendingMode: number;
  112830. /**
  112831. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  112832. * Alpha test will not mix with the background color in case of transparency.
  112833. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  112834. */
  112835. alphaTest: boolean;
  112836. /**
  112837. * Define a mask to restrict the layer to only some of the scene cameras.
  112838. */
  112839. layerMask: number;
  112840. /**
  112841. * Define the list of render target the layer is visible into.
  112842. */
  112843. renderTargetTextures: RenderTargetTexture[];
  112844. /**
  112845. * Define if the layer is only used in renderTarget or if it also
  112846. * renders in the main frame buffer of the canvas.
  112847. */
  112848. renderOnlyInRenderTargetTextures: boolean;
  112849. private _scene;
  112850. private _vertexBuffers;
  112851. private _indexBuffer;
  112852. private _effect;
  112853. private _alphaTestEffect;
  112854. /**
  112855. * An event triggered when the layer is disposed.
  112856. */
  112857. onDisposeObservable: Observable<Layer>;
  112858. private _onDisposeObserver;
  112859. /**
  112860. * Back compatibility with callback before the onDisposeObservable existed.
  112861. * The set callback will be triggered when the layer has been disposed.
  112862. */
  112863. onDispose: () => void;
  112864. /**
  112865. * An event triggered before rendering the scene
  112866. */
  112867. onBeforeRenderObservable: Observable<Layer>;
  112868. private _onBeforeRenderObserver;
  112869. /**
  112870. * Back compatibility with callback before the onBeforeRenderObservable existed.
  112871. * The set callback will be triggered just before rendering the layer.
  112872. */
  112873. onBeforeRender: () => void;
  112874. /**
  112875. * An event triggered after rendering the scene
  112876. */
  112877. onAfterRenderObservable: Observable<Layer>;
  112878. private _onAfterRenderObserver;
  112879. /**
  112880. * Back compatibility with callback before the onAfterRenderObservable existed.
  112881. * The set callback will be triggered just after rendering the layer.
  112882. */
  112883. onAfterRender: () => void;
  112884. /**
  112885. * Instantiates a new layer.
  112886. * This represents a full screen 2d layer.
  112887. * This can be useful to display a picture in the background of your scene for instance.
  112888. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112889. * @param name Define the name of the layer in the scene
  112890. * @param imgUrl Define the url of the texture to display in the layer
  112891. * @param scene Define the scene the layer belongs to
  112892. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  112893. * @param color Defines a color for the layer
  112894. */
  112895. constructor(
  112896. /**
  112897. * Define the name of the layer.
  112898. */
  112899. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  112900. private _createIndexBuffer;
  112901. /** @hidden */
  112902. _rebuild(): void;
  112903. /**
  112904. * Renders the layer in the scene.
  112905. */
  112906. render(): void;
  112907. /**
  112908. * Disposes and releases the associated ressources.
  112909. */
  112910. dispose(): void;
  112911. }
  112912. }
  112913. declare module BABYLON {
  112914. /** @hidden */
  112915. export var lensFlarePixelShader: {
  112916. name: string;
  112917. shader: string;
  112918. };
  112919. }
  112920. declare module BABYLON {
  112921. /** @hidden */
  112922. export var lensFlareVertexShader: {
  112923. name: string;
  112924. shader: string;
  112925. };
  112926. }
  112927. declare module BABYLON {
  112928. /**
  112929. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112930. * It is usually composed of several `lensFlare`.
  112931. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112932. */
  112933. export class LensFlareSystem {
  112934. /**
  112935. * Define the name of the lens flare system
  112936. */
  112937. name: string;
  112938. /**
  112939. * List of lens flares used in this system.
  112940. */
  112941. lensFlares: LensFlare[];
  112942. /**
  112943. * Define a limit from the border the lens flare can be visible.
  112944. */
  112945. borderLimit: number;
  112946. /**
  112947. * Define a viewport border we do not want to see the lens flare in.
  112948. */
  112949. viewportBorder: number;
  112950. /**
  112951. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112952. */
  112953. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112954. /**
  112955. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112956. */
  112957. layerMask: number;
  112958. /**
  112959. * Define the id of the lens flare system in the scene.
  112960. * (equal to name by default)
  112961. */
  112962. id: string;
  112963. private _scene;
  112964. private _emitter;
  112965. private _vertexBuffers;
  112966. private _indexBuffer;
  112967. private _effect;
  112968. private _positionX;
  112969. private _positionY;
  112970. private _isEnabled;
  112971. /** @hidden */
  112972. static _SceneComponentInitialization: (scene: Scene) => void;
  112973. /**
  112974. * Instantiates a lens flare system.
  112975. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112976. * It is usually composed of several `lensFlare`.
  112977. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112978. * @param name Define the name of the lens flare system in the scene
  112979. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112980. * @param scene Define the scene the lens flare system belongs to
  112981. */
  112982. constructor(
  112983. /**
  112984. * Define the name of the lens flare system
  112985. */
  112986. name: string, emitter: any, scene: Scene);
  112987. /**
  112988. * Define if the lens flare system is enabled.
  112989. */
  112990. isEnabled: boolean;
  112991. /**
  112992. * Get the scene the effects belongs to.
  112993. * @returns the scene holding the lens flare system
  112994. */
  112995. getScene(): Scene;
  112996. /**
  112997. * Get the emitter of the lens flare system.
  112998. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112999. * @returns the emitter of the lens flare system
  113000. */
  113001. getEmitter(): any;
  113002. /**
  113003. * Set the emitter of the lens flare system.
  113004. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113005. * @param newEmitter Define the new emitter of the system
  113006. */
  113007. setEmitter(newEmitter: any): void;
  113008. /**
  113009. * Get the lens flare system emitter position.
  113010. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  113011. * @returns the position
  113012. */
  113013. getEmitterPosition(): Vector3;
  113014. /**
  113015. * @hidden
  113016. */
  113017. computeEffectivePosition(globalViewport: Viewport): boolean;
  113018. /** @hidden */
  113019. _isVisible(): boolean;
  113020. /**
  113021. * @hidden
  113022. */
  113023. render(): boolean;
  113024. /**
  113025. * Dispose and release the lens flare with its associated resources.
  113026. */
  113027. dispose(): void;
  113028. /**
  113029. * Parse a lens flare system from a JSON repressentation
  113030. * @param parsedLensFlareSystem Define the JSON to parse
  113031. * @param scene Define the scene the parsed system should be instantiated in
  113032. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  113033. * @returns the parsed system
  113034. */
  113035. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  113036. /**
  113037. * Serialize the current Lens Flare System into a JSON representation.
  113038. * @returns the serialized JSON
  113039. */
  113040. serialize(): any;
  113041. }
  113042. }
  113043. declare module BABYLON {
  113044. /**
  113045. * This represents one of the lens effect in a `lensFlareSystem`.
  113046. * It controls one of the indiviual texture used in the effect.
  113047. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113048. */
  113049. export class LensFlare {
  113050. /**
  113051. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113052. */
  113053. size: number;
  113054. /**
  113055. * 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.
  113056. */
  113057. position: number;
  113058. /**
  113059. * Define the lens color.
  113060. */
  113061. color: Color3;
  113062. /**
  113063. * Define the lens texture.
  113064. */
  113065. texture: Nullable<Texture>;
  113066. /**
  113067. * Define the alpha mode to render this particular lens.
  113068. */
  113069. alphaMode: number;
  113070. private _system;
  113071. /**
  113072. * Creates a new Lens Flare.
  113073. * This represents one of the lens effect in a `lensFlareSystem`.
  113074. * It controls one of the indiviual texture used in the effect.
  113075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113076. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113077. * @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.
  113078. * @param color Define the lens color
  113079. * @param imgUrl Define the lens texture url
  113080. * @param system Define the `lensFlareSystem` this flare is part of
  113081. * @returns The newly created Lens Flare
  113082. */
  113083. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  113084. /**
  113085. * Instantiates a new Lens Flare.
  113086. * This represents one of the lens effect in a `lensFlareSystem`.
  113087. * It controls one of the indiviual texture used in the effect.
  113088. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113089. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  113090. * @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.
  113091. * @param color Define the lens color
  113092. * @param imgUrl Define the lens texture url
  113093. * @param system Define the `lensFlareSystem` this flare is part of
  113094. */
  113095. constructor(
  113096. /**
  113097. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113098. */
  113099. size: number,
  113100. /**
  113101. * 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.
  113102. */
  113103. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  113104. /**
  113105. * Dispose and release the lens flare with its associated resources.
  113106. */
  113107. dispose(): void;
  113108. }
  113109. }
  113110. declare module BABYLON {
  113111. interface AbstractScene {
  113112. /**
  113113. * The list of lens flare system added to the scene
  113114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113115. */
  113116. lensFlareSystems: Array<LensFlareSystem>;
  113117. /**
  113118. * Removes the given lens flare system from this scene.
  113119. * @param toRemove The lens flare system to remove
  113120. * @returns The index of the removed lens flare system
  113121. */
  113122. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  113123. /**
  113124. * Adds the given lens flare system to this scene
  113125. * @param newLensFlareSystem The lens flare system to add
  113126. */
  113127. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  113128. /**
  113129. * Gets a lens flare system using its name
  113130. * @param name defines the name to look for
  113131. * @returns the lens flare system or null if not found
  113132. */
  113133. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  113134. /**
  113135. * Gets a lens flare system using its id
  113136. * @param id defines the id to look for
  113137. * @returns the lens flare system or null if not found
  113138. */
  113139. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  113140. }
  113141. /**
  113142. * Defines the lens flare scene component responsible to manage any lens flares
  113143. * in a given scene.
  113144. */
  113145. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  113146. /**
  113147. * The component name helpfull to identify the component in the list of scene components.
  113148. */
  113149. readonly name: string;
  113150. /**
  113151. * The scene the component belongs to.
  113152. */
  113153. scene: Scene;
  113154. /**
  113155. * Creates a new instance of the component for the given scene
  113156. * @param scene Defines the scene to register the component in
  113157. */
  113158. constructor(scene: Scene);
  113159. /**
  113160. * Registers the component in a given scene
  113161. */
  113162. register(): void;
  113163. /**
  113164. * Rebuilds the elements related to this component in case of
  113165. * context lost for instance.
  113166. */
  113167. rebuild(): void;
  113168. /**
  113169. * Adds all the elements from the container to the scene
  113170. * @param container the container holding the elements
  113171. */
  113172. addFromContainer(container: AbstractScene): void;
  113173. /**
  113174. * Removes all the elements in the container from the scene
  113175. * @param container contains the elements to remove
  113176. * @param dispose if the removed element should be disposed (default: false)
  113177. */
  113178. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113179. /**
  113180. * Serializes the component data to the specified json object
  113181. * @param serializationObject The object to serialize to
  113182. */
  113183. serialize(serializationObject: any): void;
  113184. /**
  113185. * Disposes the component and the associated ressources.
  113186. */
  113187. dispose(): void;
  113188. private _draw;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Defines the shadow generator component responsible to manage any shadow generators
  113194. * in a given scene.
  113195. */
  113196. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  113197. /**
  113198. * The component name helpfull to identify the component in the list of scene components.
  113199. */
  113200. readonly name: string;
  113201. /**
  113202. * The scene the component belongs to.
  113203. */
  113204. scene: Scene;
  113205. /**
  113206. * Creates a new instance of the component for the given scene
  113207. * @param scene Defines the scene to register the component in
  113208. */
  113209. constructor(scene: Scene);
  113210. /**
  113211. * Registers the component in a given scene
  113212. */
  113213. register(): void;
  113214. /**
  113215. * Rebuilds the elements related to this component in case of
  113216. * context lost for instance.
  113217. */
  113218. rebuild(): void;
  113219. /**
  113220. * Serializes the component data to the specified json object
  113221. * @param serializationObject The object to serialize to
  113222. */
  113223. serialize(serializationObject: any): void;
  113224. /**
  113225. * Adds all the elements from the container to the scene
  113226. * @param container the container holding the elements
  113227. */
  113228. addFromContainer(container: AbstractScene): void;
  113229. /**
  113230. * Removes all the elements in the container from the scene
  113231. * @param container contains the elements to remove
  113232. * @param dispose if the removed element should be disposed (default: false)
  113233. */
  113234. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113235. /**
  113236. * Rebuilds the elements related to this component in case of
  113237. * context lost for instance.
  113238. */
  113239. dispose(): void;
  113240. private _gatherRenderTargets;
  113241. }
  113242. }
  113243. declare module BABYLON {
  113244. /**
  113245. * A point light is a light defined by an unique point in world space.
  113246. * The light is emitted in every direction from this point.
  113247. * A good example of a point light is a standard light bulb.
  113248. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113249. */
  113250. export class PointLight extends ShadowLight {
  113251. private _shadowAngle;
  113252. /**
  113253. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113254. * This specifies what angle the shadow will use to be created.
  113255. *
  113256. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113257. */
  113258. /**
  113259. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113260. * This specifies what angle the shadow will use to be created.
  113261. *
  113262. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113263. */
  113264. shadowAngle: number;
  113265. /**
  113266. * Gets the direction if it has been set.
  113267. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113268. */
  113269. /**
  113270. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113271. */
  113272. direction: Vector3;
  113273. /**
  113274. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113275. * A PointLight emits the light in every direction.
  113276. * It can cast shadows.
  113277. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113278. * ```javascript
  113279. * var pointLight = new PointLight("pl", camera.position, scene);
  113280. * ```
  113281. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113282. * @param name The light friendly name
  113283. * @param position The position of the point light in the scene
  113284. * @param scene The scene the lights belongs to
  113285. */
  113286. constructor(name: string, position: Vector3, scene: Scene);
  113287. /**
  113288. * Returns the string "PointLight"
  113289. * @returns the class name
  113290. */
  113291. getClassName(): string;
  113292. /**
  113293. * Returns the integer 0.
  113294. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113295. */
  113296. getTypeID(): number;
  113297. /**
  113298. * Specifies wether or not the shadowmap should be a cube texture.
  113299. * @returns true if the shadowmap needs to be a cube texture.
  113300. */
  113301. needCube(): boolean;
  113302. /**
  113303. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113304. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113305. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113306. */
  113307. getShadowDirection(faceIndex?: number): Vector3;
  113308. /**
  113309. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113310. * - fov = PI / 2
  113311. * - aspect ratio : 1.0
  113312. * - z-near and far equal to the active camera minZ and maxZ.
  113313. * Returns the PointLight.
  113314. */
  113315. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113316. protected _buildUniformLayout(): void;
  113317. /**
  113318. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113319. * @param effect The effect to update
  113320. * @param lightIndex The index of the light in the effect to update
  113321. * @returns The point light
  113322. */
  113323. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113324. /**
  113325. * Prepares the list of defines specific to the light type.
  113326. * @param defines the list of defines
  113327. * @param lightIndex defines the index of the light for the effect
  113328. */
  113329. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113330. }
  113331. }
  113332. declare module BABYLON {
  113333. /**
  113334. * Header information of HDR texture files.
  113335. */
  113336. export interface HDRInfo {
  113337. /**
  113338. * The height of the texture in pixels.
  113339. */
  113340. height: number;
  113341. /**
  113342. * The width of the texture in pixels.
  113343. */
  113344. width: number;
  113345. /**
  113346. * The index of the beginning of the data in the binary file.
  113347. */
  113348. dataPosition: number;
  113349. }
  113350. /**
  113351. * This groups tools to convert HDR texture to native colors array.
  113352. */
  113353. export class HDRTools {
  113354. private static Ldexp;
  113355. private static Rgbe2float;
  113356. private static readStringLine;
  113357. /**
  113358. * Reads header information from an RGBE texture stored in a native array.
  113359. * More information on this format are available here:
  113360. * https://en.wikipedia.org/wiki/RGBE_image_format
  113361. *
  113362. * @param uint8array The binary file stored in native array.
  113363. * @return The header information.
  113364. */
  113365. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113366. /**
  113367. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113368. * This RGBE texture needs to store the information as a panorama.
  113369. *
  113370. * More information on this format are available here:
  113371. * https://en.wikipedia.org/wiki/RGBE_image_format
  113372. *
  113373. * @param buffer The binary file stored in an array buffer.
  113374. * @param size The expected size of the extracted cubemap.
  113375. * @return The Cube Map information.
  113376. */
  113377. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113378. /**
  113379. * Returns the pixels data extracted from an RGBE texture.
  113380. * This pixels will be stored left to right up to down in the R G B order in one array.
  113381. *
  113382. * More information on this format are available here:
  113383. * https://en.wikipedia.org/wiki/RGBE_image_format
  113384. *
  113385. * @param uint8array The binary file stored in an array buffer.
  113386. * @param hdrInfo The header information of the file.
  113387. * @return The pixels data in RGB right to left up to down order.
  113388. */
  113389. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113390. private static RGBE_ReadPixels_RLE;
  113391. }
  113392. }
  113393. declare module BABYLON {
  113394. /**
  113395. * This represents a texture coming from an HDR input.
  113396. *
  113397. * The only supported format is currently panorama picture stored in RGBE format.
  113398. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113399. */
  113400. export class HDRCubeTexture extends BaseTexture {
  113401. private static _facesMapping;
  113402. private _generateHarmonics;
  113403. private _noMipmap;
  113404. private _textureMatrix;
  113405. private _size;
  113406. private _onLoad;
  113407. private _onError;
  113408. /**
  113409. * The texture URL.
  113410. */
  113411. url: string;
  113412. /**
  113413. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113414. */
  113415. coordinatesMode: number;
  113416. protected _isBlocking: boolean;
  113417. /**
  113418. * Sets wether or not the texture is blocking during loading.
  113419. */
  113420. /**
  113421. * Gets wether or not the texture is blocking during loading.
  113422. */
  113423. isBlocking: boolean;
  113424. protected _rotationY: number;
  113425. /**
  113426. * Sets texture matrix rotation angle around Y axis in radians.
  113427. */
  113428. /**
  113429. * Gets texture matrix rotation angle around Y axis radians.
  113430. */
  113431. rotationY: number;
  113432. /**
  113433. * Gets or sets the center of the bounding box associated with the cube texture
  113434. * It must define where the camera used to render the texture was set
  113435. */
  113436. boundingBoxPosition: Vector3;
  113437. private _boundingBoxSize;
  113438. /**
  113439. * Gets or sets the size of the bounding box associated with the cube texture
  113440. * When defined, the cubemap will switch to local mode
  113441. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113442. * @example https://www.babylonjs-playground.com/#RNASML
  113443. */
  113444. boundingBoxSize: Vector3;
  113445. /**
  113446. * Instantiates an HDRTexture from the following parameters.
  113447. *
  113448. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113449. * @param scene The scene the texture will be used in
  113450. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113451. * @param noMipmap Forces to not generate the mipmap if true
  113452. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113453. * @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)
  113454. * @param reserved Reserved flag for internal use.
  113455. */
  113456. 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>);
  113457. /**
  113458. * Get the current class name of the texture useful for serialization or dynamic coding.
  113459. * @returns "HDRCubeTexture"
  113460. */
  113461. getClassName(): string;
  113462. /**
  113463. * Occurs when the file is raw .hdr file.
  113464. */
  113465. private loadTexture;
  113466. clone(): HDRCubeTexture;
  113467. delayLoad(): void;
  113468. /**
  113469. * Get the texture reflection matrix used to rotate/transform the reflection.
  113470. * @returns the reflection matrix
  113471. */
  113472. getReflectionTextureMatrix(): Matrix;
  113473. /**
  113474. * Set the texture reflection matrix used to rotate/transform the reflection.
  113475. * @param value Define the reflection matrix to set
  113476. */
  113477. setReflectionTextureMatrix(value: Matrix): void;
  113478. /**
  113479. * Parses a JSON representation of an HDR Texture in order to create the texture
  113480. * @param parsedTexture Define the JSON representation
  113481. * @param scene Define the scene the texture should be created in
  113482. * @param rootUrl Define the root url in case we need to load relative dependencies
  113483. * @returns the newly created texture after parsing
  113484. */
  113485. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113486. serialize(): any;
  113487. }
  113488. }
  113489. declare module BABYLON {
  113490. /**
  113491. * Class used to control physics engine
  113492. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113493. */
  113494. export class PhysicsEngine implements IPhysicsEngine {
  113495. private _physicsPlugin;
  113496. /**
  113497. * Global value used to control the smallest number supported by the simulation
  113498. */
  113499. static Epsilon: number;
  113500. private _impostors;
  113501. private _joints;
  113502. /**
  113503. * Gets the gravity vector used by the simulation
  113504. */
  113505. gravity: Vector3;
  113506. /**
  113507. * Factory used to create the default physics plugin.
  113508. * @returns The default physics plugin
  113509. */
  113510. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113511. /**
  113512. * Creates a new Physics Engine
  113513. * @param gravity defines the gravity vector used by the simulation
  113514. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113515. */
  113516. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113517. /**
  113518. * Sets the gravity vector used by the simulation
  113519. * @param gravity defines the gravity vector to use
  113520. */
  113521. setGravity(gravity: Vector3): void;
  113522. /**
  113523. * Set the time step of the physics engine.
  113524. * Default is 1/60.
  113525. * To slow it down, enter 1/600 for example.
  113526. * To speed it up, 1/30
  113527. * @param newTimeStep defines the new timestep to apply to this world.
  113528. */
  113529. setTimeStep(newTimeStep?: number): void;
  113530. /**
  113531. * Get the time step of the physics engine.
  113532. * @returns the current time step
  113533. */
  113534. getTimeStep(): number;
  113535. /**
  113536. * Release all resources
  113537. */
  113538. dispose(): void;
  113539. /**
  113540. * Gets the name of the current physics plugin
  113541. * @returns the name of the plugin
  113542. */
  113543. getPhysicsPluginName(): string;
  113544. /**
  113545. * Adding a new impostor for the impostor tracking.
  113546. * This will be done by the impostor itself.
  113547. * @param impostor the impostor to add
  113548. */
  113549. addImpostor(impostor: PhysicsImpostor): void;
  113550. /**
  113551. * Remove an impostor from the engine.
  113552. * This impostor and its mesh will not longer be updated by the physics engine.
  113553. * @param impostor the impostor to remove
  113554. */
  113555. removeImpostor(impostor: PhysicsImpostor): void;
  113556. /**
  113557. * Add a joint to the physics engine
  113558. * @param mainImpostor defines the main impostor to which the joint is added.
  113559. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113560. * @param joint defines the joint that will connect both impostors.
  113561. */
  113562. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113563. /**
  113564. * Removes a joint from the simulation
  113565. * @param mainImpostor defines the impostor used with the joint
  113566. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113567. * @param joint defines the joint to remove
  113568. */
  113569. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113570. /**
  113571. * Called by the scene. No need to call it.
  113572. * @param delta defines the timespam between frames
  113573. */
  113574. _step(delta: number): void;
  113575. /**
  113576. * Gets the current plugin used to run the simulation
  113577. * @returns current plugin
  113578. */
  113579. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113580. /**
  113581. * Gets the list of physic impostors
  113582. * @returns an array of PhysicsImpostor
  113583. */
  113584. getImpostors(): Array<PhysicsImpostor>;
  113585. /**
  113586. * Gets the impostor for a physics enabled object
  113587. * @param object defines the object impersonated by the impostor
  113588. * @returns the PhysicsImpostor or null if not found
  113589. */
  113590. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113591. /**
  113592. * Gets the impostor for a physics body object
  113593. * @param body defines physics body used by the impostor
  113594. * @returns the PhysicsImpostor or null if not found
  113595. */
  113596. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113597. /**
  113598. * Does a raycast in the physics world
  113599. * @param from when should the ray start?
  113600. * @param to when should the ray end?
  113601. * @returns PhysicsRaycastResult
  113602. */
  113603. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113604. }
  113605. }
  113606. declare module BABYLON {
  113607. /** @hidden */
  113608. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  113609. private _useDeltaForWorldStep;
  113610. world: any;
  113611. name: string;
  113612. private _physicsMaterials;
  113613. private _fixedTimeStep;
  113614. private _cannonRaycastResult;
  113615. private _raycastResult;
  113616. private _physicsBodysToRemoveAfterStep;
  113617. BJSCANNON: any;
  113618. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  113619. setGravity(gravity: Vector3): void;
  113620. setTimeStep(timeStep: number): void;
  113621. getTimeStep(): number;
  113622. executeStep(delta: number): void;
  113623. private _removeMarkedPhysicsBodiesFromWorld;
  113624. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113625. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113626. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113627. private _processChildMeshes;
  113628. removePhysicsBody(impostor: PhysicsImpostor): void;
  113629. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113630. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113631. private _addMaterial;
  113632. private _checkWithEpsilon;
  113633. private _createShape;
  113634. private _createHeightmap;
  113635. private _minus90X;
  113636. private _plus90X;
  113637. private _tmpPosition;
  113638. private _tmpDeltaPosition;
  113639. private _tmpUnityRotation;
  113640. private _updatePhysicsBodyTransformation;
  113641. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113643. isSupported(): boolean;
  113644. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113645. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113646. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113647. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113648. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113649. getBodyMass(impostor: PhysicsImpostor): number;
  113650. getBodyFriction(impostor: PhysicsImpostor): number;
  113651. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113652. getBodyRestitution(impostor: PhysicsImpostor): number;
  113653. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113654. sleepBody(impostor: PhysicsImpostor): void;
  113655. wakeUpBody(impostor: PhysicsImpostor): void;
  113656. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  113657. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113658. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113660. getRadius(impostor: PhysicsImpostor): number;
  113661. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113662. dispose(): void;
  113663. private _extendNamespace;
  113664. /**
  113665. * Does a raycast in the physics world
  113666. * @param from when should the ray start?
  113667. * @param to when should the ray end?
  113668. * @returns PhysicsRaycastResult
  113669. */
  113670. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113671. }
  113672. }
  113673. declare module BABYLON {
  113674. /** @hidden */
  113675. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  113676. world: any;
  113677. name: string;
  113678. BJSOIMO: any;
  113679. private _raycastResult;
  113680. constructor(iterations?: number, oimoInjection?: any);
  113681. setGravity(gravity: Vector3): void;
  113682. setTimeStep(timeStep: number): void;
  113683. getTimeStep(): number;
  113684. private _tmpImpostorsArray;
  113685. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113687. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113689. private _tmpPositionVector;
  113690. removePhysicsBody(impostor: PhysicsImpostor): void;
  113691. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113692. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113693. isSupported(): boolean;
  113694. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113695. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113696. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113697. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113698. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113699. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113700. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113701. getBodyMass(impostor: PhysicsImpostor): number;
  113702. getBodyFriction(impostor: PhysicsImpostor): number;
  113703. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113704. getBodyRestitution(impostor: PhysicsImpostor): number;
  113705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113706. sleepBody(impostor: PhysicsImpostor): void;
  113707. wakeUpBody(impostor: PhysicsImpostor): void;
  113708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113709. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  113710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113711. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113712. getRadius(impostor: PhysicsImpostor): number;
  113713. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113714. dispose(): void;
  113715. /**
  113716. * Does a raycast in the physics world
  113717. * @param from when should the ray start?
  113718. * @param to when should the ray end?
  113719. * @returns PhysicsRaycastResult
  113720. */
  113721. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113722. }
  113723. }
  113724. declare module BABYLON {
  113725. /**
  113726. * Class containing static functions to help procedurally build meshes
  113727. */
  113728. export class RibbonBuilder {
  113729. /**
  113730. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113731. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  113732. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  113733. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  113734. * * 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
  113735. * * 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
  113736. * * 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
  113737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113740. * * 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
  113741. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  113742. * * 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
  113743. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  113744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113745. * @param name defines the name of the mesh
  113746. * @param options defines the options used to create the mesh
  113747. * @param scene defines the hosting scene
  113748. * @returns the ribbon mesh
  113749. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  113750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113751. */
  113752. static CreateRibbon(name: string, options: {
  113753. pathArray: Vector3[][];
  113754. closeArray?: boolean;
  113755. closePath?: boolean;
  113756. offset?: number;
  113757. updatable?: boolean;
  113758. sideOrientation?: number;
  113759. frontUVs?: Vector4;
  113760. backUVs?: Vector4;
  113761. instance?: Mesh;
  113762. invertUV?: boolean;
  113763. uvs?: Vector2[];
  113764. colors?: Color4[];
  113765. }, scene?: Nullable<Scene>): Mesh;
  113766. }
  113767. }
  113768. declare module BABYLON {
  113769. /**
  113770. * Class containing static functions to help procedurally build meshes
  113771. */
  113772. export class ShapeBuilder {
  113773. /**
  113774. * 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.
  113775. * * 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.
  113776. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113777. * * 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.
  113778. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  113779. * * 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
  113780. * * 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
  113781. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  113782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  113785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113786. * @param name defines the name of the mesh
  113787. * @param options defines the options used to create the mesh
  113788. * @param scene defines the hosting scene
  113789. * @returns the extruded shape mesh
  113790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113792. */
  113793. static ExtrudeShape(name: string, options: {
  113794. shape: Vector3[];
  113795. path: Vector3[];
  113796. scale?: number;
  113797. rotation?: number;
  113798. cap?: number;
  113799. updatable?: boolean;
  113800. sideOrientation?: number;
  113801. frontUVs?: Vector4;
  113802. backUVs?: Vector4;
  113803. instance?: Mesh;
  113804. invertUV?: boolean;
  113805. }, scene?: Nullable<Scene>): Mesh;
  113806. /**
  113807. * Creates an custom extruded shape mesh.
  113808. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  113809. * * 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.
  113810. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113811. * * 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
  113812. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  113813. * * 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
  113814. * * It must returns a float value that will be the scale value applied to the shape on each path point
  113815. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113816. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  113817. * * 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
  113818. * * 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
  113819. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  113820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113824. * @param name defines the name of the mesh
  113825. * @param options defines the options used to create the mesh
  113826. * @param scene defines the hosting scene
  113827. * @returns the custom extruded shape mesh
  113828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  113829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113831. */
  113832. static ExtrudeShapeCustom(name: string, options: {
  113833. shape: Vector3[];
  113834. path: Vector3[];
  113835. scaleFunction?: any;
  113836. rotationFunction?: any;
  113837. ribbonCloseArray?: boolean;
  113838. ribbonClosePath?: boolean;
  113839. cap?: number;
  113840. updatable?: boolean;
  113841. sideOrientation?: number;
  113842. frontUVs?: Vector4;
  113843. backUVs?: Vector4;
  113844. instance?: Mesh;
  113845. invertUV?: boolean;
  113846. }, scene?: Nullable<Scene>): Mesh;
  113847. private static _ExtrudeShapeGeneric;
  113848. }
  113849. }
  113850. declare module BABYLON {
  113851. /**
  113852. * AmmoJS Physics plugin
  113853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113854. * @see https://github.com/kripken/ammo.js/
  113855. */
  113856. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  113857. private _useDeltaForWorldStep;
  113858. /**
  113859. * Reference to the Ammo library
  113860. */
  113861. bjsAMMO: any;
  113862. /**
  113863. * Created ammoJS world which physics bodies are added to
  113864. */
  113865. world: any;
  113866. /**
  113867. * Name of the plugin
  113868. */
  113869. name: string;
  113870. private _timeStep;
  113871. private _fixedTimeStep;
  113872. private _maxSteps;
  113873. private _tmpQuaternion;
  113874. private _tmpAmmoTransform;
  113875. private _tmpAmmoQuaternion;
  113876. private _tmpAmmoConcreteContactResultCallback;
  113877. private _collisionConfiguration;
  113878. private _dispatcher;
  113879. private _overlappingPairCache;
  113880. private _solver;
  113881. private _softBodySolver;
  113882. private _tmpAmmoVectorA;
  113883. private _tmpAmmoVectorB;
  113884. private _tmpAmmoVectorC;
  113885. private _tmpAmmoVectorD;
  113886. private _tmpContactCallbackResult;
  113887. private _tmpAmmoVectorRCA;
  113888. private _tmpAmmoVectorRCB;
  113889. private _raycastResult;
  113890. private static readonly DISABLE_COLLISION_FLAG;
  113891. private static readonly KINEMATIC_FLAG;
  113892. private static readonly DISABLE_DEACTIVATION_FLAG;
  113893. /**
  113894. * Initializes the ammoJS plugin
  113895. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113896. * @param ammoInjection can be used to inject your own ammo reference
  113897. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  113898. */
  113899. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  113900. /**
  113901. * Sets the gravity of the physics world (m/(s^2))
  113902. * @param gravity Gravity to set
  113903. */
  113904. setGravity(gravity: Vector3): void;
  113905. /**
  113906. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113907. * @param timeStep timestep to use in seconds
  113908. */
  113909. setTimeStep(timeStep: number): void;
  113910. /**
  113911. * 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)
  113912. * @param fixedTimeStep fixedTimeStep to use in seconds
  113913. */
  113914. setFixedTimeStep(fixedTimeStep: number): void;
  113915. /**
  113916. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113917. * @param maxSteps the maximum number of steps by the physics engine per frame
  113918. */
  113919. setMaxSteps(maxSteps: number): void;
  113920. /**
  113921. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113922. * @returns the current timestep in seconds
  113923. */
  113924. getTimeStep(): number;
  113925. private _isImpostorInContact;
  113926. private _isImpostorPairInContact;
  113927. private _stepSimulation;
  113928. /**
  113929. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113930. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113931. * After the step the babylon meshes are set to the position of the physics imposters
  113932. * @param delta amount of time to step forward
  113933. * @param impostors array of imposters to update before/after the step
  113934. */
  113935. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113936. /**
  113937. * Update babylon mesh to match physics world object
  113938. * @param impostor imposter to match
  113939. */
  113940. private _afterSoftStep;
  113941. /**
  113942. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113943. * @param impostor imposter to match
  113944. */
  113945. private _ropeStep;
  113946. /**
  113947. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113948. * @param impostor imposter to match
  113949. */
  113950. private _softbodyOrClothStep;
  113951. private _tmpVector;
  113952. private _tmpMatrix;
  113953. /**
  113954. * Applies an impulse on the imposter
  113955. * @param impostor imposter to apply impulse to
  113956. * @param force amount of force to be applied to the imposter
  113957. * @param contactPoint the location to apply the impulse on the imposter
  113958. */
  113959. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113960. /**
  113961. * Applies a force on the imposter
  113962. * @param impostor imposter to apply force
  113963. * @param force amount of force to be applied to the imposter
  113964. * @param contactPoint the location to apply the force on the imposter
  113965. */
  113966. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113967. /**
  113968. * Creates a physics body using the plugin
  113969. * @param impostor the imposter to create the physics body on
  113970. */
  113971. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113972. /**
  113973. * Removes the physics body from the imposter and disposes of the body's memory
  113974. * @param impostor imposter to remove the physics body from
  113975. */
  113976. removePhysicsBody(impostor: PhysicsImpostor): void;
  113977. /**
  113978. * Generates a joint
  113979. * @param impostorJoint the imposter joint to create the joint with
  113980. */
  113981. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113982. /**
  113983. * Removes a joint
  113984. * @param impostorJoint the imposter joint to remove the joint from
  113985. */
  113986. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113987. private _addMeshVerts;
  113988. /**
  113989. * Initialise the soft body vertices to match its object's (mesh) vertices
  113990. * Softbody vertices (nodes) are in world space and to match this
  113991. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113992. * @param impostor to create the softbody for
  113993. */
  113994. private _softVertexData;
  113995. /**
  113996. * Create an impostor's soft body
  113997. * @param impostor to create the softbody for
  113998. */
  113999. private _createSoftbody;
  114000. /**
  114001. * Create cloth for an impostor
  114002. * @param impostor to create the softbody for
  114003. */
  114004. private _createCloth;
  114005. /**
  114006. * Create rope for an impostor
  114007. * @param impostor to create the softbody for
  114008. */
  114009. private _createRope;
  114010. private _addHullVerts;
  114011. private _createShape;
  114012. /**
  114013. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114014. * @param impostor imposter containing the physics body and babylon object
  114015. */
  114016. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114017. /**
  114018. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114019. * @param impostor imposter containing the physics body and babylon object
  114020. * @param newPosition new position
  114021. * @param newRotation new rotation
  114022. */
  114023. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114024. /**
  114025. * If this plugin is supported
  114026. * @returns true if its supported
  114027. */
  114028. isSupported(): boolean;
  114029. /**
  114030. * Sets the linear velocity of the physics body
  114031. * @param impostor imposter to set the velocity on
  114032. * @param velocity velocity to set
  114033. */
  114034. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114035. /**
  114036. * Sets the angular velocity of the physics body
  114037. * @param impostor imposter to set the velocity on
  114038. * @param velocity velocity to set
  114039. */
  114040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114041. /**
  114042. * gets the linear velocity
  114043. * @param impostor imposter to get linear velocity from
  114044. * @returns linear velocity
  114045. */
  114046. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114047. /**
  114048. * gets the angular velocity
  114049. * @param impostor imposter to get angular velocity from
  114050. * @returns angular velocity
  114051. */
  114052. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114053. /**
  114054. * Sets the mass of physics body
  114055. * @param impostor imposter to set the mass on
  114056. * @param mass mass to set
  114057. */
  114058. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114059. /**
  114060. * Gets the mass of the physics body
  114061. * @param impostor imposter to get the mass from
  114062. * @returns mass
  114063. */
  114064. getBodyMass(impostor: PhysicsImpostor): number;
  114065. /**
  114066. * Gets friction of the impostor
  114067. * @param impostor impostor to get friction from
  114068. * @returns friction value
  114069. */
  114070. getBodyFriction(impostor: PhysicsImpostor): number;
  114071. /**
  114072. * Sets friction of the impostor
  114073. * @param impostor impostor to set friction on
  114074. * @param friction friction value
  114075. */
  114076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114077. /**
  114078. * Gets restitution of the impostor
  114079. * @param impostor impostor to get restitution from
  114080. * @returns restitution value
  114081. */
  114082. getBodyRestitution(impostor: PhysicsImpostor): number;
  114083. /**
  114084. * Sets resitution of the impostor
  114085. * @param impostor impostor to set resitution on
  114086. * @param restitution resitution value
  114087. */
  114088. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114089. /**
  114090. * Gets pressure inside the impostor
  114091. * @param impostor impostor to get pressure from
  114092. * @returns pressure value
  114093. */
  114094. getBodyPressure(impostor: PhysicsImpostor): number;
  114095. /**
  114096. * Sets pressure inside a soft body impostor
  114097. * Cloth and rope must remain 0 pressure
  114098. * @param impostor impostor to set pressure on
  114099. * @param pressure pressure value
  114100. */
  114101. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  114102. /**
  114103. * Gets stiffness of the impostor
  114104. * @param impostor impostor to get stiffness from
  114105. * @returns pressure value
  114106. */
  114107. getBodyStiffness(impostor: PhysicsImpostor): number;
  114108. /**
  114109. * Sets stiffness of the impostor
  114110. * @param impostor impostor to set stiffness on
  114111. * @param stiffness stiffness value from 0 to 1
  114112. */
  114113. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  114114. /**
  114115. * Gets velocityIterations of the impostor
  114116. * @param impostor impostor to get velocity iterations from
  114117. * @returns velocityIterations value
  114118. */
  114119. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  114120. /**
  114121. * Sets velocityIterations of the impostor
  114122. * @param impostor impostor to set velocity iterations on
  114123. * @param velocityIterations velocityIterations value
  114124. */
  114125. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  114126. /**
  114127. * Gets positionIterations of the impostor
  114128. * @param impostor impostor to get position iterations from
  114129. * @returns positionIterations value
  114130. */
  114131. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  114132. /**
  114133. * Sets positionIterations of the impostor
  114134. * @param impostor impostor to set position on
  114135. * @param positionIterations positionIterations value
  114136. */
  114137. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  114138. /**
  114139. * Append an anchor to a cloth object
  114140. * @param impostor is the cloth impostor to add anchor to
  114141. * @param otherImpostor is the rigid impostor to anchor to
  114142. * @param width ratio across width from 0 to 1
  114143. * @param height ratio up height from 0 to 1
  114144. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114145. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114146. */
  114147. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114148. /**
  114149. * Append an hook to a rope object
  114150. * @param impostor is the rope impostor to add hook to
  114151. * @param otherImpostor is the rigid impostor to hook to
  114152. * @param length ratio along the rope from 0 to 1
  114153. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114154. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114155. */
  114156. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114157. /**
  114158. * Sleeps the physics body and stops it from being active
  114159. * @param impostor impostor to sleep
  114160. */
  114161. sleepBody(impostor: PhysicsImpostor): void;
  114162. /**
  114163. * Activates the physics body
  114164. * @param impostor impostor to activate
  114165. */
  114166. wakeUpBody(impostor: PhysicsImpostor): void;
  114167. /**
  114168. * Updates the distance parameters of the joint
  114169. * @param joint joint to update
  114170. * @param maxDistance maximum distance of the joint
  114171. * @param minDistance minimum distance of the joint
  114172. */
  114173. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114174. /**
  114175. * Sets a motor on the joint
  114176. * @param joint joint to set motor on
  114177. * @param speed speed of the motor
  114178. * @param maxForce maximum force of the motor
  114179. * @param motorIndex index of the motor
  114180. */
  114181. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114182. /**
  114183. * Sets the motors limit
  114184. * @param joint joint to set limit on
  114185. * @param upperLimit upper limit
  114186. * @param lowerLimit lower limit
  114187. */
  114188. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114189. /**
  114190. * Syncs the position and rotation of a mesh with the impostor
  114191. * @param mesh mesh to sync
  114192. * @param impostor impostor to update the mesh with
  114193. */
  114194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114195. /**
  114196. * Gets the radius of the impostor
  114197. * @param impostor impostor to get radius from
  114198. * @returns the radius
  114199. */
  114200. getRadius(impostor: PhysicsImpostor): number;
  114201. /**
  114202. * Gets the box size of the impostor
  114203. * @param impostor impostor to get box size from
  114204. * @param result the resulting box size
  114205. */
  114206. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114207. /**
  114208. * Disposes of the impostor
  114209. */
  114210. dispose(): void;
  114211. /**
  114212. * Does a raycast in the physics world
  114213. * @param from when should the ray start?
  114214. * @param to when should the ray end?
  114215. * @returns PhysicsRaycastResult
  114216. */
  114217. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114218. }
  114219. }
  114220. declare module BABYLON {
  114221. interface AbstractScene {
  114222. /**
  114223. * The list of reflection probes added to the scene
  114224. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114225. */
  114226. reflectionProbes: Array<ReflectionProbe>;
  114227. /**
  114228. * Removes the given reflection probe from this scene.
  114229. * @param toRemove The reflection probe to remove
  114230. * @returns The index of the removed reflection probe
  114231. */
  114232. removeReflectionProbe(toRemove: ReflectionProbe): number;
  114233. /**
  114234. * Adds the given reflection probe to this scene.
  114235. * @param newReflectionProbe The reflection probe to add
  114236. */
  114237. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  114238. }
  114239. /**
  114240. * Class used to generate realtime reflection / refraction cube textures
  114241. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114242. */
  114243. export class ReflectionProbe {
  114244. /** defines the name of the probe */
  114245. name: string;
  114246. private _scene;
  114247. private _renderTargetTexture;
  114248. private _projectionMatrix;
  114249. private _viewMatrix;
  114250. private _target;
  114251. private _add;
  114252. private _attachedMesh;
  114253. private _invertYAxis;
  114254. /** Gets or sets probe position (center of the cube map) */
  114255. position: Vector3;
  114256. /**
  114257. * Creates a new reflection probe
  114258. * @param name defines the name of the probe
  114259. * @param size defines the texture resolution (for each face)
  114260. * @param scene defines the hosting scene
  114261. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  114262. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  114263. */
  114264. constructor(
  114265. /** defines the name of the probe */
  114266. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  114267. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  114268. samples: number;
  114269. /** Gets or sets the refresh rate to use (on every frame by default) */
  114270. refreshRate: number;
  114271. /**
  114272. * Gets the hosting scene
  114273. * @returns a Scene
  114274. */
  114275. getScene(): Scene;
  114276. /** Gets the internal CubeTexture used to render to */
  114277. readonly cubeTexture: RenderTargetTexture;
  114278. /** Gets the list of meshes to render */
  114279. readonly renderList: Nullable<AbstractMesh[]>;
  114280. /**
  114281. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114282. * @param mesh defines the mesh to attach to
  114283. */
  114284. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114285. /**
  114286. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114287. * @param renderingGroupId The rendering group id corresponding to its index
  114288. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114289. */
  114290. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114291. /**
  114292. * Clean all associated resources
  114293. */
  114294. dispose(): void;
  114295. /**
  114296. * Converts the reflection probe information to a readable string for debug purpose.
  114297. * @param fullDetails Supports for multiple levels of logging within scene loading
  114298. * @returns the human readable reflection probe info
  114299. */
  114300. toString(fullDetails?: boolean): string;
  114301. /**
  114302. * Get the class name of the relfection probe.
  114303. * @returns "ReflectionProbe"
  114304. */
  114305. getClassName(): string;
  114306. /**
  114307. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114308. * @returns The JSON representation of the texture
  114309. */
  114310. serialize(): any;
  114311. /**
  114312. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114313. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114314. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114315. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114316. * @returns The parsed reflection probe if successful
  114317. */
  114318. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114319. }
  114320. }
  114321. declare module BABYLON {
  114322. /** @hidden */
  114323. export var _BabylonLoaderRegistered: boolean;
  114324. }
  114325. declare module BABYLON {
  114326. /**
  114327. * The Physically based simple base material of BJS.
  114328. *
  114329. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114330. * It is used as the base class for both the specGloss and metalRough conventions.
  114331. */
  114332. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114333. /**
  114334. * Number of Simultaneous lights allowed on the material.
  114335. */
  114336. maxSimultaneousLights: number;
  114337. /**
  114338. * If sets to true, disables all the lights affecting the material.
  114339. */
  114340. disableLighting: boolean;
  114341. /**
  114342. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114343. */
  114344. environmentTexture: BaseTexture;
  114345. /**
  114346. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114347. */
  114348. invertNormalMapX: boolean;
  114349. /**
  114350. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114351. */
  114352. invertNormalMapY: boolean;
  114353. /**
  114354. * Normal map used in the model.
  114355. */
  114356. normalTexture: BaseTexture;
  114357. /**
  114358. * Emissivie color used to self-illuminate the model.
  114359. */
  114360. emissiveColor: Color3;
  114361. /**
  114362. * Emissivie texture used to self-illuminate the model.
  114363. */
  114364. emissiveTexture: BaseTexture;
  114365. /**
  114366. * Occlusion Channel Strenght.
  114367. */
  114368. occlusionStrength: number;
  114369. /**
  114370. * Occlusion Texture of the material (adding extra occlusion effects).
  114371. */
  114372. occlusionTexture: BaseTexture;
  114373. /**
  114374. * Defines the alpha limits in alpha test mode.
  114375. */
  114376. alphaCutOff: number;
  114377. /**
  114378. * Gets the current double sided mode.
  114379. */
  114380. /**
  114381. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114382. */
  114383. doubleSided: boolean;
  114384. /**
  114385. * Stores the pre-calculated light information of a mesh in a texture.
  114386. */
  114387. lightmapTexture: BaseTexture;
  114388. /**
  114389. * If true, the light map contains occlusion information instead of lighting info.
  114390. */
  114391. useLightmapAsShadowmap: boolean;
  114392. /**
  114393. * Instantiates a new PBRMaterial instance.
  114394. *
  114395. * @param name The material name
  114396. * @param scene The scene the material will be use in.
  114397. */
  114398. constructor(name: string, scene: Scene);
  114399. getClassName(): string;
  114400. }
  114401. }
  114402. declare module BABYLON {
  114403. /**
  114404. * The PBR material of BJS following the metal roughness convention.
  114405. *
  114406. * This fits to the PBR convention in the GLTF definition:
  114407. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114408. */
  114409. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114410. /**
  114411. * The base color has two different interpretations depending on the value of metalness.
  114412. * When the material is a metal, the base color is the specific measured reflectance value
  114413. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114414. * of the material.
  114415. */
  114416. baseColor: Color3;
  114417. /**
  114418. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114419. * well as opacity information in the alpha channel.
  114420. */
  114421. baseTexture: BaseTexture;
  114422. /**
  114423. * Specifies the metallic scalar value of the material.
  114424. * Can also be used to scale the metalness values of the metallic texture.
  114425. */
  114426. metallic: number;
  114427. /**
  114428. * Specifies the roughness scalar value of the material.
  114429. * Can also be used to scale the roughness values of the metallic texture.
  114430. */
  114431. roughness: number;
  114432. /**
  114433. * Texture containing both the metallic value in the B channel and the
  114434. * roughness value in the G channel to keep better precision.
  114435. */
  114436. metallicRoughnessTexture: BaseTexture;
  114437. /**
  114438. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114439. *
  114440. * @param name The material name
  114441. * @param scene The scene the material will be use in.
  114442. */
  114443. constructor(name: string, scene: Scene);
  114444. /**
  114445. * Return the currrent class name of the material.
  114446. */
  114447. getClassName(): string;
  114448. /**
  114449. * Makes a duplicate of the current material.
  114450. * @param name - name to use for the new material.
  114451. */
  114452. clone(name: string): PBRMetallicRoughnessMaterial;
  114453. /**
  114454. * Serialize the material to a parsable JSON object.
  114455. */
  114456. serialize(): any;
  114457. /**
  114458. * Parses a JSON object correponding to the serialize function.
  114459. */
  114460. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114461. }
  114462. }
  114463. declare module BABYLON {
  114464. /**
  114465. * The PBR material of BJS following the specular glossiness convention.
  114466. *
  114467. * This fits to the PBR convention in the GLTF definition:
  114468. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114469. */
  114470. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114471. /**
  114472. * Specifies the diffuse color of the material.
  114473. */
  114474. diffuseColor: Color3;
  114475. /**
  114476. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114477. * channel.
  114478. */
  114479. diffuseTexture: BaseTexture;
  114480. /**
  114481. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114482. */
  114483. specularColor: Color3;
  114484. /**
  114485. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114486. */
  114487. glossiness: number;
  114488. /**
  114489. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114490. */
  114491. specularGlossinessTexture: BaseTexture;
  114492. /**
  114493. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114494. *
  114495. * @param name The material name
  114496. * @param scene The scene the material will be use in.
  114497. */
  114498. constructor(name: string, scene: Scene);
  114499. /**
  114500. * Return the currrent class name of the material.
  114501. */
  114502. getClassName(): string;
  114503. /**
  114504. * Makes a duplicate of the current material.
  114505. * @param name - name to use for the new material.
  114506. */
  114507. clone(name: string): PBRSpecularGlossinessMaterial;
  114508. /**
  114509. * Serialize the material to a parsable JSON object.
  114510. */
  114511. serialize(): any;
  114512. /**
  114513. * Parses a JSON object correponding to the serialize function.
  114514. */
  114515. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114516. }
  114517. }
  114518. declare module BABYLON {
  114519. /**
  114520. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114521. * It can help converting any input color in a desired output one. This can then be used to create effects
  114522. * from sepia, black and white to sixties or futuristic rendering...
  114523. *
  114524. * The only supported format is currently 3dl.
  114525. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  114526. */
  114527. export class ColorGradingTexture extends BaseTexture {
  114528. /**
  114529. * The current texture matrix. (will always be identity in color grading texture)
  114530. */
  114531. private _textureMatrix;
  114532. /**
  114533. * The texture URL.
  114534. */
  114535. url: string;
  114536. /**
  114537. * Empty line regex stored for GC.
  114538. */
  114539. private static _noneEmptyLineRegex;
  114540. private _engine;
  114541. /**
  114542. * Instantiates a ColorGradingTexture from the following parameters.
  114543. *
  114544. * @param url The location of the color gradind data (currently only supporting 3dl)
  114545. * @param scene The scene the texture will be used in
  114546. */
  114547. constructor(url: string, scene: Scene);
  114548. /**
  114549. * Returns the texture matrix used in most of the material.
  114550. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  114551. */
  114552. getTextureMatrix(): Matrix;
  114553. /**
  114554. * Occurs when the file being loaded is a .3dl LUT file.
  114555. */
  114556. private load3dlTexture;
  114557. /**
  114558. * Starts the loading process of the texture.
  114559. */
  114560. private loadTexture;
  114561. /**
  114562. * Clones the color gradind texture.
  114563. */
  114564. clone(): ColorGradingTexture;
  114565. /**
  114566. * Called during delayed load for textures.
  114567. */
  114568. delayLoad(): void;
  114569. /**
  114570. * Parses a color grading texture serialized by Babylon.
  114571. * @param parsedTexture The texture information being parsedTexture
  114572. * @param scene The scene to load the texture in
  114573. * @param rootUrl The root url of the data assets to load
  114574. * @return A color gradind texture
  114575. */
  114576. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  114577. /**
  114578. * Serializes the LUT texture to json format.
  114579. */
  114580. serialize(): any;
  114581. }
  114582. }
  114583. declare module BABYLON {
  114584. /**
  114585. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  114586. */
  114587. export class EquiRectangularCubeTexture extends BaseTexture {
  114588. /** The six faces of the cube. */
  114589. private static _FacesMapping;
  114590. private _noMipmap;
  114591. private _onLoad;
  114592. private _onError;
  114593. /** The size of the cubemap. */
  114594. private _size;
  114595. /** The buffer of the image. */
  114596. private _buffer;
  114597. /** The width of the input image. */
  114598. private _width;
  114599. /** The height of the input image. */
  114600. private _height;
  114601. /** The URL to the image. */
  114602. url: string;
  114603. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  114604. coordinatesMode: number;
  114605. /**
  114606. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  114607. * @param url The location of the image
  114608. * @param scene The scene the texture will be used in
  114609. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114610. * @param noMipmap Forces to not generate the mipmap if true
  114611. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114612. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114613. * @param onLoad — defines a callback called when texture is loaded
  114614. * @param onError — defines a callback called if there is an error
  114615. */
  114616. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  114617. /**
  114618. * Load the image data, by putting the image on a canvas and extracting its buffer.
  114619. */
  114620. private loadImage;
  114621. /**
  114622. * Convert the image buffer into a cubemap and create a CubeTexture.
  114623. */
  114624. private loadTexture;
  114625. /**
  114626. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  114627. * @param buffer The ArrayBuffer that should be converted.
  114628. * @returns The buffer as Float32Array.
  114629. */
  114630. private getFloat32ArrayFromArrayBuffer;
  114631. /**
  114632. * Get the current class name of the texture useful for serialization or dynamic coding.
  114633. * @returns "EquiRectangularCubeTexture"
  114634. */
  114635. getClassName(): string;
  114636. /**
  114637. * Create a clone of the current EquiRectangularCubeTexture and return it.
  114638. * @returns A clone of the current EquiRectangularCubeTexture.
  114639. */
  114640. clone(): EquiRectangularCubeTexture;
  114641. }
  114642. }
  114643. declare module BABYLON {
  114644. /**
  114645. * Based on jsTGALoader - Javascript loader for TGA file
  114646. * By Vincent Thibault
  114647. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114648. */
  114649. export class TGATools {
  114650. private static _TYPE_INDEXED;
  114651. private static _TYPE_RGB;
  114652. private static _TYPE_GREY;
  114653. private static _TYPE_RLE_INDEXED;
  114654. private static _TYPE_RLE_RGB;
  114655. private static _TYPE_RLE_GREY;
  114656. private static _ORIGIN_MASK;
  114657. private static _ORIGIN_SHIFT;
  114658. private static _ORIGIN_BL;
  114659. private static _ORIGIN_BR;
  114660. private static _ORIGIN_UL;
  114661. private static _ORIGIN_UR;
  114662. /**
  114663. * Gets the header of a TGA file
  114664. * @param data defines the TGA data
  114665. * @returns the header
  114666. */
  114667. static GetTGAHeader(data: Uint8Array): any;
  114668. /**
  114669. * Uploads TGA content to a Babylon Texture
  114670. * @hidden
  114671. */
  114672. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  114673. /** @hidden */
  114674. 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;
  114675. /** @hidden */
  114676. 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;
  114677. /** @hidden */
  114678. 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;
  114679. /** @hidden */
  114680. 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;
  114681. /** @hidden */
  114682. 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;
  114683. /** @hidden */
  114684. 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;
  114685. }
  114686. }
  114687. declare module BABYLON {
  114688. /**
  114689. * Implementation of the TGA Texture Loader.
  114690. * @hidden
  114691. */
  114692. export class _TGATextureLoader implements IInternalTextureLoader {
  114693. /**
  114694. * Defines wether the loader supports cascade loading the different faces.
  114695. */
  114696. readonly supportCascades: boolean;
  114697. /**
  114698. * This returns if the loader support the current file information.
  114699. * @param extension defines the file extension of the file being loaded
  114700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114701. * @param fallback defines the fallback internal texture if any
  114702. * @param isBase64 defines whether the texture is encoded as a base64
  114703. * @param isBuffer defines whether the texture data are stored as a buffer
  114704. * @returns true if the loader can load the specified file
  114705. */
  114706. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114707. /**
  114708. * Transform the url before loading if required.
  114709. * @param rootUrl the url of the texture
  114710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114711. * @returns the transformed texture
  114712. */
  114713. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114714. /**
  114715. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114716. * @param rootUrl the url of the texture
  114717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114718. * @returns the fallback texture
  114719. */
  114720. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114721. /**
  114722. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114723. * @param data contains the texture data
  114724. * @param texture defines the BabylonJS internal texture
  114725. * @param createPolynomials will be true if polynomials have been requested
  114726. * @param onLoad defines the callback to trigger once the texture is ready
  114727. * @param onError defines the callback to trigger in case of error
  114728. */
  114729. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114730. /**
  114731. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114732. * @param data contains the texture data
  114733. * @param texture defines the BabylonJS internal texture
  114734. * @param callback defines the method to call once ready to upload
  114735. */
  114736. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114737. }
  114738. }
  114739. declare module BABYLON {
  114740. /**
  114741. * Info about the .basis files
  114742. */
  114743. class BasisFileInfo {
  114744. /**
  114745. * If the file has alpha
  114746. */
  114747. hasAlpha: boolean;
  114748. /**
  114749. * Info about each image of the basis file
  114750. */
  114751. images: Array<{
  114752. levels: Array<{
  114753. width: number;
  114754. height: number;
  114755. transcodedPixels: ArrayBufferView;
  114756. }>;
  114757. }>;
  114758. }
  114759. /**
  114760. * Result of transcoding a basis file
  114761. */
  114762. class TranscodeResult {
  114763. /**
  114764. * Info about the .basis file
  114765. */
  114766. fileInfo: BasisFileInfo;
  114767. /**
  114768. * Format to use when loading the file
  114769. */
  114770. format: number;
  114771. }
  114772. /**
  114773. * Configuration options for the Basis transcoder
  114774. */
  114775. export class BasisTranscodeConfiguration {
  114776. /**
  114777. * Supported compression formats used to determine the supported output format of the transcoder
  114778. */
  114779. supportedCompressionFormats?: {
  114780. /**
  114781. * etc1 compression format
  114782. */
  114783. etc1?: boolean;
  114784. /**
  114785. * s3tc compression format
  114786. */
  114787. s3tc?: boolean;
  114788. /**
  114789. * pvrtc compression format
  114790. */
  114791. pvrtc?: boolean;
  114792. /**
  114793. * etc2 compression format
  114794. */
  114795. etc2?: boolean;
  114796. };
  114797. /**
  114798. * If mipmap levels should be loaded for transcoded images (Default: true)
  114799. */
  114800. loadMipmapLevels?: boolean;
  114801. /**
  114802. * Index of a single image to load (Default: all images)
  114803. */
  114804. loadSingleImage?: number;
  114805. }
  114806. /**
  114807. * Used to load .Basis files
  114808. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  114809. */
  114810. export class BasisTools {
  114811. private static _IgnoreSupportedFormats;
  114812. /**
  114813. * URL to use when loading the basis transcoder
  114814. */
  114815. static JSModuleURL: string;
  114816. /**
  114817. * URL to use when loading the wasm module for the transcoder
  114818. */
  114819. static WasmModuleURL: string;
  114820. /**
  114821. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  114822. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  114823. * @returns internal format corresponding to the Basis format
  114824. */
  114825. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  114826. private static _WorkerPromise;
  114827. private static _Worker;
  114828. private static _actionId;
  114829. private static _CreateWorkerAsync;
  114830. /**
  114831. * Transcodes a loaded image file to compressed pixel data
  114832. * @param imageData image data to transcode
  114833. * @param config configuration options for the transcoding
  114834. * @returns a promise resulting in the transcoded image
  114835. */
  114836. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  114837. /**
  114838. * Loads a texture from the transcode result
  114839. * @param texture texture load to
  114840. * @param transcodeResult the result of transcoding the basis file to load from
  114841. */
  114842. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  114843. }
  114844. }
  114845. declare module BABYLON {
  114846. /**
  114847. * Loader for .basis file format
  114848. */
  114849. export class _BasisTextureLoader implements IInternalTextureLoader {
  114850. /**
  114851. * Defines whether the loader supports cascade loading the different faces.
  114852. */
  114853. readonly supportCascades: boolean;
  114854. /**
  114855. * This returns if the loader support the current file information.
  114856. * @param extension defines the file extension of the file being loaded
  114857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114858. * @param fallback defines the fallback internal texture if any
  114859. * @param isBase64 defines whether the texture is encoded as a base64
  114860. * @param isBuffer defines whether the texture data are stored as a buffer
  114861. * @returns true if the loader can load the specified file
  114862. */
  114863. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114864. /**
  114865. * Transform the url before loading if required.
  114866. * @param rootUrl the url of the texture
  114867. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114868. * @returns the transformed texture
  114869. */
  114870. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114871. /**
  114872. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114873. * @param rootUrl the url of the texture
  114874. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114875. * @returns the fallback texture
  114876. */
  114877. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114878. /**
  114879. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  114880. * @param data contains the texture data
  114881. * @param texture defines the BabylonJS internal texture
  114882. * @param createPolynomials will be true if polynomials have been requested
  114883. * @param onLoad defines the callback to trigger once the texture is ready
  114884. * @param onError defines the callback to trigger in case of error
  114885. */
  114886. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114887. /**
  114888. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114889. * @param data contains the texture data
  114890. * @param texture defines the BabylonJS internal texture
  114891. * @param callback defines the method to call once ready to upload
  114892. */
  114893. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114894. }
  114895. }
  114896. declare module BABYLON {
  114897. /**
  114898. * 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.
  114899. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114900. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114901. */
  114902. export class CustomProceduralTexture extends ProceduralTexture {
  114903. private _animate;
  114904. private _time;
  114905. private _config;
  114906. private _texturePath;
  114907. /**
  114908. * Instantiates a new Custom Procedural Texture.
  114909. * 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.
  114910. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114911. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114912. * @param name Define the name of the texture
  114913. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114914. * @param size Define the size of the texture to create
  114915. * @param scene Define the scene the texture belongs to
  114916. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114917. * @param generateMipMaps Define if the texture should creates mip maps or not
  114918. */
  114919. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114920. private _loadJson;
  114921. /**
  114922. * Is the texture ready to be used ? (rendered at least once)
  114923. * @returns true if ready, otherwise, false.
  114924. */
  114925. isReady(): boolean;
  114926. /**
  114927. * Render the texture to its associated render target.
  114928. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114929. */
  114930. render(useCameraPostProcess?: boolean): void;
  114931. /**
  114932. * Update the list of dependant textures samplers in the shader.
  114933. */
  114934. updateTextures(): void;
  114935. /**
  114936. * Update the uniform values of the procedural texture in the shader.
  114937. */
  114938. updateShaderUniforms(): void;
  114939. /**
  114940. * Define if the texture animates or not.
  114941. */
  114942. animate: boolean;
  114943. }
  114944. }
  114945. declare module BABYLON {
  114946. /** @hidden */
  114947. export var noisePixelShader: {
  114948. name: string;
  114949. shader: string;
  114950. };
  114951. }
  114952. declare module BABYLON {
  114953. /**
  114954. * Class used to generate noise procedural textures
  114955. */
  114956. export class NoiseProceduralTexture extends ProceduralTexture {
  114957. private _time;
  114958. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114959. brightness: number;
  114960. /** Defines the number of octaves to process */
  114961. octaves: number;
  114962. /** Defines the level of persistence (0.8 by default) */
  114963. persistence: number;
  114964. /** Gets or sets animation speed factor (default is 1) */
  114965. animationSpeedFactor: number;
  114966. /**
  114967. * Creates a new NoiseProceduralTexture
  114968. * @param name defines the name fo the texture
  114969. * @param size defines the size of the texture (default is 256)
  114970. * @param scene defines the hosting scene
  114971. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114972. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114973. */
  114974. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114975. private _updateShaderUniforms;
  114976. protected _getDefines(): string;
  114977. /** Generate the current state of the procedural texture */
  114978. render(useCameraPostProcess?: boolean): void;
  114979. /**
  114980. * Serializes this noise procedural texture
  114981. * @returns a serialized noise procedural texture object
  114982. */
  114983. serialize(): any;
  114984. /**
  114985. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114986. * @param parsedTexture defines parsed texture data
  114987. * @param scene defines the current scene
  114988. * @param rootUrl defines the root URL containing noise procedural texture information
  114989. * @returns a parsed NoiseProceduralTexture
  114990. */
  114991. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114992. }
  114993. }
  114994. declare module BABYLON {
  114995. /**
  114996. * Raw cube texture where the raw buffers are passed in
  114997. */
  114998. export class RawCubeTexture extends CubeTexture {
  114999. /**
  115000. * Creates a cube texture where the raw buffers are passed in.
  115001. * @param scene defines the scene the texture is attached to
  115002. * @param data defines the array of data to use to create each face
  115003. * @param size defines the size of the textures
  115004. * @param format defines the format of the data
  115005. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  115006. * @param generateMipMaps defines if the engine should generate the mip levels
  115007. * @param invertY defines if data must be stored with Y axis inverted
  115008. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  115009. * @param compression defines the compression used (null by default)
  115010. */
  115011. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  115012. /**
  115013. * Updates the raw cube texture.
  115014. * @param data defines the data to store
  115015. * @param format defines the data format
  115016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  115017. * @param invertY defines if data must be stored with Y axis inverted
  115018. * @param compression defines the compression used (null by default)
  115019. * @param level defines which level of the texture to update
  115020. */
  115021. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  115022. /**
  115023. * Updates a raw cube texture with RGBD encoded data.
  115024. * @param data defines the array of data [mipmap][face] to use to create each face
  115025. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  115026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115028. * @returns a promsie that resolves when the operation is complete
  115029. */
  115030. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  115031. /**
  115032. * Clones the raw cube texture.
  115033. * @return a new cube texture
  115034. */
  115035. clone(): CubeTexture;
  115036. /** @hidden */
  115037. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115038. }
  115039. }
  115040. declare module BABYLON {
  115041. /**
  115042. * Class used to store 3D textures containing user data
  115043. */
  115044. export class RawTexture3D extends Texture {
  115045. /** Gets or sets the texture format to use */
  115046. format: number;
  115047. private _engine;
  115048. /**
  115049. * Create a new RawTexture3D
  115050. * @param data defines the data of the texture
  115051. * @param width defines the width of the texture
  115052. * @param height defines the height of the texture
  115053. * @param depth defines the depth of the texture
  115054. * @param format defines the texture format to use
  115055. * @param scene defines the hosting scene
  115056. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115057. * @param invertY defines if texture must be stored with Y axis inverted
  115058. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115059. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115060. */
  115061. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115062. /** Gets or sets the texture format to use */
  115063. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115064. /**
  115065. * Update the texture with new data
  115066. * @param data defines the data to store in the texture
  115067. */
  115068. update(data: ArrayBufferView): void;
  115069. }
  115070. }
  115071. declare module BABYLON {
  115072. /**
  115073. * Creates a refraction texture used by refraction channel of the standard material.
  115074. * It is like a mirror but to see through a material.
  115075. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115076. */
  115077. export class RefractionTexture extends RenderTargetTexture {
  115078. /**
  115079. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115080. * 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.
  115081. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115082. */
  115083. refractionPlane: Plane;
  115084. /**
  115085. * Define how deep under the surface we should see.
  115086. */
  115087. depth: number;
  115088. /**
  115089. * Creates a refraction texture used by refraction channel of the standard material.
  115090. * It is like a mirror but to see through a material.
  115091. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115092. * @param name Define the texture name
  115093. * @param size Define the size of the underlying texture
  115094. * @param scene Define the scene the refraction belongs to
  115095. * @param generateMipMaps Define if we need to generate mips level for the refraction
  115096. */
  115097. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  115098. /**
  115099. * Clone the refraction texture.
  115100. * @returns the cloned texture
  115101. */
  115102. clone(): RefractionTexture;
  115103. /**
  115104. * Serialize the texture to a JSON representation you could use in Parse later on
  115105. * @returns the serialized JSON representation
  115106. */
  115107. serialize(): any;
  115108. }
  115109. }
  115110. declare module BABYLON {
  115111. /**
  115112. * Defines the options related to the creation of an HtmlElementTexture
  115113. */
  115114. export interface IHtmlElementTextureOptions {
  115115. /**
  115116. * Defines wether mip maps should be created or not.
  115117. */
  115118. generateMipMaps?: boolean;
  115119. /**
  115120. * Defines the sampling mode of the texture.
  115121. */
  115122. samplingMode?: number;
  115123. /**
  115124. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  115125. */
  115126. engine: Nullable<Engine>;
  115127. /**
  115128. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  115129. */
  115130. scene: Nullable<Scene>;
  115131. }
  115132. /**
  115133. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  115134. * To be as efficient as possible depending on your constraints nothing aside the first upload
  115135. * is automatically managed.
  115136. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  115137. * in your application.
  115138. *
  115139. * As the update is not automatic, you need to call them manually.
  115140. */
  115141. export class HtmlElementTexture extends BaseTexture {
  115142. /**
  115143. * The texture URL.
  115144. */
  115145. element: HTMLVideoElement | HTMLCanvasElement;
  115146. private static readonly DefaultOptions;
  115147. private _textureMatrix;
  115148. private _engine;
  115149. private _isVideo;
  115150. private _generateMipMaps;
  115151. private _samplingMode;
  115152. /**
  115153. * Instantiates a HtmlElementTexture from the following parameters.
  115154. *
  115155. * @param name Defines the name of the texture
  115156. * @param element Defines the video or canvas the texture is filled with
  115157. * @param options Defines the other none mandatory texture creation options
  115158. */
  115159. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  115160. private _createInternalTexture;
  115161. /**
  115162. * Returns the texture matrix used in most of the material.
  115163. */
  115164. getTextureMatrix(): Matrix;
  115165. /**
  115166. * Updates the content of the texture.
  115167. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  115168. */
  115169. update(invertY?: Nullable<boolean>): void;
  115170. }
  115171. }
  115172. declare module BABYLON {
  115173. /**
  115174. * Enum used to define the target of a block
  115175. */
  115176. export enum NodeMaterialBlockTargets {
  115177. /** Vertex shader */
  115178. Vertex = 1,
  115179. /** Fragment shader */
  115180. Fragment = 2,
  115181. /** Neutral */
  115182. Neutral = 4,
  115183. /** Vertex and Fragment */
  115184. VertexAndFragment = 3
  115185. }
  115186. }
  115187. declare module BABYLON {
  115188. /**
  115189. * Defines the kind of connection point for node based material
  115190. */
  115191. export enum NodeMaterialBlockConnectionPointTypes {
  115192. /** Float */
  115193. Float = 1,
  115194. /** Int */
  115195. Int = 2,
  115196. /** Vector2 */
  115197. Vector2 = 4,
  115198. /** Vector3 */
  115199. Vector3 = 8,
  115200. /** Vector4 */
  115201. Vector4 = 16,
  115202. /** Color3 */
  115203. Color3 = 32,
  115204. /** Color4 */
  115205. Color4 = 64,
  115206. /** Matrix */
  115207. Matrix = 128,
  115208. /** Detect type based on connection */
  115209. AutoDetect = 1024,
  115210. /** Output type that will be defined by input type */
  115211. BasedOnInput = 2048
  115212. }
  115213. }
  115214. declare module BABYLON {
  115215. /**
  115216. * Root class for all node material optimizers
  115217. */
  115218. export class NodeMaterialOptimizer {
  115219. /**
  115220. * Function used to optimize a NodeMaterial graph
  115221. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  115222. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  115223. */
  115224. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  115225. }
  115226. }
  115227. declare module BABYLON {
  115228. /**
  115229. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115230. */
  115231. export class TransformBlock extends NodeMaterialBlock {
  115232. /**
  115233. * Defines the value to use to complement W value to transform it to a Vector4
  115234. */
  115235. complementW: number;
  115236. /**
  115237. * Defines the value to use to complement z value to transform it to a Vector4
  115238. */
  115239. complementZ: number;
  115240. /**
  115241. * Creates a new TransformBlock
  115242. * @param name defines the block name
  115243. */
  115244. constructor(name: string);
  115245. /**
  115246. * Gets the current class name
  115247. * @returns the class name
  115248. */
  115249. getClassName(): string;
  115250. /**
  115251. * Gets the vector input
  115252. */
  115253. readonly vector: NodeMaterialConnectionPoint;
  115254. /**
  115255. * Gets the output component
  115256. */
  115257. readonly output: NodeMaterialConnectionPoint;
  115258. /**
  115259. * Gets the matrix transform input
  115260. */
  115261. readonly transform: NodeMaterialConnectionPoint;
  115262. protected _buildBlock(state: NodeMaterialBuildState): this;
  115263. serialize(): any;
  115264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115265. }
  115266. }
  115267. declare module BABYLON {
  115268. /**
  115269. * Block used to output the vertex position
  115270. */
  115271. export class VertexOutputBlock extends NodeMaterialBlock {
  115272. /**
  115273. * Creates a new VertexOutputBlock
  115274. * @param name defines the block name
  115275. */
  115276. constructor(name: string);
  115277. /**
  115278. * Gets the current class name
  115279. * @returns the class name
  115280. */
  115281. getClassName(): string;
  115282. /**
  115283. * Gets the vector input component
  115284. */
  115285. readonly vector: NodeMaterialConnectionPoint;
  115286. protected _buildBlock(state: NodeMaterialBuildState): this;
  115287. }
  115288. }
  115289. declare module BABYLON {
  115290. /**
  115291. * Block used to output the final color
  115292. */
  115293. export class FragmentOutputBlock extends NodeMaterialBlock {
  115294. /**
  115295. * Create a new FragmentOutputBlock
  115296. * @param name defines the block name
  115297. */
  115298. constructor(name: string);
  115299. /**
  115300. * Gets the current class name
  115301. * @returns the class name
  115302. */
  115303. getClassName(): string;
  115304. /**
  115305. * Gets the rgba input component
  115306. */
  115307. readonly rgba: NodeMaterialConnectionPoint;
  115308. /**
  115309. * Gets the rgb input component
  115310. */
  115311. readonly rgb: NodeMaterialConnectionPoint;
  115312. /**
  115313. * Gets the a input component
  115314. */
  115315. readonly a: NodeMaterialConnectionPoint;
  115316. protected _buildBlock(state: NodeMaterialBuildState): this;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * Interface used to configure the node material editor
  115322. */
  115323. export interface INodeMaterialEditorOptions {
  115324. /** Define the URl to load node editor script */
  115325. editorURL?: string;
  115326. }
  115327. /** @hidden */
  115328. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115329. /** BONES */
  115330. NUM_BONE_INFLUENCERS: number;
  115331. BonesPerMesh: number;
  115332. BONETEXTURE: boolean;
  115333. /** MORPH TARGETS */
  115334. MORPHTARGETS: boolean;
  115335. MORPHTARGETS_NORMAL: boolean;
  115336. MORPHTARGETS_TANGENT: boolean;
  115337. MORPHTARGETS_UV: boolean;
  115338. NUM_MORPH_INFLUENCERS: number;
  115339. /** IMAGE PROCESSING */
  115340. IMAGEPROCESSING: boolean;
  115341. VIGNETTE: boolean;
  115342. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115343. VIGNETTEBLENDMODEOPAQUE: boolean;
  115344. TONEMAPPING: boolean;
  115345. TONEMAPPING_ACES: boolean;
  115346. CONTRAST: boolean;
  115347. EXPOSURE: boolean;
  115348. COLORCURVES: boolean;
  115349. COLORGRADING: boolean;
  115350. COLORGRADING3D: boolean;
  115351. SAMPLER3DGREENDEPTH: boolean;
  115352. SAMPLER3DBGRMAP: boolean;
  115353. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115354. constructor();
  115355. setValue(name: string, value: boolean): void;
  115356. }
  115357. /**
  115358. * Class used to configure NodeMaterial
  115359. */
  115360. export interface INodeMaterialOptions {
  115361. /**
  115362. * Defines if blocks should emit comments
  115363. */
  115364. emitComments: boolean;
  115365. }
  115366. /**
  115367. * Class used to create a node based material built by assembling shader blocks
  115368. */
  115369. export class NodeMaterial extends PushMaterial {
  115370. private static _BuildIdGenerator;
  115371. private _options;
  115372. private _vertexCompilationState;
  115373. private _fragmentCompilationState;
  115374. private _sharedData;
  115375. private _buildId;
  115376. private _buildWasSuccessful;
  115377. private _cachedWorldViewMatrix;
  115378. private _cachedWorldViewProjectionMatrix;
  115379. private _optimizers;
  115380. /** Define the URl to load node editor script */
  115381. static EditorURL: string;
  115382. private BJSNODEMATERIALEDITOR;
  115383. /** Get the inspector from bundle or global */
  115384. private _getGlobalNodeMaterialEditor;
  115385. /**
  115386. * 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)
  115387. */
  115388. ignoreAlpha: boolean;
  115389. /**
  115390. * Defines the maximum number of lights that can be used in the material
  115391. */
  115392. maxSimultaneousLights: number;
  115393. /**
  115394. * Observable raised when the material is built
  115395. */
  115396. onBuildObservable: Observable<NodeMaterial>;
  115397. /**
  115398. * Gets or sets the root nodes of the material vertex shader
  115399. */
  115400. _vertexOutputNodes: NodeMaterialBlock[];
  115401. /**
  115402. * Gets or sets the root nodes of the material fragment (pixel) shader
  115403. */
  115404. _fragmentOutputNodes: NodeMaterialBlock[];
  115405. /** Gets or sets options to control the node material overall behavior */
  115406. options: INodeMaterialOptions;
  115407. /**
  115408. * Default configuration related to image processing available in the standard Material.
  115409. */
  115410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115411. /**
  115412. * Gets the image processing configuration used either in this material.
  115413. */
  115414. /**
  115415. * Sets the Default image processing configuration used either in the this material.
  115416. *
  115417. * If sets to null, the scene one is in use.
  115418. */
  115419. imageProcessingConfiguration: ImageProcessingConfiguration;
  115420. /**
  115421. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  115422. */
  115423. attachedBlocks: NodeMaterialBlock[];
  115424. /**
  115425. * Create a new node based material
  115426. * @param name defines the material name
  115427. * @param scene defines the hosting scene
  115428. * @param options defines creation option
  115429. */
  115430. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115431. /**
  115432. * Gets the current class name of the material e.g. "NodeMaterial"
  115433. * @returns the class name
  115434. */
  115435. getClassName(): string;
  115436. /**
  115437. * Keep track of the image processing observer to allow dispose and replace.
  115438. */
  115439. private _imageProcessingObserver;
  115440. /**
  115441. * Attaches a new image processing configuration to the Standard Material.
  115442. * @param configuration
  115443. */
  115444. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115445. /**
  115446. * Adds a new optimizer to the list of optimizers
  115447. * @param optimizer defines the optimizers to add
  115448. * @returns the current material
  115449. */
  115450. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115451. /**
  115452. * Remove an optimizer from the list of optimizers
  115453. * @param optimizer defines the optimizers to remove
  115454. * @returns the current material
  115455. */
  115456. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115457. /**
  115458. * Add a new block to the list of output nodes
  115459. * @param node defines the node to add
  115460. * @returns the current material
  115461. */
  115462. addOutputNode(node: NodeMaterialBlock): this;
  115463. /**
  115464. * Remove a block from the list of root nodes
  115465. * @param node defines the node to remove
  115466. * @returns the current material
  115467. */
  115468. removeOutputNode(node: NodeMaterialBlock): this;
  115469. private _addVertexOutputNode;
  115470. private _removeVertexOutputNode;
  115471. private _addFragmentOutputNode;
  115472. private _removeFragmentOutputNode;
  115473. /**
  115474. * Specifies if the material will require alpha blending
  115475. * @returns a boolean specifying if alpha blending is needed
  115476. */
  115477. needAlphaBlending(): boolean;
  115478. /**
  115479. * Specifies if this material should be rendered in alpha test mode
  115480. * @returns a boolean specifying if an alpha test is needed.
  115481. */
  115482. needAlphaTesting(): boolean;
  115483. private _initializeBlock;
  115484. private _resetDualBlocks;
  115485. /**
  115486. * Build the material and generates the inner effect
  115487. * @param verbose defines if the build should log activity
  115488. */
  115489. build(verbose?: boolean): void;
  115490. /**
  115491. * Runs an otpimization phase to try to improve the shader code
  115492. */
  115493. optimize(): void;
  115494. private _prepareDefinesForAttributes;
  115495. /**
  115496. * Get if the submesh is ready to be used and all its information available.
  115497. * Child classes can use it to update shaders
  115498. * @param mesh defines the mesh to check
  115499. * @param subMesh defines which submesh to check
  115500. * @param useInstances specifies that instances should be used
  115501. * @returns a boolean indicating that the submesh is ready or not
  115502. */
  115503. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115504. /**
  115505. * Get a string representing the shaders built by the current node graph
  115506. */
  115507. readonly compiledShaders: string;
  115508. /**
  115509. * Binds the world matrix to the material
  115510. * @param world defines the world transformation matrix
  115511. */
  115512. bindOnlyWorldMatrix(world: Matrix): void;
  115513. /**
  115514. * Binds the submesh to this material by preparing the effect and shader to draw
  115515. * @param world defines the world transformation matrix
  115516. * @param mesh defines the mesh containing the submesh
  115517. * @param subMesh defines the submesh to bind the material to
  115518. */
  115519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115520. /**
  115521. * Gets the active textures from the material
  115522. * @returns an array of textures
  115523. */
  115524. getActiveTextures(): BaseTexture[];
  115525. /**
  115526. * Specifies if the material uses a texture
  115527. * @param texture defines the texture to check against the material
  115528. * @returns a boolean specifying if the material uses the texture
  115529. */
  115530. hasTexture(texture: BaseTexture): boolean;
  115531. /**
  115532. * Disposes the material
  115533. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115534. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115535. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115536. */
  115537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115538. /** Creates the node editor window. */
  115539. private _createNodeEditor;
  115540. /**
  115541. * Launch the node material editor
  115542. * @param config Define the configuration of the editor
  115543. * @return a promise fulfilled when the node editor is visible
  115544. */
  115545. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  115546. /**
  115547. * Clear the current material
  115548. */
  115549. clear(): void;
  115550. /**
  115551. * Clear the current material and set it to a default state
  115552. */
  115553. setToDefault(): void;
  115554. private _gatherBlocks;
  115555. /**
  115556. * Serializes this material in a JSON representation
  115557. * @returns the serialized material object
  115558. */
  115559. serialize(): any;
  115560. /**
  115561. * Clear the current graph and load a new one from a serialization object
  115562. * @param source defines the JSON representation of the material
  115563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115564. */
  115565. loadFromSerialization(source: any, rootUrl?: string): void;
  115566. /**
  115567. * Creates a node material from parsed material data
  115568. * @param source defines the JSON representation of the material
  115569. * @param scene defines the hosting scene
  115570. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115571. * @returns a new node material
  115572. */
  115573. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  115574. }
  115575. }
  115576. declare module BABYLON {
  115577. /**
  115578. * Block used to read a texture from a sampler
  115579. */
  115580. export class TextureBlock extends NodeMaterialBlock {
  115581. private _defineName;
  115582. private _samplerName;
  115583. private _transformedUVName;
  115584. private _textureTransformName;
  115585. private _textureInfoName;
  115586. private _mainUVName;
  115587. private _mainUVDefineName;
  115588. /**
  115589. * Gets or sets the texture associated with the node
  115590. */
  115591. texture: Nullable<BaseTexture>;
  115592. /**
  115593. * Create a new TextureBlock
  115594. * @param name defines the block name
  115595. */
  115596. constructor(name: string);
  115597. /**
  115598. * Gets the current class name
  115599. * @returns the class name
  115600. */
  115601. getClassName(): string;
  115602. /**
  115603. * Gets the uv input component
  115604. */
  115605. readonly uv: NodeMaterialConnectionPoint;
  115606. /**
  115607. * Gets the output component
  115608. */
  115609. readonly output: NodeMaterialConnectionPoint;
  115610. autoConfigure(): void;
  115611. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115613. isReady(): boolean;
  115614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115615. private _injectVertexCode;
  115616. private _writeOutput;
  115617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115618. serialize(): any;
  115619. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115620. }
  115621. }
  115622. declare module BABYLON {
  115623. /**
  115624. * Class used to store shared data between 2 NodeMaterialBuildState
  115625. */
  115626. export class NodeMaterialBuildStateSharedData {
  115627. /**
  115628. * Gets the list of emitted varyings
  115629. */
  115630. varyings: string[];
  115631. /**
  115632. * Gets the varying declaration string
  115633. */
  115634. varyingDeclaration: string;
  115635. /**
  115636. * Input blocks
  115637. */
  115638. inputBlocks: InputBlock[];
  115639. /**
  115640. * Input blocks
  115641. */
  115642. textureBlocks: TextureBlock[];
  115643. /**
  115644. * Bindable blocks (Blocks that need to set data to the effect)
  115645. */
  115646. bindableBlocks: NodeMaterialBlock[];
  115647. /**
  115648. * List of blocks that can provide a compilation fallback
  115649. */
  115650. blocksWithFallbacks: NodeMaterialBlock[];
  115651. /**
  115652. * List of blocks that can provide a define update
  115653. */
  115654. blocksWithDefines: NodeMaterialBlock[];
  115655. /**
  115656. * List of blocks that can provide a repeatable content
  115657. */
  115658. repeatableContentBlocks: NodeMaterialBlock[];
  115659. /**
  115660. * List of blocks that can provide a dynamic list of uniforms
  115661. */
  115662. dynamicUniformBlocks: NodeMaterialBlock[];
  115663. /**
  115664. * List of blocks that can block the isReady function for the material
  115665. */
  115666. blockingBlocks: NodeMaterialBlock[];
  115667. /**
  115668. * Build Id used to avoid multiple recompilations
  115669. */
  115670. buildId: number;
  115671. /** List of emitted variables */
  115672. variableNames: {
  115673. [key: string]: number;
  115674. };
  115675. /** List of emitted defines */
  115676. defineNames: {
  115677. [key: string]: number;
  115678. };
  115679. /** Should emit comments? */
  115680. emitComments: boolean;
  115681. /** Emit build activity */
  115682. verbose: boolean;
  115683. /**
  115684. * Gets the compilation hints emitted at compilation time
  115685. */
  115686. hints: {
  115687. needWorldViewMatrix: boolean;
  115688. needWorldViewProjectionMatrix: boolean;
  115689. needAlphaBlending: boolean;
  115690. needAlphaTesting: boolean;
  115691. };
  115692. /**
  115693. * List of compilation checks
  115694. */
  115695. checks: {
  115696. emitVertex: boolean;
  115697. emitFragment: boolean;
  115698. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  115699. };
  115700. /** Creates a new shared data */
  115701. constructor();
  115702. /**
  115703. * Emits console errors and exceptions if there is a failing check
  115704. */
  115705. emitErrors(): void;
  115706. }
  115707. }
  115708. declare module BABYLON {
  115709. /**
  115710. * Class used to store node based material build state
  115711. */
  115712. export class NodeMaterialBuildState {
  115713. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  115714. supportUniformBuffers: boolean;
  115715. /**
  115716. * Gets the list of emitted attributes
  115717. */
  115718. attributes: string[];
  115719. /**
  115720. * Gets the list of emitted uniforms
  115721. */
  115722. uniforms: string[];
  115723. /**
  115724. * Gets the list of emitted uniform buffers
  115725. */
  115726. uniformBuffers: string[];
  115727. /**
  115728. * Gets the list of emitted samplers
  115729. */
  115730. samplers: string[];
  115731. /**
  115732. * Gets the list of emitted functions
  115733. */
  115734. functions: {
  115735. [key: string]: string;
  115736. };
  115737. /**
  115738. * Gets the target of the compilation state
  115739. */
  115740. target: NodeMaterialBlockTargets;
  115741. /**
  115742. * Gets the list of emitted counters
  115743. */
  115744. counters: {
  115745. [key: string]: number;
  115746. };
  115747. /**
  115748. * Shared data between multiple NodeMaterialBuildState instances
  115749. */
  115750. sharedData: NodeMaterialBuildStateSharedData;
  115751. /** @hidden */
  115752. _vertexState: NodeMaterialBuildState;
  115753. /** @hidden */
  115754. _attributeDeclaration: string;
  115755. /** @hidden */
  115756. _uniformDeclaration: string;
  115757. /** @hidden */
  115758. _samplerDeclaration: string;
  115759. /** @hidden */
  115760. _varyingTransfer: string;
  115761. private _repeatableContentAnchorIndex;
  115762. /** @hidden */
  115763. _builtCompilationString: string;
  115764. /**
  115765. * Gets the emitted compilation strings
  115766. */
  115767. compilationString: string;
  115768. /**
  115769. * Finalize the compilation strings
  115770. * @param state defines the current compilation state
  115771. */
  115772. finalize(state: NodeMaterialBuildState): void;
  115773. /** @hidden */
  115774. readonly _repeatableContentAnchor: string;
  115775. /** @hidden */
  115776. _getFreeVariableName(prefix: string): string;
  115777. /** @hidden */
  115778. _getFreeDefineName(prefix: string): string;
  115779. /** @hidden */
  115780. _excludeVariableName(name: string): void;
  115781. /** @hidden */
  115782. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  115783. /** @hidden */
  115784. _emitFunction(name: string, code: string, comments: string): void;
  115785. /** @hidden */
  115786. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  115787. replaceStrings?: {
  115788. search: RegExp;
  115789. replace: string;
  115790. }[];
  115791. repeatKey?: string;
  115792. }): string;
  115793. /** @hidden */
  115794. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  115795. repeatKey?: string;
  115796. removeAttributes?: boolean;
  115797. removeUniforms?: boolean;
  115798. removeVaryings?: boolean;
  115799. removeIfDef?: boolean;
  115800. replaceStrings?: {
  115801. search: RegExp;
  115802. replace: string;
  115803. }[];
  115804. }, storeKey?: string): void;
  115805. /** @hidden */
  115806. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115807. /** @hidden */
  115808. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115809. }
  115810. }
  115811. declare module BABYLON {
  115812. /**
  115813. * Defines a block that can be used inside a node based material
  115814. */
  115815. export class NodeMaterialBlock {
  115816. private _buildId;
  115817. private _buildTarget;
  115818. private _target;
  115819. private _isFinalMerger;
  115820. private _isInput;
  115821. /** @hidden */
  115822. _inputs: NodeMaterialConnectionPoint[];
  115823. /** @hidden */
  115824. _outputs: NodeMaterialConnectionPoint[];
  115825. /**
  115826. * Gets or sets the name of the block
  115827. */
  115828. name: string;
  115829. /**
  115830. * Gets or sets the unique id of the node
  115831. */
  115832. uniqueId: number;
  115833. /**
  115834. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  115835. */
  115836. readonly isFinalMerger: boolean;
  115837. /**
  115838. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  115839. */
  115840. readonly isInput: boolean;
  115841. /**
  115842. * Gets or sets the build Id
  115843. */
  115844. buildId: number;
  115845. /**
  115846. * Gets or sets the target of the block
  115847. */
  115848. target: NodeMaterialBlockTargets;
  115849. /**
  115850. * Gets the list of input points
  115851. */
  115852. readonly inputs: NodeMaterialConnectionPoint[];
  115853. /** Gets the list of output points */
  115854. readonly outputs: NodeMaterialConnectionPoint[];
  115855. /**
  115856. * Find an input by its name
  115857. * @param name defines the name of the input to look for
  115858. * @returns the input or null if not found
  115859. */
  115860. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115861. /**
  115862. * Find an output by its name
  115863. * @param name defines the name of the outputto look for
  115864. * @returns the output or null if not found
  115865. */
  115866. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115867. /**
  115868. * Creates a new NodeMaterialBlock
  115869. * @param name defines the block name
  115870. * @param target defines the target of that block (Vertex by default)
  115871. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  115872. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  115873. */
  115874. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  115875. /**
  115876. * Initialize the block and prepare the context for build
  115877. * @param state defines the state that will be used for the build
  115878. */
  115879. initialize(state: NodeMaterialBuildState): void;
  115880. /**
  115881. * Bind data to effect. Will only be called for blocks with isBindable === true
  115882. * @param effect defines the effect to bind data to
  115883. * @param nodeMaterial defines the hosting NodeMaterial
  115884. * @param mesh defines the mesh that will be rendered
  115885. */
  115886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115887. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  115888. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  115889. protected _writeFloat(value: number): string;
  115890. /**
  115891. * Gets the current class name e.g. "NodeMaterialBlock"
  115892. * @returns the class name
  115893. */
  115894. getClassName(): string;
  115895. /**
  115896. * Register a new input. Must be called inside a block constructor
  115897. * @param name defines the connection point name
  115898. * @param type defines the connection point type
  115899. * @param isOptional defines a boolean indicating that this input can be omitted
  115900. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115901. * @returns the current block
  115902. */
  115903. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  115904. /**
  115905. * Register a new output. Must be called inside a block constructor
  115906. * @param name defines the connection point name
  115907. * @param type defines the connection point type
  115908. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115909. * @returns the current block
  115910. */
  115911. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  115912. /**
  115913. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  115914. * @param forOutput defines an optional connection point to check compatibility with
  115915. * @returns the first available input or null
  115916. */
  115917. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  115918. /**
  115919. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  115920. * @param forBlock defines an optional block to check compatibility with
  115921. * @returns the first available input or null
  115922. */
  115923. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  115924. /**
  115925. * Connect current block with another block
  115926. * @param other defines the block to connect with
  115927. * @param options define the various options to help pick the right connections
  115928. * @returns the current block
  115929. */
  115930. connectTo(other: NodeMaterialBlock, options?: {
  115931. input?: string;
  115932. output?: string;
  115933. outputSwizzle?: string;
  115934. }): this | undefined;
  115935. protected _buildBlock(state: NodeMaterialBuildState): void;
  115936. /**
  115937. * Add uniforms, samplers and uniform buffers at compilation time
  115938. * @param state defines the state to update
  115939. * @param nodeMaterial defines the node material requesting the update
  115940. * @param defines defines the material defines to update
  115941. */
  115942. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115943. /**
  115944. * Add potential fallbacks if shader compilation fails
  115945. * @param mesh defines the mesh to be rendered
  115946. * @param fallbacks defines the current prioritized list of fallbacks
  115947. */
  115948. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115949. /**
  115950. * Update defines for shader compilation
  115951. * @param mesh defines the mesh to be rendered
  115952. * @param nodeMaterial defines the node material requesting the update
  115953. * @param defines defines the material defines to update
  115954. * @param useInstances specifies that instances should be used
  115955. */
  115956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115957. /**
  115958. * Initialize defines for shader compilation
  115959. * @param mesh defines the mesh to be rendered
  115960. * @param nodeMaterial defines the node material requesting the update
  115961. * @param defines defines the material defines to be prepared
  115962. * @param useInstances specifies that instances should be used
  115963. */
  115964. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115965. /**
  115966. * Lets the block try to connect some inputs automatically
  115967. */
  115968. autoConfigure(): void;
  115969. /**
  115970. * Function called when a block is declared as repeatable content generator
  115971. * @param vertexShaderState defines the current compilation state for the vertex shader
  115972. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115973. * @param mesh defines the mesh to be rendered
  115974. * @param defines defines the material defines to update
  115975. */
  115976. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115977. /**
  115978. * Checks if the block is ready
  115979. * @param mesh defines the mesh to be rendered
  115980. * @param nodeMaterial defines the node material requesting the update
  115981. * @param defines defines the material defines to update
  115982. * @param useInstances specifies that instances should be used
  115983. * @returns true if the block is ready
  115984. */
  115985. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115986. private _processBuild;
  115987. /**
  115988. * Compile the current node and generate the shader code
  115989. * @param state defines the current compilation state (uniforms, samplers, current string)
  115990. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115991. * @returns true if already built
  115992. */
  115993. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115994. /**
  115995. * Serializes this block in a JSON representation
  115996. * @returns the serialized block object
  115997. */
  115998. serialize(): any;
  115999. /** @hidden */
  116000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116001. }
  116002. }
  116003. declare module BABYLON {
  116004. /**
  116005. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  116006. */
  116007. export enum NodeMaterialBlockConnectionPointMode {
  116008. /** Value is an uniform */
  116009. Uniform = 0,
  116010. /** Value is a mesh attribute */
  116011. Attribute = 1,
  116012. /** Value is a varying between vertex and fragment shaders */
  116013. Varying = 2,
  116014. /** Mode is undefined */
  116015. Undefined = 3
  116016. }
  116017. }
  116018. declare module BABYLON {
  116019. /**
  116020. * Enum used to define well known values e.g. values automatically provided by the system
  116021. */
  116022. export enum NodeMaterialWellKnownValues {
  116023. /** World */
  116024. World = 1,
  116025. /** View */
  116026. View = 2,
  116027. /** Projection */
  116028. Projection = 3,
  116029. /** ViewProjection */
  116030. ViewProjection = 4,
  116031. /** WorldView */
  116032. WorldView = 5,
  116033. /** WorldViewProjection */
  116034. WorldViewProjection = 6,
  116035. /** CameraPosition */
  116036. CameraPosition = 7,
  116037. /** Fog Color */
  116038. FogColor = 8
  116039. }
  116040. }
  116041. declare module BABYLON {
  116042. /**
  116043. * Contains position and normal vectors for a vertex
  116044. */
  116045. export class PositionNormalVertex {
  116046. /** the position of the vertex (defaut: 0,0,0) */
  116047. position: Vector3;
  116048. /** the normal of the vertex (defaut: 0,1,0) */
  116049. normal: Vector3;
  116050. /**
  116051. * Creates a PositionNormalVertex
  116052. * @param position the position of the vertex (defaut: 0,0,0)
  116053. * @param normal the normal of the vertex (defaut: 0,1,0)
  116054. */
  116055. constructor(
  116056. /** the position of the vertex (defaut: 0,0,0) */
  116057. position?: Vector3,
  116058. /** the normal of the vertex (defaut: 0,1,0) */
  116059. normal?: Vector3);
  116060. /**
  116061. * Clones the PositionNormalVertex
  116062. * @returns the cloned PositionNormalVertex
  116063. */
  116064. clone(): PositionNormalVertex;
  116065. }
  116066. /**
  116067. * Contains position, normal and uv vectors for a vertex
  116068. */
  116069. export class PositionNormalTextureVertex {
  116070. /** the position of the vertex (defaut: 0,0,0) */
  116071. position: Vector3;
  116072. /** the normal of the vertex (defaut: 0,1,0) */
  116073. normal: Vector3;
  116074. /** the uv of the vertex (default: 0,0) */
  116075. uv: Vector2;
  116076. /**
  116077. * Creates a PositionNormalTextureVertex
  116078. * @param position the position of the vertex (defaut: 0,0,0)
  116079. * @param normal the normal of the vertex (defaut: 0,1,0)
  116080. * @param uv the uv of the vertex (default: 0,0)
  116081. */
  116082. constructor(
  116083. /** the position of the vertex (defaut: 0,0,0) */
  116084. position?: Vector3,
  116085. /** the normal of the vertex (defaut: 0,1,0) */
  116086. normal?: Vector3,
  116087. /** the uv of the vertex (default: 0,0) */
  116088. uv?: Vector2);
  116089. /**
  116090. * Clones the PositionNormalTextureVertex
  116091. * @returns the cloned PositionNormalTextureVertex
  116092. */
  116093. clone(): PositionNormalTextureVertex;
  116094. }
  116095. }
  116096. declare module BABYLON {
  116097. /**
  116098. * Block used to expose an input value
  116099. */
  116100. export class InputBlock extends NodeMaterialBlock {
  116101. private _mode;
  116102. private _associatedVariableName;
  116103. private _storedValue;
  116104. private _valueCallback;
  116105. private _type;
  116106. /** @hidden */
  116107. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116108. /**
  116109. * Gets or sets the connection point type (default is float)
  116110. */
  116111. readonly type: NodeMaterialBlockConnectionPointTypes;
  116112. /**
  116113. * Creates a new InputBlock
  116114. * @param name defines the block name
  116115. * @param target defines the target of that block (Vertex by default)
  116116. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  116117. */
  116118. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  116119. /**
  116120. * Gets the output component
  116121. */
  116122. readonly output: NodeMaterialConnectionPoint;
  116123. /**
  116124. * Set the source of this connection point to a vertex attribute
  116125. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  116126. * @returns the current connection point
  116127. */
  116128. setAsAttribute(attributeName?: string): InputBlock;
  116129. /**
  116130. * Set the source of this connection point to a well known value
  116131. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  116132. * @returns the current connection point
  116133. */
  116134. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  116135. /**
  116136. * Gets or sets the value of that point.
  116137. * Please note that this value will be ignored if valueCallback is defined
  116138. */
  116139. value: any;
  116140. /**
  116141. * Gets or sets a callback used to get the value of that point.
  116142. * Please note that setting this value will force the connection point to ignore the value property
  116143. */
  116144. valueCallback: () => any;
  116145. /**
  116146. * Gets or sets the associated variable name in the shader
  116147. */
  116148. associatedVariableName: string;
  116149. /**
  116150. * Gets a boolean indicating that this connection point not defined yet
  116151. */
  116152. readonly isUndefined: boolean;
  116153. /**
  116154. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  116155. * In this case the connection point name must be the name of the uniform to use.
  116156. * Can only be set on inputs
  116157. */
  116158. isUniform: boolean;
  116159. /**
  116160. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  116161. * In this case the connection point name must be the name of the attribute to use
  116162. * Can only be set on inputs
  116163. */
  116164. isAttribute: boolean;
  116165. /**
  116166. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  116167. * Can only be set on exit points
  116168. */
  116169. isVarying: boolean;
  116170. /**
  116171. * Gets a boolean indicating that the current connection point is a well known value
  116172. */
  116173. readonly isWellKnownValue: boolean;
  116174. /**
  116175. * Gets or sets the current well known value or null if not defined as well know value
  116176. */
  116177. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116178. /**
  116179. * Gets the current class name
  116180. * @returns the class name
  116181. */
  116182. getClassName(): string;
  116183. private _emitDefine;
  116184. /**
  116185. * Set the input block to its default value (based on its type)
  116186. */
  116187. setDefaultValue(): void;
  116188. private _emit;
  116189. /** @hidden */
  116190. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  116191. /** @hidden */
  116192. _transmit(effect: Effect, scene: Scene): void;
  116193. protected _buildBlock(state: NodeMaterialBuildState): void;
  116194. serialize(): any;
  116195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116196. }
  116197. }
  116198. declare module BABYLON {
  116199. /**
  116200. * Defines a connection point for a block
  116201. */
  116202. export class NodeMaterialConnectionPoint {
  116203. /** @hidden */
  116204. _ownerBlock: NodeMaterialBlock;
  116205. /** @hidden */
  116206. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116207. private _endpoints;
  116208. private _associatedVariableName;
  116209. /** @hidden */
  116210. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  116211. private _type;
  116212. /** @hidden */
  116213. _enforceAssociatedVariableName: boolean;
  116214. /**
  116215. * Gets or sets the additional types supported byt this connection point
  116216. */
  116217. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  116218. /**
  116219. * Gets or sets the associated variable name in the shader
  116220. */
  116221. associatedVariableName: string;
  116222. /**
  116223. * Gets or sets the connection point type (default is float)
  116224. */
  116225. type: NodeMaterialBlockConnectionPointTypes;
  116226. /**
  116227. * Gets or sets the connection point name
  116228. */
  116229. name: string;
  116230. /**
  116231. * Gets or sets a boolean indicating that this connection point can be omitted
  116232. */
  116233. isOptional: boolean;
  116234. /**
  116235. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  116236. */
  116237. define: string;
  116238. /** Gets or sets the target of that connection point */
  116239. target: NodeMaterialBlockTargets;
  116240. /**
  116241. * Gets a boolean indicating that the current point is connected
  116242. */
  116243. readonly isConnected: boolean;
  116244. /**
  116245. * Gets a boolean indicating that the current point is connected to an input block
  116246. */
  116247. readonly isConnectedToInput: boolean;
  116248. /**
  116249. * Gets a the connected input block (if any)
  116250. */
  116251. readonly connectInputBlock: Nullable<InputBlock>;
  116252. /** Get the other side of the connection (if any) */
  116253. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116254. /** Get the block that owns this connection point */
  116255. readonly ownerBlock: NodeMaterialBlock;
  116256. /** Get the block connected on the other side of this connection (if any) */
  116257. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  116258. /** Get the block connected on the endpoints of this connection (if any) */
  116259. readonly connectedBlocks: Array<NodeMaterialBlock>;
  116260. /** Gets the list of connected endpoints */
  116261. readonly endpoints: NodeMaterialConnectionPoint[];
  116262. /**
  116263. * Creates a new connection point
  116264. * @param name defines the connection point name
  116265. * @param ownerBlock defines the block hosting this connection point
  116266. */
  116267. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116268. /**
  116269. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116270. * @returns the class name
  116271. */
  116272. getClassName(): string;
  116273. /**
  116274. * Gets an boolean indicating if the current point can be connected to another point
  116275. * @param connectionPoint defines the other connection point
  116276. * @returns true if the connection is possible
  116277. */
  116278. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116279. /**
  116280. * Connect this point to another connection point
  116281. * @param connectionPoint defines the other connection point
  116282. * @returns the current connection point
  116283. */
  116284. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116285. /**
  116286. * Disconnect this point from one of his endpoint
  116287. * @param endpoint defines the other connection point
  116288. * @returns the current connection point
  116289. */
  116290. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116291. /**
  116292. * Serializes this point in a JSON representation
  116293. * @returns the serialized point object
  116294. */
  116295. serialize(): any;
  116296. }
  116297. }
  116298. declare module BABYLON {
  116299. /**
  116300. * Block used to add support for vertex skinning (bones)
  116301. */
  116302. export class BonesBlock extends NodeMaterialBlock {
  116303. /**
  116304. * Creates a new BonesBlock
  116305. * @param name defines the block name
  116306. */
  116307. constructor(name: string);
  116308. /**
  116309. * Initialize the block and prepare the context for build
  116310. * @param state defines the state that will be used for the build
  116311. */
  116312. initialize(state: NodeMaterialBuildState): void;
  116313. /**
  116314. * Gets the current class name
  116315. * @returns the class name
  116316. */
  116317. getClassName(): string;
  116318. /**
  116319. * Gets the matrix indices input component
  116320. */
  116321. readonly matricesIndices: NodeMaterialConnectionPoint;
  116322. /**
  116323. * Gets the matrix weights input component
  116324. */
  116325. readonly matricesWeights: NodeMaterialConnectionPoint;
  116326. /**
  116327. * Gets the extra matrix indices input component
  116328. */
  116329. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116330. /**
  116331. * Gets the extra matrix weights input component
  116332. */
  116333. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116334. /**
  116335. * Gets the world input component
  116336. */
  116337. readonly world: NodeMaterialConnectionPoint;
  116338. /**
  116339. * Gets the output component
  116340. */
  116341. readonly output: NodeMaterialConnectionPoint;
  116342. autoConfigure(): void;
  116343. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116346. protected _buildBlock(state: NodeMaterialBuildState): this;
  116347. }
  116348. }
  116349. declare module BABYLON {
  116350. /**
  116351. * Block used to add support for instances
  116352. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116353. */
  116354. export class InstancesBlock extends NodeMaterialBlock {
  116355. /**
  116356. * Creates a new InstancesBlock
  116357. * @param name defines the block name
  116358. */
  116359. constructor(name: string);
  116360. /**
  116361. * Gets the current class name
  116362. * @returns the class name
  116363. */
  116364. getClassName(): string;
  116365. /**
  116366. * Gets the first world row input component
  116367. */
  116368. readonly world0: NodeMaterialConnectionPoint;
  116369. /**
  116370. * Gets the second world row input component
  116371. */
  116372. readonly world1: NodeMaterialConnectionPoint;
  116373. /**
  116374. * Gets the third world row input component
  116375. */
  116376. readonly world2: NodeMaterialConnectionPoint;
  116377. /**
  116378. * Gets the forth world row input component
  116379. */
  116380. readonly world3: NodeMaterialConnectionPoint;
  116381. /**
  116382. * Gets the world input component
  116383. */
  116384. readonly world: NodeMaterialConnectionPoint;
  116385. /**
  116386. * Gets the output component
  116387. */
  116388. readonly output: NodeMaterialConnectionPoint;
  116389. autoConfigure(): void;
  116390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116391. protected _buildBlock(state: NodeMaterialBuildState): this;
  116392. }
  116393. }
  116394. declare module BABYLON {
  116395. /**
  116396. * Block used to add morph targets support to vertex shader
  116397. */
  116398. export class MorphTargetsBlock extends NodeMaterialBlock {
  116399. private _repeatableContentAnchor;
  116400. private _repeatebleContentGenerated;
  116401. /**
  116402. * Create a new MorphTargetsBlock
  116403. * @param name defines the block name
  116404. */
  116405. constructor(name: string);
  116406. /**
  116407. * Gets the current class name
  116408. * @returns the class name
  116409. */
  116410. getClassName(): string;
  116411. /**
  116412. * Gets the position input component
  116413. */
  116414. readonly position: NodeMaterialConnectionPoint;
  116415. /**
  116416. * Gets the normal input component
  116417. */
  116418. readonly normal: NodeMaterialConnectionPoint;
  116419. /**
  116420. * Gets the tangent input component
  116421. */
  116422. readonly tangent: NodeMaterialConnectionPoint;
  116423. /**
  116424. * Gets the tangent input component
  116425. */
  116426. readonly uv: NodeMaterialConnectionPoint;
  116427. /**
  116428. * Gets the position output component
  116429. */
  116430. readonly positionOutput: NodeMaterialConnectionPoint;
  116431. /**
  116432. * Gets the normal output component
  116433. */
  116434. readonly normalOutput: NodeMaterialConnectionPoint;
  116435. /**
  116436. * Gets the tangent output component
  116437. */
  116438. readonly tangentOutput: NodeMaterialConnectionPoint;
  116439. /**
  116440. * Gets the tangent output component
  116441. */
  116442. readonly uvOutput: NodeMaterialConnectionPoint;
  116443. initialize(state: NodeMaterialBuildState): void;
  116444. autoConfigure(): void;
  116445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116447. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116448. protected _buildBlock(state: NodeMaterialBuildState): this;
  116449. }
  116450. }
  116451. declare module BABYLON {
  116452. /**
  116453. * Block used to add an alpha test in the fragment shader
  116454. */
  116455. export class AlphaTestBlock extends NodeMaterialBlock {
  116456. /**
  116457. * Gets or sets the alpha value where alpha testing happens
  116458. */
  116459. alphaCutOff: number;
  116460. /**
  116461. * Create a new AlphaTestBlock
  116462. * @param name defines the block name
  116463. */
  116464. constructor(name: string);
  116465. /**
  116466. * Gets the current class name
  116467. * @returns the class name
  116468. */
  116469. getClassName(): string;
  116470. /**
  116471. * Gets the color input component
  116472. */
  116473. readonly color: NodeMaterialConnectionPoint;
  116474. /**
  116475. * Gets the alpha input component
  116476. */
  116477. readonly alpha: NodeMaterialConnectionPoint;
  116478. protected _buildBlock(state: NodeMaterialBuildState): this;
  116479. }
  116480. }
  116481. declare module BABYLON {
  116482. /**
  116483. * Block used to create a Color3/4 out of individual inputs (one for each component)
  116484. */
  116485. export class ColorMergerBlock extends NodeMaterialBlock {
  116486. /**
  116487. * Create a new ColorMergerBlock
  116488. * @param name defines the block name
  116489. */
  116490. constructor(name: string);
  116491. /**
  116492. * Gets the current class name
  116493. * @returns the class name
  116494. */
  116495. getClassName(): string;
  116496. /**
  116497. * Gets the r component (input)
  116498. */
  116499. readonly r: NodeMaterialConnectionPoint;
  116500. /**
  116501. * Gets the g component (input)
  116502. */
  116503. readonly g: NodeMaterialConnectionPoint;
  116504. /**
  116505. * Gets the b component (input)
  116506. */
  116507. readonly b: NodeMaterialConnectionPoint;
  116508. /**
  116509. * Gets the a component (input)
  116510. */
  116511. readonly a: NodeMaterialConnectionPoint;
  116512. /**
  116513. * Gets the rgba component (output)
  116514. */
  116515. readonly rgba: NodeMaterialConnectionPoint;
  116516. /**
  116517. * Gets the rgb component (output)
  116518. */
  116519. readonly rgb: NodeMaterialConnectionPoint;
  116520. protected _buildBlock(state: NodeMaterialBuildState): this;
  116521. }
  116522. }
  116523. declare module BABYLON {
  116524. /**
  116525. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  116526. */
  116527. export class VectorMergerBlock extends NodeMaterialBlock {
  116528. /**
  116529. * Create a new VectorMergerBlock
  116530. * @param name defines the block name
  116531. */
  116532. constructor(name: string);
  116533. /**
  116534. * Gets the current class name
  116535. * @returns the class name
  116536. */
  116537. getClassName(): string;
  116538. /**
  116539. * Gets the x component (input)
  116540. */
  116541. readonly x: NodeMaterialConnectionPoint;
  116542. /**
  116543. * Gets the y component (input)
  116544. */
  116545. readonly y: NodeMaterialConnectionPoint;
  116546. /**
  116547. * Gets the z component (input)
  116548. */
  116549. readonly z: NodeMaterialConnectionPoint;
  116550. /**
  116551. * Gets the w component (input)
  116552. */
  116553. readonly w: NodeMaterialConnectionPoint;
  116554. /**
  116555. * Gets the xyzw component (output)
  116556. */
  116557. readonly xyzw: NodeMaterialConnectionPoint;
  116558. /**
  116559. * Gets the xyz component (output)
  116560. */
  116561. readonly xyz: NodeMaterialConnectionPoint;
  116562. /**
  116563. * Gets the xy component (output)
  116564. */
  116565. readonly xy: NodeMaterialConnectionPoint;
  116566. protected _buildBlock(state: NodeMaterialBuildState): this;
  116567. }
  116568. }
  116569. declare module BABYLON {
  116570. /**
  116571. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  116572. */
  116573. export class ColorSplitterBlock extends NodeMaterialBlock {
  116574. /**
  116575. * Create a new ColorSplitterBlock
  116576. * @param name defines the block name
  116577. */
  116578. constructor(name: string);
  116579. /**
  116580. * Gets the current class name
  116581. * @returns the class name
  116582. */
  116583. getClassName(): string;
  116584. /**
  116585. * Gets the rgba component (input)
  116586. */
  116587. readonly rgba: NodeMaterialConnectionPoint;
  116588. /**
  116589. * Gets the rgb component (input)
  116590. */
  116591. readonly rgbIn: NodeMaterialConnectionPoint;
  116592. /**
  116593. * Gets the rgb component (output)
  116594. */
  116595. readonly rgbOut: NodeMaterialConnectionPoint;
  116596. /**
  116597. * Gets the r component (output)
  116598. */
  116599. readonly r: NodeMaterialConnectionPoint;
  116600. /**
  116601. * Gets the g component (output)
  116602. */
  116603. readonly g: NodeMaterialConnectionPoint;
  116604. /**
  116605. * Gets the b component (output)
  116606. */
  116607. readonly b: NodeMaterialConnectionPoint;
  116608. /**
  116609. * Gets the a component (output)
  116610. */
  116611. readonly a: NodeMaterialConnectionPoint;
  116612. protected _buildBlock(state: NodeMaterialBuildState): this;
  116613. }
  116614. }
  116615. declare module BABYLON {
  116616. /**
  116617. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  116618. */
  116619. export class VectorSplitterBlock extends NodeMaterialBlock {
  116620. /**
  116621. * Create a new VectorSplitterBlock
  116622. * @param name defines the block name
  116623. */
  116624. constructor(name: string);
  116625. /**
  116626. * Gets the current class name
  116627. * @returns the class name
  116628. */
  116629. getClassName(): string;
  116630. /**
  116631. * Gets the xyzw component (input)
  116632. */
  116633. readonly xyzw: NodeMaterialConnectionPoint;
  116634. /**
  116635. * Gets the xyz component (input)
  116636. */
  116637. readonly xyzIn: NodeMaterialConnectionPoint;
  116638. /**
  116639. * Gets the xyz component (output)
  116640. */
  116641. readonly xyzOut: NodeMaterialConnectionPoint;
  116642. /**
  116643. * Gets the xy component (output)
  116644. */
  116645. readonly xy: NodeMaterialConnectionPoint;
  116646. /**
  116647. * Gets the x component (output)
  116648. */
  116649. readonly x: NodeMaterialConnectionPoint;
  116650. /**
  116651. * Gets the y component (output)
  116652. */
  116653. readonly y: NodeMaterialConnectionPoint;
  116654. /**
  116655. * Gets the z component (output)
  116656. */
  116657. readonly z: NodeMaterialConnectionPoint;
  116658. /**
  116659. * Gets the w component (output)
  116660. */
  116661. readonly w: NodeMaterialConnectionPoint;
  116662. protected _buildBlock(state: NodeMaterialBuildState): this;
  116663. }
  116664. }
  116665. declare module BABYLON {
  116666. /**
  116667. * Block used to add image processing support to fragment shader
  116668. */
  116669. export class ImageProcessingBlock extends NodeMaterialBlock {
  116670. /**
  116671. * Create a new ImageProcessingBlock
  116672. * @param name defines the block name
  116673. */
  116674. constructor(name: string);
  116675. /**
  116676. * Gets the current class name
  116677. * @returns the class name
  116678. */
  116679. getClassName(): string;
  116680. /**
  116681. * Gets the color input component
  116682. */
  116683. readonly color: NodeMaterialConnectionPoint;
  116684. /**
  116685. * Gets the output component
  116686. */
  116687. readonly output: NodeMaterialConnectionPoint;
  116688. /**
  116689. * Initialize the block and prepare the context for build
  116690. * @param state defines the state that will be used for the build
  116691. */
  116692. initialize(state: NodeMaterialBuildState): void;
  116693. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  116694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116696. protected _buildBlock(state: NodeMaterialBuildState): this;
  116697. }
  116698. }
  116699. declare module BABYLON {
  116700. /**
  116701. * Block used to add support for scene fog
  116702. */
  116703. export class FogBlock extends NodeMaterialBlock {
  116704. private _fogDistanceName;
  116705. private _fogParameters;
  116706. /**
  116707. * Create a new FogBlock
  116708. * @param name defines the block name
  116709. */
  116710. constructor(name: string);
  116711. /**
  116712. * Gets the current class name
  116713. * @returns the class name
  116714. */
  116715. getClassName(): string;
  116716. /**
  116717. * Gets the world position input component
  116718. */
  116719. readonly worldPosition: NodeMaterialConnectionPoint;
  116720. /**
  116721. * Gets the view input component
  116722. */
  116723. readonly view: NodeMaterialConnectionPoint;
  116724. /**
  116725. * Gets the color input component
  116726. */
  116727. readonly color: NodeMaterialConnectionPoint;
  116728. /**
  116729. * Gets the fog color input component
  116730. */
  116731. readonly fogColor: NodeMaterialConnectionPoint;
  116732. /**
  116733. * Gets the output component
  116734. */
  116735. readonly output: NodeMaterialConnectionPoint;
  116736. autoConfigure(): void;
  116737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116739. protected _buildBlock(state: NodeMaterialBuildState): this;
  116740. }
  116741. }
  116742. declare module BABYLON {
  116743. /**
  116744. * Block used to add light in the fragment shader
  116745. */
  116746. export class LightBlock extends NodeMaterialBlock {
  116747. private _lightId;
  116748. /**
  116749. * Gets or sets the light associated with this block
  116750. */
  116751. light: Nullable<Light>;
  116752. /**
  116753. * Create a new LightBlock
  116754. * @param name defines the block name
  116755. */
  116756. constructor(name: string);
  116757. /**
  116758. * Gets the current class name
  116759. * @returns the class name
  116760. */
  116761. getClassName(): string;
  116762. /**
  116763. * Gets the world position input component
  116764. */
  116765. readonly worldPosition: NodeMaterialConnectionPoint;
  116766. /**
  116767. * Gets the world normal input component
  116768. */
  116769. readonly worldNormal: NodeMaterialConnectionPoint;
  116770. /**
  116771. * Gets the camera (or eye) position component
  116772. */
  116773. readonly cameraPosition: NodeMaterialConnectionPoint;
  116774. /**
  116775. * Gets the diffuse output component
  116776. */
  116777. readonly diffuseOutput: NodeMaterialConnectionPoint;
  116778. /**
  116779. * Gets the specular output component
  116780. */
  116781. readonly specularOutput: NodeMaterialConnectionPoint;
  116782. autoConfigure(): void;
  116783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116784. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116786. private _injectVertexCode;
  116787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116788. serialize(): any;
  116789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116790. }
  116791. }
  116792. declare module BABYLON {
  116793. /**
  116794. * Block used to multiply 2 values
  116795. */
  116796. export class MultiplyBlock extends NodeMaterialBlock {
  116797. /**
  116798. * Creates a new MultiplyBlock
  116799. * @param name defines the block name
  116800. */
  116801. constructor(name: string);
  116802. /**
  116803. * Gets the current class name
  116804. * @returns the class name
  116805. */
  116806. getClassName(): string;
  116807. /**
  116808. * Gets the left operand input component
  116809. */
  116810. readonly left: NodeMaterialConnectionPoint;
  116811. /**
  116812. * Gets the right operand input component
  116813. */
  116814. readonly right: NodeMaterialConnectionPoint;
  116815. /**
  116816. * Gets the output component
  116817. */
  116818. readonly output: NodeMaterialConnectionPoint;
  116819. protected _buildBlock(state: NodeMaterialBuildState): this;
  116820. }
  116821. }
  116822. declare module BABYLON {
  116823. /**
  116824. * Block used to add 2 vectors
  116825. */
  116826. export class AddBlock extends NodeMaterialBlock {
  116827. /**
  116828. * Creates a new AddBlock
  116829. * @param name defines the block name
  116830. */
  116831. constructor(name: string);
  116832. /**
  116833. * Gets the current class name
  116834. * @returns the class name
  116835. */
  116836. getClassName(): string;
  116837. /**
  116838. * Gets the left operand input component
  116839. */
  116840. readonly left: NodeMaterialConnectionPoint;
  116841. /**
  116842. * Gets the right operand input component
  116843. */
  116844. readonly right: NodeMaterialConnectionPoint;
  116845. /**
  116846. * Gets the output component
  116847. */
  116848. readonly output: NodeMaterialConnectionPoint;
  116849. protected _buildBlock(state: NodeMaterialBuildState): this;
  116850. }
  116851. }
  116852. declare module BABYLON {
  116853. /**
  116854. * Block used to clamp a float
  116855. */
  116856. export class ClampBlock extends NodeMaterialBlock {
  116857. /** Gets or sets the minimum range */
  116858. minimum: number;
  116859. /** Gets or sets the maximum range */
  116860. maximum: number;
  116861. /**
  116862. * Creates a new ClampBlock
  116863. * @param name defines the block name
  116864. */
  116865. constructor(name: string);
  116866. /**
  116867. * Gets the current class name
  116868. * @returns the class name
  116869. */
  116870. getClassName(): string;
  116871. /**
  116872. * Gets the value input component
  116873. */
  116874. readonly value: NodeMaterialConnectionPoint;
  116875. /**
  116876. * Gets the output component
  116877. */
  116878. readonly output: NodeMaterialConnectionPoint;
  116879. protected _buildBlock(state: NodeMaterialBuildState): this;
  116880. }
  116881. }
  116882. declare module BABYLON {
  116883. /**
  116884. * Block used to apply a cross product between 2 vectors
  116885. */
  116886. export class CrossBlock extends NodeMaterialBlock {
  116887. /**
  116888. * Creates a new CrossBlock
  116889. * @param name defines the block name
  116890. */
  116891. constructor(name: string);
  116892. /**
  116893. * Gets the current class name
  116894. * @returns the class name
  116895. */
  116896. getClassName(): string;
  116897. /**
  116898. * Gets the left operand input component
  116899. */
  116900. readonly left: NodeMaterialConnectionPoint;
  116901. /**
  116902. * Gets the right operand input component
  116903. */
  116904. readonly right: NodeMaterialConnectionPoint;
  116905. /**
  116906. * Gets the output component
  116907. */
  116908. readonly output: NodeMaterialConnectionPoint;
  116909. protected _buildBlock(state: NodeMaterialBuildState): this;
  116910. }
  116911. }
  116912. declare module BABYLON {
  116913. /**
  116914. * Block used to apply a dot product between 2 vectors
  116915. */
  116916. export class DotBlock extends NodeMaterialBlock {
  116917. /**
  116918. * Creates a new DotBlock
  116919. * @param name defines the block name
  116920. */
  116921. constructor(name: string);
  116922. /**
  116923. * Gets the current class name
  116924. * @returns the class name
  116925. */
  116926. getClassName(): string;
  116927. /**
  116928. * Gets the left operand input component
  116929. */
  116930. readonly left: NodeMaterialConnectionPoint;
  116931. /**
  116932. * Gets the right operand input component
  116933. */
  116934. readonly right: NodeMaterialConnectionPoint;
  116935. /**
  116936. * Gets the output component
  116937. */
  116938. readonly output: NodeMaterialConnectionPoint;
  116939. protected _buildBlock(state: NodeMaterialBuildState): this;
  116940. }
  116941. }
  116942. declare module BABYLON {
  116943. /**
  116944. * Block used to remap a float from a range to a new one
  116945. */
  116946. export class RemapBlock extends NodeMaterialBlock {
  116947. /**
  116948. * Gets or sets the source range
  116949. */
  116950. sourceRange: Vector2;
  116951. /**
  116952. * Gets or sets the target range
  116953. */
  116954. targetRange: Vector2;
  116955. /**
  116956. * Creates a new RemapBlock
  116957. * @param name defines the block name
  116958. */
  116959. constructor(name: string);
  116960. /**
  116961. * Gets the current class name
  116962. * @returns the class name
  116963. */
  116964. getClassName(): string;
  116965. /**
  116966. * Gets the input component
  116967. */
  116968. readonly input: NodeMaterialConnectionPoint;
  116969. /**
  116970. * Gets the output component
  116971. */
  116972. readonly output: NodeMaterialConnectionPoint;
  116973. protected _buildBlock(state: NodeMaterialBuildState): this;
  116974. }
  116975. }
  116976. declare module BABYLON {
  116977. /**
  116978. * Block used to normalize a vector
  116979. */
  116980. export class NormalizeBlock extends NodeMaterialBlock {
  116981. /**
  116982. * Creates a new NormalizeBlock
  116983. * @param name defines the block name
  116984. */
  116985. constructor(name: string);
  116986. /**
  116987. * Gets the current class name
  116988. * @returns the class name
  116989. */
  116990. getClassName(): string;
  116991. /**
  116992. * Gets the input component
  116993. */
  116994. readonly input: NodeMaterialConnectionPoint;
  116995. /**
  116996. * Gets the output component
  116997. */
  116998. readonly output: NodeMaterialConnectionPoint;
  116999. protected _buildBlock(state: NodeMaterialBuildState): this;
  117000. }
  117001. }
  117002. declare module BABYLON {
  117003. /**
  117004. * Effect Render Options
  117005. */
  117006. export interface IEffectRendererOptions {
  117007. /**
  117008. * Defines the vertices positions.
  117009. */
  117010. positions?: number[];
  117011. /**
  117012. * Defines the indices.
  117013. */
  117014. indices?: number[];
  117015. }
  117016. /**
  117017. * Helper class to render one or more effects
  117018. */
  117019. export class EffectRenderer {
  117020. private engine;
  117021. private static _DefaultOptions;
  117022. private _vertexBuffers;
  117023. private _indexBuffer;
  117024. private _ringBufferIndex;
  117025. private _ringScreenBuffer;
  117026. private _fullscreenViewport;
  117027. private _getNextFrameBuffer;
  117028. /**
  117029. * Creates an effect renderer
  117030. * @param engine the engine to use for rendering
  117031. * @param options defines the options of the effect renderer
  117032. */
  117033. constructor(engine: Engine, options?: IEffectRendererOptions);
  117034. /**
  117035. * Sets the current viewport in normalized coordinates 0-1
  117036. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  117037. */
  117038. setViewport(viewport?: Viewport): void;
  117039. /**
  117040. * Sets the current effect wrapper to use during draw.
  117041. * The effect needs to be ready before calling this api.
  117042. * This also sets the default full screen position attribute.
  117043. * @param effectWrapper Defines the effect to draw with
  117044. */
  117045. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  117046. /**
  117047. * Draws a full screen quad.
  117048. */
  117049. draw(): void;
  117050. /**
  117051. * renders one or more effects to a specified texture
  117052. * @param effectWrappers list of effects to renderer
  117053. * @param outputTexture texture to draw to, if null it will render to the screen
  117054. */
  117055. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  117056. /**
  117057. * Disposes of the effect renderer
  117058. */
  117059. dispose(): void;
  117060. }
  117061. /**
  117062. * Options to create an EffectWrapper
  117063. */
  117064. interface EffectWrapperCreationOptions {
  117065. /**
  117066. * Engine to use to create the effect
  117067. */
  117068. engine: Engine;
  117069. /**
  117070. * Fragment shader for the effect
  117071. */
  117072. fragmentShader: string;
  117073. /**
  117074. * Vertex shader for the effect
  117075. */
  117076. vertexShader?: string;
  117077. /**
  117078. * Attributes to use in the shader
  117079. */
  117080. attributeNames?: Array<string>;
  117081. /**
  117082. * Uniforms to use in the shader
  117083. */
  117084. uniformNames?: Array<string>;
  117085. /**
  117086. * Texture sampler names to use in the shader
  117087. */
  117088. samplerNames?: Array<string>;
  117089. /**
  117090. * The friendly name of the effect displayed in Spector.
  117091. */
  117092. name?: string;
  117093. }
  117094. /**
  117095. * Wraps an effect to be used for rendering
  117096. */
  117097. export class EffectWrapper {
  117098. /**
  117099. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  117100. */
  117101. onApplyObservable: Observable<{}>;
  117102. /**
  117103. * The underlying effect
  117104. */
  117105. effect: Effect;
  117106. /**
  117107. * Creates an effect to be renderer
  117108. * @param creationOptions options to create the effect
  117109. */
  117110. constructor(creationOptions: EffectWrapperCreationOptions);
  117111. /**
  117112. * Disposes of the effect wrapper
  117113. */
  117114. dispose(): void;
  117115. }
  117116. }
  117117. declare module BABYLON {
  117118. /**
  117119. * Helper class to push actions to a pool of workers.
  117120. */
  117121. export class WorkerPool implements IDisposable {
  117122. private _workerInfos;
  117123. private _pendingActions;
  117124. /**
  117125. * Constructor
  117126. * @param workers Array of workers to use for actions
  117127. */
  117128. constructor(workers: Array<Worker>);
  117129. /**
  117130. * Terminates all workers and clears any pending actions.
  117131. */
  117132. dispose(): void;
  117133. /**
  117134. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117135. * pended until a worker has completed its action.
  117136. * @param action The action to perform. Call onComplete when the action is complete.
  117137. */
  117138. push(action: (worker: Worker, onComplete: () => void) => void): void;
  117139. private _execute;
  117140. }
  117141. }
  117142. declare module BABYLON {
  117143. /**
  117144. * Configuration for Draco compression
  117145. */
  117146. export interface IDracoCompressionConfiguration {
  117147. /**
  117148. * Configuration for the decoder.
  117149. */
  117150. decoder: {
  117151. /**
  117152. * The url to the WebAssembly module.
  117153. */
  117154. wasmUrl?: string;
  117155. /**
  117156. * The url to the WebAssembly binary.
  117157. */
  117158. wasmBinaryUrl?: string;
  117159. /**
  117160. * The url to the fallback JavaScript module.
  117161. */
  117162. fallbackUrl?: string;
  117163. };
  117164. }
  117165. /**
  117166. * Draco compression (https://google.github.io/draco/)
  117167. *
  117168. * This class wraps the Draco module.
  117169. *
  117170. * **Encoder**
  117171. *
  117172. * The encoder is not currently implemented.
  117173. *
  117174. * **Decoder**
  117175. *
  117176. * 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.
  117177. *
  117178. * To update the configuration, use the following code:
  117179. * ```javascript
  117180. * DracoCompression.Configuration = {
  117181. * decoder: {
  117182. * wasmUrl: "<url to the WebAssembly library>",
  117183. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  117184. * fallbackUrl: "<url to the fallback JavaScript library>",
  117185. * }
  117186. * };
  117187. * ```
  117188. *
  117189. * 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.
  117190. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  117191. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  117192. *
  117193. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  117194. * ```javascript
  117195. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  117196. * ```
  117197. *
  117198. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  117199. */
  117200. export class DracoCompression implements IDisposable {
  117201. private _workerPoolPromise?;
  117202. private _decoderModulePromise?;
  117203. /**
  117204. * The configuration. Defaults to the following urls:
  117205. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  117206. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  117207. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  117208. */
  117209. static Configuration: IDracoCompressionConfiguration;
  117210. /**
  117211. * Returns true if the decoder configuration is available.
  117212. */
  117213. static readonly DecoderAvailable: boolean;
  117214. /**
  117215. * Default number of workers to create when creating the draco compression object.
  117216. */
  117217. static DefaultNumWorkers: number;
  117218. private static GetDefaultNumWorkers;
  117219. private static _Default;
  117220. /**
  117221. * Default instance for the draco compression object.
  117222. */
  117223. static readonly Default: DracoCompression;
  117224. /**
  117225. * Constructor
  117226. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  117227. */
  117228. constructor(numWorkers?: number);
  117229. /**
  117230. * Stop all async operations and release resources.
  117231. */
  117232. dispose(): void;
  117233. /**
  117234. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  117235. * @returns a promise that resolves when ready
  117236. */
  117237. whenReadyAsync(): Promise<void>;
  117238. /**
  117239. * Decode Draco compressed mesh data to vertex data.
  117240. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  117241. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  117242. * @returns A promise that resolves with the decoded vertex data
  117243. */
  117244. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  117245. [kind: string]: number;
  117246. }): Promise<VertexData>;
  117247. }
  117248. }
  117249. declare module BABYLON {
  117250. /**
  117251. * Class for building Constructive Solid Geometry
  117252. */
  117253. export class CSG {
  117254. private polygons;
  117255. /**
  117256. * The world matrix
  117257. */
  117258. matrix: Matrix;
  117259. /**
  117260. * Stores the position
  117261. */
  117262. position: Vector3;
  117263. /**
  117264. * Stores the rotation
  117265. */
  117266. rotation: Vector3;
  117267. /**
  117268. * Stores the rotation quaternion
  117269. */
  117270. rotationQuaternion: Nullable<Quaternion>;
  117271. /**
  117272. * Stores the scaling vector
  117273. */
  117274. scaling: Vector3;
  117275. /**
  117276. * Convert the Mesh to CSG
  117277. * @param mesh The Mesh to convert to CSG
  117278. * @returns A new CSG from the Mesh
  117279. */
  117280. static FromMesh(mesh: Mesh): CSG;
  117281. /**
  117282. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  117283. * @param polygons Polygons used to construct a CSG solid
  117284. */
  117285. private static FromPolygons;
  117286. /**
  117287. * Clones, or makes a deep copy, of the CSG
  117288. * @returns A new CSG
  117289. */
  117290. clone(): CSG;
  117291. /**
  117292. * Unions this CSG with another CSG
  117293. * @param csg The CSG to union against this CSG
  117294. * @returns The unioned CSG
  117295. */
  117296. union(csg: CSG): CSG;
  117297. /**
  117298. * Unions this CSG with another CSG in place
  117299. * @param csg The CSG to union against this CSG
  117300. */
  117301. unionInPlace(csg: CSG): void;
  117302. /**
  117303. * Subtracts this CSG with another CSG
  117304. * @param csg The CSG to subtract against this CSG
  117305. * @returns A new CSG
  117306. */
  117307. subtract(csg: CSG): CSG;
  117308. /**
  117309. * Subtracts this CSG with another CSG in place
  117310. * @param csg The CSG to subtact against this CSG
  117311. */
  117312. subtractInPlace(csg: CSG): void;
  117313. /**
  117314. * Intersect this CSG with another CSG
  117315. * @param csg The CSG to intersect against this CSG
  117316. * @returns A new CSG
  117317. */
  117318. intersect(csg: CSG): CSG;
  117319. /**
  117320. * Intersects this CSG with another CSG in place
  117321. * @param csg The CSG to intersect against this CSG
  117322. */
  117323. intersectInPlace(csg: CSG): void;
  117324. /**
  117325. * Return a new CSG solid with solid and empty space switched. This solid is
  117326. * not modified.
  117327. * @returns A new CSG solid with solid and empty space switched
  117328. */
  117329. inverse(): CSG;
  117330. /**
  117331. * Inverses the CSG in place
  117332. */
  117333. inverseInPlace(): void;
  117334. /**
  117335. * This is used to keep meshes transformations so they can be restored
  117336. * when we build back a Babylon Mesh
  117337. * NB : All CSG operations are performed in world coordinates
  117338. * @param csg The CSG to copy the transform attributes from
  117339. * @returns This CSG
  117340. */
  117341. copyTransformAttributes(csg: CSG): CSG;
  117342. /**
  117343. * Build Raw mesh from CSG
  117344. * Coordinates here are in world space
  117345. * @param name The name of the mesh geometry
  117346. * @param scene The Scene
  117347. * @param keepSubMeshes Specifies if the submeshes should be kept
  117348. * @returns A new Mesh
  117349. */
  117350. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  117351. /**
  117352. * Build Mesh from CSG taking material and transforms into account
  117353. * @param name The name of the Mesh
  117354. * @param material The material of the Mesh
  117355. * @param scene The Scene
  117356. * @param keepSubMeshes Specifies if submeshes should be kept
  117357. * @returns The new Mesh
  117358. */
  117359. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  117360. }
  117361. }
  117362. declare module BABYLON {
  117363. /**
  117364. * Class used to create a trail following a mesh
  117365. */
  117366. export class TrailMesh extends Mesh {
  117367. private _generator;
  117368. private _autoStart;
  117369. private _running;
  117370. private _diameter;
  117371. private _length;
  117372. private _sectionPolygonPointsCount;
  117373. private _sectionVectors;
  117374. private _sectionNormalVectors;
  117375. private _beforeRenderObserver;
  117376. /**
  117377. * @constructor
  117378. * @param name The value used by scene.getMeshByName() to do a lookup.
  117379. * @param generator The mesh to generate a trail.
  117380. * @param scene The scene to add this mesh to.
  117381. * @param diameter Diameter of trailing mesh. Default is 1.
  117382. * @param length Length of trailing mesh. Default is 60.
  117383. * @param autoStart Automatically start trailing mesh. Default true.
  117384. */
  117385. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  117386. /**
  117387. * "TrailMesh"
  117388. * @returns "TrailMesh"
  117389. */
  117390. getClassName(): string;
  117391. private _createMesh;
  117392. /**
  117393. * Start trailing mesh.
  117394. */
  117395. start(): void;
  117396. /**
  117397. * Stop trailing mesh.
  117398. */
  117399. stop(): void;
  117400. /**
  117401. * Update trailing mesh geometry.
  117402. */
  117403. update(): void;
  117404. /**
  117405. * Returns a new TrailMesh object.
  117406. * @param name is a string, the name given to the new mesh
  117407. * @param newGenerator use new generator object for cloned trail mesh
  117408. * @returns a new mesh
  117409. */
  117410. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117411. /**
  117412. * Serializes this trail mesh
  117413. * @param serializationObject object to write serialization to
  117414. */
  117415. serialize(serializationObject: any): void;
  117416. /**
  117417. * Parses a serialized trail mesh
  117418. * @param parsedMesh the serialized mesh
  117419. * @param scene the scene to create the trail mesh in
  117420. * @returns the created trail mesh
  117421. */
  117422. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117423. }
  117424. }
  117425. declare module BABYLON {
  117426. /**
  117427. * Class containing static functions to help procedurally build meshes
  117428. */
  117429. export class TiledBoxBuilder {
  117430. /**
  117431. * Creates a box mesh
  117432. * 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)
  117433. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117437. * @param name defines the name of the mesh
  117438. * @param options defines the options used to create the mesh
  117439. * @param scene defines the hosting scene
  117440. * @returns the box mesh
  117441. */
  117442. static CreateTiledBox(name: string, options: {
  117443. pattern?: number;
  117444. width?: number;
  117445. height?: number;
  117446. depth?: number;
  117447. tileSize?: number;
  117448. tileWidth?: number;
  117449. tileHeight?: number;
  117450. alignHorizontal?: number;
  117451. alignVertical?: number;
  117452. faceUV?: Vector4[];
  117453. faceColors?: Color4[];
  117454. sideOrientation?: number;
  117455. updatable?: boolean;
  117456. }, scene?: Nullable<Scene>): Mesh;
  117457. }
  117458. }
  117459. declare module BABYLON {
  117460. /**
  117461. * Class containing static functions to help procedurally build meshes
  117462. */
  117463. export class TorusKnotBuilder {
  117464. /**
  117465. * Creates a torus knot mesh
  117466. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117467. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117468. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117469. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117473. * @param name defines the name of the mesh
  117474. * @param options defines the options used to create the mesh
  117475. * @param scene defines the hosting scene
  117476. * @returns the torus knot mesh
  117477. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117478. */
  117479. static CreateTorusKnot(name: string, options: {
  117480. radius?: number;
  117481. tube?: number;
  117482. radialSegments?: number;
  117483. tubularSegments?: number;
  117484. p?: number;
  117485. q?: number;
  117486. updatable?: boolean;
  117487. sideOrientation?: number;
  117488. frontUVs?: Vector4;
  117489. backUVs?: Vector4;
  117490. }, scene: any): Mesh;
  117491. }
  117492. }
  117493. declare module BABYLON {
  117494. /**
  117495. * Polygon
  117496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117497. */
  117498. export class Polygon {
  117499. /**
  117500. * Creates a rectangle
  117501. * @param xmin bottom X coord
  117502. * @param ymin bottom Y coord
  117503. * @param xmax top X coord
  117504. * @param ymax top Y coord
  117505. * @returns points that make the resulting rectation
  117506. */
  117507. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117508. /**
  117509. * Creates a circle
  117510. * @param radius radius of circle
  117511. * @param cx scale in x
  117512. * @param cy scale in y
  117513. * @param numberOfSides number of sides that make up the circle
  117514. * @returns points that make the resulting circle
  117515. */
  117516. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  117517. /**
  117518. * Creates a polygon from input string
  117519. * @param input Input polygon data
  117520. * @returns the parsed points
  117521. */
  117522. static Parse(input: string): Vector2[];
  117523. /**
  117524. * Starts building a polygon from x and y coordinates
  117525. * @param x x coordinate
  117526. * @param y y coordinate
  117527. * @returns the started path2
  117528. */
  117529. static StartingAt(x: number, y: number): Path2;
  117530. }
  117531. /**
  117532. * Builds a polygon
  117533. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  117534. */
  117535. export class PolygonMeshBuilder {
  117536. private _points;
  117537. private _outlinepoints;
  117538. private _holes;
  117539. private _name;
  117540. private _scene;
  117541. private _epoints;
  117542. private _eholes;
  117543. private _addToepoint;
  117544. /**
  117545. * Babylon reference to the earcut plugin.
  117546. */
  117547. bjsEarcut: any;
  117548. /**
  117549. * Creates a PolygonMeshBuilder
  117550. * @param name name of the builder
  117551. * @param contours Path of the polygon
  117552. * @param scene scene to add to when creating the mesh
  117553. * @param earcutInjection can be used to inject your own earcut reference
  117554. */
  117555. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  117556. /**
  117557. * Adds a whole within the polygon
  117558. * @param hole Array of points defining the hole
  117559. * @returns this
  117560. */
  117561. addHole(hole: Vector2[]): PolygonMeshBuilder;
  117562. /**
  117563. * Creates the polygon
  117564. * @param updatable If the mesh should be updatable
  117565. * @param depth The depth of the mesh created
  117566. * @returns the created mesh
  117567. */
  117568. build(updatable?: boolean, depth?: number): Mesh;
  117569. /**
  117570. * Creates the polygon
  117571. * @param depth The depth of the mesh created
  117572. * @returns the created VertexData
  117573. */
  117574. buildVertexData(depth?: number): VertexData;
  117575. /**
  117576. * Adds a side to the polygon
  117577. * @param positions points that make the polygon
  117578. * @param normals normals of the polygon
  117579. * @param uvs uvs of the polygon
  117580. * @param indices indices of the polygon
  117581. * @param bounds bounds of the polygon
  117582. * @param points points of the polygon
  117583. * @param depth depth of the polygon
  117584. * @param flip flip of the polygon
  117585. */
  117586. private addSide;
  117587. }
  117588. }
  117589. declare module BABYLON {
  117590. /**
  117591. * Class containing static functions to help procedurally build meshes
  117592. */
  117593. export class PolygonBuilder {
  117594. /**
  117595. * Creates a polygon mesh
  117596. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117597. * * 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
  117598. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117601. * * Remember you can only change the shape positions, not their number when updating a polygon
  117602. * @param name defines the name of the mesh
  117603. * @param options defines the options used to create the mesh
  117604. * @param scene defines the hosting scene
  117605. * @param earcutInjection can be used to inject your own earcut reference
  117606. * @returns the polygon mesh
  117607. */
  117608. static CreatePolygon(name: string, options: {
  117609. shape: Vector3[];
  117610. holes?: Vector3[][];
  117611. depth?: number;
  117612. faceUV?: Vector4[];
  117613. faceColors?: Color4[];
  117614. updatable?: boolean;
  117615. sideOrientation?: number;
  117616. frontUVs?: Vector4;
  117617. backUVs?: Vector4;
  117618. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117619. /**
  117620. * Creates an extruded polygon mesh, with depth in the Y direction.
  117621. * * 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)
  117622. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117623. * @param name defines the name of the mesh
  117624. * @param options defines the options used to create the mesh
  117625. * @param scene defines the hosting scene
  117626. * @param earcutInjection can be used to inject your own earcut reference
  117627. * @returns the polygon mesh
  117628. */
  117629. static ExtrudePolygon(name: string, options: {
  117630. shape: Vector3[];
  117631. holes?: Vector3[][];
  117632. depth?: number;
  117633. faceUV?: Vector4[];
  117634. faceColors?: Color4[];
  117635. updatable?: boolean;
  117636. sideOrientation?: number;
  117637. frontUVs?: Vector4;
  117638. backUVs?: Vector4;
  117639. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117640. }
  117641. }
  117642. declare module BABYLON {
  117643. /**
  117644. * Class containing static functions to help procedurally build meshes
  117645. */
  117646. export class LatheBuilder {
  117647. /**
  117648. * Creates lathe mesh.
  117649. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117650. * * 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
  117651. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117652. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117653. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117654. * * 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
  117655. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117656. * * 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
  117657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117661. * @param name defines the name of the mesh
  117662. * @param options defines the options used to create the mesh
  117663. * @param scene defines the hosting scene
  117664. * @returns the lathe mesh
  117665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117666. */
  117667. static CreateLathe(name: string, options: {
  117668. shape: Vector3[];
  117669. radius?: number;
  117670. tessellation?: number;
  117671. clip?: number;
  117672. arc?: number;
  117673. closed?: boolean;
  117674. updatable?: boolean;
  117675. sideOrientation?: number;
  117676. frontUVs?: Vector4;
  117677. backUVs?: Vector4;
  117678. cap?: number;
  117679. invertUV?: boolean;
  117680. }, scene?: Nullable<Scene>): Mesh;
  117681. }
  117682. }
  117683. declare module BABYLON {
  117684. /**
  117685. * Class containing static functions to help procedurally build meshes
  117686. */
  117687. export class TiledPlaneBuilder {
  117688. /**
  117689. * Creates a tiled plane mesh
  117690. * * The parameter `pattern` will, depending on value, do nothing or
  117691. * * * flip (reflect about central vertical) alternate tiles across and up
  117692. * * * flip every tile on alternate rows
  117693. * * * rotate (180 degs) alternate tiles across and up
  117694. * * * rotate every tile on alternate rows
  117695. * * * flip and rotate alternate tiles across and up
  117696. * * * flip and rotate every tile on alternate rows
  117697. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  117698. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  117699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117701. * * 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)
  117702. * * 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)
  117703. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117704. * @param name defines the name of the mesh
  117705. * @param options defines the options used to create the mesh
  117706. * @param scene defines the hosting scene
  117707. * @returns the box mesh
  117708. */
  117709. static CreateTiledPlane(name: string, options: {
  117710. pattern?: number;
  117711. tileSize?: number;
  117712. tileWidth?: number;
  117713. tileHeight?: number;
  117714. size?: number;
  117715. width?: number;
  117716. height?: number;
  117717. alignHorizontal?: number;
  117718. alignVertical?: number;
  117719. sideOrientation?: number;
  117720. frontUVs?: Vector4;
  117721. backUVs?: Vector4;
  117722. updatable?: boolean;
  117723. }, scene?: Nullable<Scene>): Mesh;
  117724. }
  117725. }
  117726. declare module BABYLON {
  117727. /**
  117728. * Class containing static functions to help procedurally build meshes
  117729. */
  117730. export class TubeBuilder {
  117731. /**
  117732. * Creates a tube mesh.
  117733. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117734. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117735. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117736. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117737. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117738. * * 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)
  117739. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117740. * * 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
  117741. * * 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
  117742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117746. * @param name defines the name of the mesh
  117747. * @param options defines the options used to create the mesh
  117748. * @param scene defines the hosting scene
  117749. * @returns the tube mesh
  117750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117751. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117752. */
  117753. static CreateTube(name: string, options: {
  117754. path: Vector3[];
  117755. radius?: number;
  117756. tessellation?: number;
  117757. radiusFunction?: {
  117758. (i: number, distance: number): number;
  117759. };
  117760. cap?: number;
  117761. arc?: number;
  117762. updatable?: boolean;
  117763. sideOrientation?: number;
  117764. frontUVs?: Vector4;
  117765. backUVs?: Vector4;
  117766. instance?: Mesh;
  117767. invertUV?: boolean;
  117768. }, scene?: Nullable<Scene>): Mesh;
  117769. }
  117770. }
  117771. declare module BABYLON {
  117772. /**
  117773. * Class containing static functions to help procedurally build meshes
  117774. */
  117775. export class IcoSphereBuilder {
  117776. /**
  117777. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117778. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117779. * * 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`)
  117780. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117781. * * 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
  117782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117785. * @param name defines the name of the mesh
  117786. * @param options defines the options used to create the mesh
  117787. * @param scene defines the hosting scene
  117788. * @returns the icosahedron mesh
  117789. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117790. */
  117791. static CreateIcoSphere(name: string, options: {
  117792. radius?: number;
  117793. radiusX?: number;
  117794. radiusY?: number;
  117795. radiusZ?: number;
  117796. flat?: boolean;
  117797. subdivisions?: number;
  117798. sideOrientation?: number;
  117799. frontUVs?: Vector4;
  117800. backUVs?: Vector4;
  117801. updatable?: boolean;
  117802. }, scene?: Nullable<Scene>): Mesh;
  117803. }
  117804. }
  117805. declare module BABYLON {
  117806. /**
  117807. * Class containing static functions to help procedurally build meshes
  117808. */
  117809. export class DecalBuilder {
  117810. /**
  117811. * Creates a decal mesh.
  117812. * 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
  117813. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117814. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117815. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117816. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117817. * @param name defines the name of the mesh
  117818. * @param sourceMesh defines the mesh where the decal must be applied
  117819. * @param options defines the options used to create the mesh
  117820. * @param scene defines the hosting scene
  117821. * @returns the decal mesh
  117822. * @see https://doc.babylonjs.com/how_to/decals
  117823. */
  117824. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117825. position?: Vector3;
  117826. normal?: Vector3;
  117827. size?: Vector3;
  117828. angle?: number;
  117829. }): Mesh;
  117830. }
  117831. }
  117832. declare module BABYLON {
  117833. /**
  117834. * Class containing static functions to help procedurally build meshes
  117835. */
  117836. export class MeshBuilder {
  117837. /**
  117838. * Creates a box mesh
  117839. * * The parameter `size` sets the size (float) of each box side (default 1)
  117840. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117841. * * 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)
  117842. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117846. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117847. * @param name defines the name of the mesh
  117848. * @param options defines the options used to create the mesh
  117849. * @param scene defines the hosting scene
  117850. * @returns the box mesh
  117851. */
  117852. static CreateBox(name: string, options: {
  117853. size?: number;
  117854. width?: number;
  117855. height?: number;
  117856. depth?: number;
  117857. faceUV?: Vector4[];
  117858. faceColors?: Color4[];
  117859. sideOrientation?: number;
  117860. frontUVs?: Vector4;
  117861. backUVs?: Vector4;
  117862. updatable?: boolean;
  117863. }, scene?: Nullable<Scene>): Mesh;
  117864. /**
  117865. * Creates a tiled box mesh
  117866. * * faceTiles sets the pattern, tile size and number of tiles for a face
  117867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117868. * @param name defines the name of the mesh
  117869. * @param options defines the options used to create the mesh
  117870. * @param scene defines the hosting scene
  117871. * @returns the tiled box mesh
  117872. */
  117873. static CreateTiledBox(name: string, options: {
  117874. pattern?: number;
  117875. size?: number;
  117876. width?: number;
  117877. height?: number;
  117878. depth: number;
  117879. tileSize?: number;
  117880. tileWidth?: number;
  117881. tileHeight?: number;
  117882. faceUV?: Vector4[];
  117883. faceColors?: Color4[];
  117884. alignHorizontal?: number;
  117885. alignVertical?: number;
  117886. sideOrientation?: number;
  117887. updatable?: boolean;
  117888. }, scene?: Nullable<Scene>): Mesh;
  117889. /**
  117890. * Creates a sphere mesh
  117891. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117892. * * 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`)
  117893. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117894. * * 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
  117895. * * 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)
  117896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117899. * @param name defines the name of the mesh
  117900. * @param options defines the options used to create the mesh
  117901. * @param scene defines the hosting scene
  117902. * @returns the sphere mesh
  117903. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117904. */
  117905. static CreateSphere(name: string, options: {
  117906. segments?: number;
  117907. diameter?: number;
  117908. diameterX?: number;
  117909. diameterY?: number;
  117910. diameterZ?: number;
  117911. arc?: number;
  117912. slice?: number;
  117913. sideOrientation?: number;
  117914. frontUVs?: Vector4;
  117915. backUVs?: Vector4;
  117916. updatable?: boolean;
  117917. }, scene?: Nullable<Scene>): Mesh;
  117918. /**
  117919. * Creates a plane polygonal mesh. By default, this is a disc
  117920. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  117921. * * 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
  117922. * * 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
  117923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117926. * @param name defines the name of the mesh
  117927. * @param options defines the options used to create the mesh
  117928. * @param scene defines the hosting scene
  117929. * @returns the plane polygonal mesh
  117930. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  117931. */
  117932. static CreateDisc(name: string, options: {
  117933. radius?: number;
  117934. tessellation?: number;
  117935. arc?: number;
  117936. updatable?: boolean;
  117937. sideOrientation?: number;
  117938. frontUVs?: Vector4;
  117939. backUVs?: Vector4;
  117940. }, scene?: Nullable<Scene>): Mesh;
  117941. /**
  117942. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117943. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117944. * * 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`)
  117945. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117946. * * 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
  117947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117950. * @param name defines the name of the mesh
  117951. * @param options defines the options used to create the mesh
  117952. * @param scene defines the hosting scene
  117953. * @returns the icosahedron mesh
  117954. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117955. */
  117956. static CreateIcoSphere(name: string, options: {
  117957. radius?: number;
  117958. radiusX?: number;
  117959. radiusY?: number;
  117960. radiusZ?: number;
  117961. flat?: boolean;
  117962. subdivisions?: number;
  117963. sideOrientation?: number;
  117964. frontUVs?: Vector4;
  117965. backUVs?: Vector4;
  117966. updatable?: boolean;
  117967. }, scene?: Nullable<Scene>): Mesh;
  117968. /**
  117969. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117970. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117971. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117972. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117973. * * 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
  117974. * * 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
  117975. * * 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
  117976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117979. * * 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
  117980. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117981. * * 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
  117982. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117984. * @param name defines the name of the mesh
  117985. * @param options defines the options used to create the mesh
  117986. * @param scene defines the hosting scene
  117987. * @returns the ribbon mesh
  117988. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117989. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117990. */
  117991. static CreateRibbon(name: string, options: {
  117992. pathArray: Vector3[][];
  117993. closeArray?: boolean;
  117994. closePath?: boolean;
  117995. offset?: number;
  117996. updatable?: boolean;
  117997. sideOrientation?: number;
  117998. frontUVs?: Vector4;
  117999. backUVs?: Vector4;
  118000. instance?: Mesh;
  118001. invertUV?: boolean;
  118002. uvs?: Vector2[];
  118003. colors?: Color4[];
  118004. }, scene?: Nullable<Scene>): Mesh;
  118005. /**
  118006. * Creates a cylinder or a cone mesh
  118007. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118008. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118009. * * 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.
  118010. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118011. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118012. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118013. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118014. * * 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).
  118015. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118016. * * 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).
  118017. * * 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
  118018. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118019. * * 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
  118020. * * 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.
  118021. * * If `enclose` is false, a ring surface is one element.
  118022. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118023. * * 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
  118024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118027. * @param name defines the name of the mesh
  118028. * @param options defines the options used to create the mesh
  118029. * @param scene defines the hosting scene
  118030. * @returns the cylinder mesh
  118031. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118032. */
  118033. static CreateCylinder(name: string, options: {
  118034. height?: number;
  118035. diameterTop?: number;
  118036. diameterBottom?: number;
  118037. diameter?: number;
  118038. tessellation?: number;
  118039. subdivisions?: number;
  118040. arc?: number;
  118041. faceColors?: Color4[];
  118042. faceUV?: Vector4[];
  118043. updatable?: boolean;
  118044. hasRings?: boolean;
  118045. enclose?: boolean;
  118046. cap?: number;
  118047. sideOrientation?: number;
  118048. frontUVs?: Vector4;
  118049. backUVs?: Vector4;
  118050. }, scene?: Nullable<Scene>): Mesh;
  118051. /**
  118052. * Creates a torus mesh
  118053. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118054. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118055. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118059. * @param name defines the name of the mesh
  118060. * @param options defines the options used to create the mesh
  118061. * @param scene defines the hosting scene
  118062. * @returns the torus mesh
  118063. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118064. */
  118065. static CreateTorus(name: string, options: {
  118066. diameter?: number;
  118067. thickness?: number;
  118068. tessellation?: number;
  118069. updatable?: boolean;
  118070. sideOrientation?: number;
  118071. frontUVs?: Vector4;
  118072. backUVs?: Vector4;
  118073. }, scene?: Nullable<Scene>): Mesh;
  118074. /**
  118075. * Creates a torus knot mesh
  118076. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118077. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118078. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118079. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118083. * @param name defines the name of the mesh
  118084. * @param options defines the options used to create the mesh
  118085. * @param scene defines the hosting scene
  118086. * @returns the torus knot mesh
  118087. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118088. */
  118089. static CreateTorusKnot(name: string, options: {
  118090. radius?: number;
  118091. tube?: number;
  118092. radialSegments?: number;
  118093. tubularSegments?: number;
  118094. p?: number;
  118095. q?: number;
  118096. updatable?: boolean;
  118097. sideOrientation?: number;
  118098. frontUVs?: Vector4;
  118099. backUVs?: Vector4;
  118100. }, scene?: Nullable<Scene>): Mesh;
  118101. /**
  118102. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118103. * * 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
  118104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118105. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118106. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118107. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118108. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118109. * * 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
  118110. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118113. * @param name defines the name of the new line system
  118114. * @param options defines the options used to create the line system
  118115. * @param scene defines the hosting scene
  118116. * @returns a new line system mesh
  118117. */
  118118. static CreateLineSystem(name: string, options: {
  118119. lines: Vector3[][];
  118120. updatable?: boolean;
  118121. instance?: Nullable<LinesMesh>;
  118122. colors?: Nullable<Color4[][]>;
  118123. useVertexAlpha?: boolean;
  118124. }, scene: Nullable<Scene>): LinesMesh;
  118125. /**
  118126. * Creates a line mesh
  118127. * 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
  118128. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118129. * * The parameter `points` is an array successive Vector3
  118130. * * 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
  118131. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118132. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118133. * * When updating an instance, remember that only point positions can change, not the number of points
  118134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118136. * @param name defines the name of the new line system
  118137. * @param options defines the options used to create the line system
  118138. * @param scene defines the hosting scene
  118139. * @returns a new line mesh
  118140. */
  118141. static CreateLines(name: string, options: {
  118142. points: Vector3[];
  118143. updatable?: boolean;
  118144. instance?: Nullable<LinesMesh>;
  118145. colors?: Color4[];
  118146. useVertexAlpha?: boolean;
  118147. }, scene?: Nullable<Scene>): LinesMesh;
  118148. /**
  118149. * Creates a dashed line mesh
  118150. * * 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
  118151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118152. * * The parameter `points` is an array successive Vector3
  118153. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118154. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118155. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118156. * * 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
  118157. * * When updating an instance, remember that only point positions can change, not the number of points
  118158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118159. * @param name defines the name of the mesh
  118160. * @param options defines the options used to create the mesh
  118161. * @param scene defines the hosting scene
  118162. * @returns the dashed line mesh
  118163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118164. */
  118165. static CreateDashedLines(name: string, options: {
  118166. points: Vector3[];
  118167. dashSize?: number;
  118168. gapSize?: number;
  118169. dashNb?: number;
  118170. updatable?: boolean;
  118171. instance?: LinesMesh;
  118172. }, scene?: Nullable<Scene>): LinesMesh;
  118173. /**
  118174. * 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.
  118175. * * 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.
  118176. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118177. * * 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.
  118178. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118179. * * 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
  118180. * * 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
  118181. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118186. * @param name defines the name of the mesh
  118187. * @param options defines the options used to create the mesh
  118188. * @param scene defines the hosting scene
  118189. * @returns the extruded shape mesh
  118190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118192. */
  118193. static ExtrudeShape(name: string, options: {
  118194. shape: Vector3[];
  118195. path: Vector3[];
  118196. scale?: number;
  118197. rotation?: number;
  118198. cap?: number;
  118199. updatable?: boolean;
  118200. sideOrientation?: number;
  118201. frontUVs?: Vector4;
  118202. backUVs?: Vector4;
  118203. instance?: Mesh;
  118204. invertUV?: boolean;
  118205. }, scene?: Nullable<Scene>): Mesh;
  118206. /**
  118207. * Creates an custom extruded shape mesh.
  118208. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118209. * * 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.
  118210. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118211. * * 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
  118212. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118213. * * 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
  118214. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118215. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118216. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118217. * * 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
  118218. * * 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
  118219. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118222. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118224. * @param name defines the name of the mesh
  118225. * @param options defines the options used to create the mesh
  118226. * @param scene defines the hosting scene
  118227. * @returns the custom extruded shape mesh
  118228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118229. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118231. */
  118232. static ExtrudeShapeCustom(name: string, options: {
  118233. shape: Vector3[];
  118234. path: Vector3[];
  118235. scaleFunction?: any;
  118236. rotationFunction?: any;
  118237. ribbonCloseArray?: boolean;
  118238. ribbonClosePath?: boolean;
  118239. cap?: number;
  118240. updatable?: boolean;
  118241. sideOrientation?: number;
  118242. frontUVs?: Vector4;
  118243. backUVs?: Vector4;
  118244. instance?: Mesh;
  118245. invertUV?: boolean;
  118246. }, scene?: Nullable<Scene>): Mesh;
  118247. /**
  118248. * Creates lathe mesh.
  118249. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118250. * * 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
  118251. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118252. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118253. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118254. * * 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
  118255. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118256. * * 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
  118257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118261. * @param name defines the name of the mesh
  118262. * @param options defines the options used to create the mesh
  118263. * @param scene defines the hosting scene
  118264. * @returns the lathe mesh
  118265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118266. */
  118267. static CreateLathe(name: string, options: {
  118268. shape: Vector3[];
  118269. radius?: number;
  118270. tessellation?: number;
  118271. clip?: number;
  118272. arc?: number;
  118273. closed?: boolean;
  118274. updatable?: boolean;
  118275. sideOrientation?: number;
  118276. frontUVs?: Vector4;
  118277. backUVs?: Vector4;
  118278. cap?: number;
  118279. invertUV?: boolean;
  118280. }, scene?: Nullable<Scene>): Mesh;
  118281. /**
  118282. * Creates a tiled plane mesh
  118283. * * You can set a limited pattern arrangement with the tiles
  118284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118287. * @param name defines the name of the mesh
  118288. * @param options defines the options used to create the mesh
  118289. * @param scene defines the hosting scene
  118290. * @returns the plane mesh
  118291. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118292. */
  118293. static CreateTiledPlane(name: string, options: {
  118294. pattern?: number;
  118295. tileSize?: number;
  118296. tileWidth?: number;
  118297. tileHeight?: number;
  118298. size?: number;
  118299. width?: number;
  118300. height?: number;
  118301. alignHorizontal?: number;
  118302. alignVertical?: number;
  118303. sideOrientation?: number;
  118304. frontUVs?: Vector4;
  118305. backUVs?: Vector4;
  118306. updatable?: boolean;
  118307. }, scene?: Nullable<Scene>): Mesh;
  118308. /**
  118309. * Creates a plane mesh
  118310. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  118311. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  118312. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  118313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118316. * @param name defines the name of the mesh
  118317. * @param options defines the options used to create the mesh
  118318. * @param scene defines the hosting scene
  118319. * @returns the plane mesh
  118320. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118321. */
  118322. static CreatePlane(name: string, options: {
  118323. size?: number;
  118324. width?: number;
  118325. height?: number;
  118326. sideOrientation?: number;
  118327. frontUVs?: Vector4;
  118328. backUVs?: Vector4;
  118329. updatable?: boolean;
  118330. sourcePlane?: Plane;
  118331. }, scene?: Nullable<Scene>): Mesh;
  118332. /**
  118333. * Creates a ground mesh
  118334. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118335. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118337. * @param name defines the name of the mesh
  118338. * @param options defines the options used to create the mesh
  118339. * @param scene defines the hosting scene
  118340. * @returns the ground mesh
  118341. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118342. */
  118343. static CreateGround(name: string, options: {
  118344. width?: number;
  118345. height?: number;
  118346. subdivisions?: number;
  118347. subdivisionsX?: number;
  118348. subdivisionsY?: number;
  118349. updatable?: boolean;
  118350. }, scene?: Nullable<Scene>): Mesh;
  118351. /**
  118352. * Creates a tiled ground mesh
  118353. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118354. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118355. * * 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
  118356. * * 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
  118357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118358. * @param name defines the name of the mesh
  118359. * @param options defines the options used to create the mesh
  118360. * @param scene defines the hosting scene
  118361. * @returns the tiled ground mesh
  118362. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118363. */
  118364. static CreateTiledGround(name: string, options: {
  118365. xmin: number;
  118366. zmin: number;
  118367. xmax: number;
  118368. zmax: number;
  118369. subdivisions?: {
  118370. w: number;
  118371. h: number;
  118372. };
  118373. precision?: {
  118374. w: number;
  118375. h: number;
  118376. };
  118377. updatable?: boolean;
  118378. }, scene?: Nullable<Scene>): Mesh;
  118379. /**
  118380. * Creates a ground mesh from a height map
  118381. * * The parameter `url` sets the URL of the height map image resource.
  118382. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118383. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118384. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118385. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118386. * * 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.
  118387. * * 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).
  118388. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118390. * @param name defines the name of the mesh
  118391. * @param url defines the url to the height map
  118392. * @param options defines the options used to create the mesh
  118393. * @param scene defines the hosting scene
  118394. * @returns the ground mesh
  118395. * @see https://doc.babylonjs.com/babylon101/height_map
  118396. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118397. */
  118398. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118399. width?: number;
  118400. height?: number;
  118401. subdivisions?: number;
  118402. minHeight?: number;
  118403. maxHeight?: number;
  118404. colorFilter?: Color3;
  118405. alphaFilter?: number;
  118406. updatable?: boolean;
  118407. onReady?: (mesh: GroundMesh) => void;
  118408. }, scene?: Nullable<Scene>): GroundMesh;
  118409. /**
  118410. * Creates a polygon mesh
  118411. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118412. * * 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
  118413. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118416. * * Remember you can only change the shape positions, not their number when updating a polygon
  118417. * @param name defines the name of the mesh
  118418. * @param options defines the options used to create the mesh
  118419. * @param scene defines the hosting scene
  118420. * @param earcutInjection can be used to inject your own earcut reference
  118421. * @returns the polygon mesh
  118422. */
  118423. static CreatePolygon(name: string, options: {
  118424. shape: Vector3[];
  118425. holes?: Vector3[][];
  118426. depth?: number;
  118427. faceUV?: Vector4[];
  118428. faceColors?: Color4[];
  118429. updatable?: boolean;
  118430. sideOrientation?: number;
  118431. frontUVs?: Vector4;
  118432. backUVs?: Vector4;
  118433. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118434. /**
  118435. * Creates an extruded polygon mesh, with depth in the Y direction.
  118436. * * 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)
  118437. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118438. * @param name defines the name of the mesh
  118439. * @param options defines the options used to create the mesh
  118440. * @param scene defines the hosting scene
  118441. * @param earcutInjection can be used to inject your own earcut reference
  118442. * @returns the polygon mesh
  118443. */
  118444. static ExtrudePolygon(name: string, options: {
  118445. shape: Vector3[];
  118446. holes?: Vector3[][];
  118447. depth?: number;
  118448. faceUV?: Vector4[];
  118449. faceColors?: Color4[];
  118450. updatable?: boolean;
  118451. sideOrientation?: number;
  118452. frontUVs?: Vector4;
  118453. backUVs?: Vector4;
  118454. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118455. /**
  118456. * Creates a tube mesh.
  118457. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118458. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118459. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118460. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118461. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118462. * * 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)
  118463. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118464. * * 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
  118465. * * 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
  118466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118468. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118470. * @param name defines the name of the mesh
  118471. * @param options defines the options used to create the mesh
  118472. * @param scene defines the hosting scene
  118473. * @returns the tube mesh
  118474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118475. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118476. */
  118477. static CreateTube(name: string, options: {
  118478. path: Vector3[];
  118479. radius?: number;
  118480. tessellation?: number;
  118481. radiusFunction?: {
  118482. (i: number, distance: number): number;
  118483. };
  118484. cap?: number;
  118485. arc?: number;
  118486. updatable?: boolean;
  118487. sideOrientation?: number;
  118488. frontUVs?: Vector4;
  118489. backUVs?: Vector4;
  118490. instance?: Mesh;
  118491. invertUV?: boolean;
  118492. }, scene?: Nullable<Scene>): Mesh;
  118493. /**
  118494. * Creates a polyhedron mesh
  118495. * * 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
  118496. * * The parameter `size` (positive float, default 1) sets the polygon size
  118497. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118498. * * 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`
  118499. * * 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
  118500. * * 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)`)
  118501. * * 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
  118502. * * 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
  118503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118506. * @param name defines the name of the mesh
  118507. * @param options defines the options used to create the mesh
  118508. * @param scene defines the hosting scene
  118509. * @returns the polyhedron mesh
  118510. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  118511. */
  118512. static CreatePolyhedron(name: string, options: {
  118513. type?: number;
  118514. size?: number;
  118515. sizeX?: number;
  118516. sizeY?: number;
  118517. sizeZ?: number;
  118518. custom?: any;
  118519. faceUV?: Vector4[];
  118520. faceColors?: Color4[];
  118521. flat?: boolean;
  118522. updatable?: boolean;
  118523. sideOrientation?: number;
  118524. frontUVs?: Vector4;
  118525. backUVs?: Vector4;
  118526. }, scene?: Nullable<Scene>): Mesh;
  118527. /**
  118528. * Creates a decal mesh.
  118529. * 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
  118530. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118531. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118532. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118533. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118534. * @param name defines the name of the mesh
  118535. * @param sourceMesh defines the mesh where the decal must be applied
  118536. * @param options defines the options used to create the mesh
  118537. * @param scene defines the hosting scene
  118538. * @returns the decal mesh
  118539. * @see https://doc.babylonjs.com/how_to/decals
  118540. */
  118541. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118542. position?: Vector3;
  118543. normal?: Vector3;
  118544. size?: Vector3;
  118545. angle?: number;
  118546. }): Mesh;
  118547. }
  118548. }
  118549. declare module BABYLON {
  118550. /**
  118551. * A simplifier interface for future simplification implementations
  118552. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118553. */
  118554. export interface ISimplifier {
  118555. /**
  118556. * Simplification of a given mesh according to the given settings.
  118557. * Since this requires computation, it is assumed that the function runs async.
  118558. * @param settings The settings of the simplification, including quality and distance
  118559. * @param successCallback A callback that will be called after the mesh was simplified.
  118560. * @param errorCallback in case of an error, this callback will be called. optional.
  118561. */
  118562. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  118563. }
  118564. /**
  118565. * Expected simplification settings.
  118566. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  118567. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118568. */
  118569. export interface ISimplificationSettings {
  118570. /**
  118571. * Gets or sets the expected quality
  118572. */
  118573. quality: number;
  118574. /**
  118575. * Gets or sets the distance when this optimized version should be used
  118576. */
  118577. distance: number;
  118578. /**
  118579. * Gets an already optimized mesh
  118580. */
  118581. optimizeMesh?: boolean;
  118582. }
  118583. /**
  118584. * Class used to specify simplification options
  118585. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118586. */
  118587. export class SimplificationSettings implements ISimplificationSettings {
  118588. /** expected quality */
  118589. quality: number;
  118590. /** distance when this optimized version should be used */
  118591. distance: number;
  118592. /** already optimized mesh */
  118593. optimizeMesh?: boolean | undefined;
  118594. /**
  118595. * Creates a SimplificationSettings
  118596. * @param quality expected quality
  118597. * @param distance distance when this optimized version should be used
  118598. * @param optimizeMesh already optimized mesh
  118599. */
  118600. constructor(
  118601. /** expected quality */
  118602. quality: number,
  118603. /** distance when this optimized version should be used */
  118604. distance: number,
  118605. /** already optimized mesh */
  118606. optimizeMesh?: boolean | undefined);
  118607. }
  118608. /**
  118609. * Interface used to define a simplification task
  118610. */
  118611. export interface ISimplificationTask {
  118612. /**
  118613. * Array of settings
  118614. */
  118615. settings: Array<ISimplificationSettings>;
  118616. /**
  118617. * Simplification type
  118618. */
  118619. simplificationType: SimplificationType;
  118620. /**
  118621. * Mesh to simplify
  118622. */
  118623. mesh: Mesh;
  118624. /**
  118625. * Callback called on success
  118626. */
  118627. successCallback?: () => void;
  118628. /**
  118629. * Defines if parallel processing can be used
  118630. */
  118631. parallelProcessing: boolean;
  118632. }
  118633. /**
  118634. * Queue used to order the simplification tasks
  118635. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118636. */
  118637. export class SimplificationQueue {
  118638. private _simplificationArray;
  118639. /**
  118640. * Gets a boolean indicating that the process is still running
  118641. */
  118642. running: boolean;
  118643. /**
  118644. * Creates a new queue
  118645. */
  118646. constructor();
  118647. /**
  118648. * Adds a new simplification task
  118649. * @param task defines a task to add
  118650. */
  118651. addTask(task: ISimplificationTask): void;
  118652. /**
  118653. * Execute next task
  118654. */
  118655. executeNext(): void;
  118656. /**
  118657. * Execute a simplification task
  118658. * @param task defines the task to run
  118659. */
  118660. runSimplification(task: ISimplificationTask): void;
  118661. private getSimplifier;
  118662. }
  118663. /**
  118664. * The implemented types of simplification
  118665. * At the moment only Quadratic Error Decimation is implemented
  118666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118667. */
  118668. export enum SimplificationType {
  118669. /** Quadratic error decimation */
  118670. QUADRATIC = 0
  118671. }
  118672. }
  118673. declare module BABYLON {
  118674. interface Scene {
  118675. /** @hidden (Backing field) */
  118676. _simplificationQueue: SimplificationQueue;
  118677. /**
  118678. * Gets or sets the simplification queue attached to the scene
  118679. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118680. */
  118681. simplificationQueue: SimplificationQueue;
  118682. }
  118683. interface Mesh {
  118684. /**
  118685. * Simplify the mesh according to the given array of settings.
  118686. * Function will return immediately and will simplify async
  118687. * @param settings a collection of simplification settings
  118688. * @param parallelProcessing should all levels calculate parallel or one after the other
  118689. * @param simplificationType the type of simplification to run
  118690. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  118691. * @returns the current mesh
  118692. */
  118693. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  118694. }
  118695. /**
  118696. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  118697. * created in a scene
  118698. */
  118699. export class SimplicationQueueSceneComponent implements ISceneComponent {
  118700. /**
  118701. * The component name helpfull to identify the component in the list of scene components.
  118702. */
  118703. readonly name: string;
  118704. /**
  118705. * The scene the component belongs to.
  118706. */
  118707. scene: Scene;
  118708. /**
  118709. * Creates a new instance of the component for the given scene
  118710. * @param scene Defines the scene to register the component in
  118711. */
  118712. constructor(scene: Scene);
  118713. /**
  118714. * Registers the component in a given scene
  118715. */
  118716. register(): void;
  118717. /**
  118718. * Rebuilds the elements related to this component in case of
  118719. * context lost for instance.
  118720. */
  118721. rebuild(): void;
  118722. /**
  118723. * Disposes the component and the associated ressources
  118724. */
  118725. dispose(): void;
  118726. private _beforeCameraUpdate;
  118727. }
  118728. }
  118729. declare module BABYLON {
  118730. /**
  118731. * Navigation plugin interface to add navigation constrained by a navigation mesh
  118732. */
  118733. export interface INavigationEnginePlugin {
  118734. /**
  118735. * plugin name
  118736. */
  118737. name: string;
  118738. /**
  118739. * Creates a navigation mesh
  118740. * @param meshes array of all the geometry used to compute the navigatio mesh
  118741. * @param parameters bunch of parameters used to filter geometry
  118742. */
  118743. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118744. /**
  118745. * Create a navigation mesh debug mesh
  118746. * @param scene is where the mesh will be added
  118747. * @returns debug display mesh
  118748. */
  118749. createDebugNavMesh(scene: Scene): Mesh;
  118750. /**
  118751. * Get a navigation mesh constrained position, closest to the parameter position
  118752. * @param position world position
  118753. * @returns the closest point to position constrained by the navigation mesh
  118754. */
  118755. getClosestPoint(position: Vector3): Vector3;
  118756. /**
  118757. * Get a navigation mesh constrained position, within a particular radius
  118758. * @param position world position
  118759. * @param maxRadius the maximum distance to the constrained world position
  118760. * @returns the closest point to position constrained by the navigation mesh
  118761. */
  118762. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118763. /**
  118764. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118765. * @param start world position
  118766. * @param end world position
  118767. * @returns array containing world position composing the path
  118768. */
  118769. computePath(start: Vector3, end: Vector3): Vector3[];
  118770. /**
  118771. * If this plugin is supported
  118772. * @returns true if plugin is supported
  118773. */
  118774. isSupported(): boolean;
  118775. /**
  118776. * Create a new Crowd so you can add agents
  118777. * @param maxAgents the maximum agent count in the crowd
  118778. * @param maxAgentRadius the maximum radius an agent can have
  118779. * @param scene to attach the crowd to
  118780. * @returns the crowd you can add agents to
  118781. */
  118782. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118783. /**
  118784. * Release all resources
  118785. */
  118786. dispose(): void;
  118787. }
  118788. /**
  118789. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  118790. */
  118791. export interface ICrowd {
  118792. /**
  118793. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118794. * You can attach anything to that node. The node position is updated in the scene update tick.
  118795. * @param pos world position that will be constrained by the navigation mesh
  118796. * @param parameters agent parameters
  118797. * @param transform hooked to the agent that will be update by the scene
  118798. * @returns agent index
  118799. */
  118800. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118801. /**
  118802. * Returns the agent position in world space
  118803. * @param index agent index returned by addAgent
  118804. * @returns world space position
  118805. */
  118806. getAgentPosition(index: number): Vector3;
  118807. /**
  118808. * Gets the agent velocity in world space
  118809. * @param index agent index returned by addAgent
  118810. * @returns world space velocity
  118811. */
  118812. getAgentVelocity(index: number): Vector3;
  118813. /**
  118814. * remove a particular agent previously created
  118815. * @param index agent index returned by addAgent
  118816. */
  118817. removeAgent(index: number): void;
  118818. /**
  118819. * get the list of all agents attached to this crowd
  118820. * @returns list of agent indices
  118821. */
  118822. getAgents(): number[];
  118823. /**
  118824. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118825. * @param deltaTime in seconds
  118826. */
  118827. update(deltaTime: number): void;
  118828. /**
  118829. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118830. * @param index agent index returned by addAgent
  118831. * @param destination targeted world position
  118832. */
  118833. agentGoto(index: number, destination: Vector3): void;
  118834. /**
  118835. * Release all resources
  118836. */
  118837. dispose(): void;
  118838. }
  118839. /**
  118840. * Configures an agent
  118841. */
  118842. export interface IAgentParameters {
  118843. /**
  118844. * Agent radius. [Limit: >= 0]
  118845. */
  118846. radius: number;
  118847. /**
  118848. * Agent height. [Limit: > 0]
  118849. */
  118850. height: number;
  118851. /**
  118852. * Maximum allowed acceleration. [Limit: >= 0]
  118853. */
  118854. maxAcceleration: number;
  118855. /**
  118856. * Maximum allowed speed. [Limit: >= 0]
  118857. */
  118858. maxSpeed: number;
  118859. /**
  118860. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  118861. */
  118862. collisionQueryRange: number;
  118863. /**
  118864. * The path visibility optimization range. [Limit: > 0]
  118865. */
  118866. pathOptimizationRange: number;
  118867. /**
  118868. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  118869. */
  118870. separationWeight: number;
  118871. }
  118872. /**
  118873. * Configures the navigation mesh creation
  118874. */
  118875. export interface INavMeshParameters {
  118876. /**
  118877. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  118878. */
  118879. cs: number;
  118880. /**
  118881. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  118882. */
  118883. ch: number;
  118884. /**
  118885. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  118886. */
  118887. walkableSlopeAngle: number;
  118888. /**
  118889. * Minimum floor to 'ceiling' height that will still allow the floor area to
  118890. * be considered walkable. [Limit: >= 3] [Units: vx]
  118891. */
  118892. walkableHeight: number;
  118893. /**
  118894. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  118895. */
  118896. walkableClimb: number;
  118897. /**
  118898. * The distance to erode/shrink the walkable area of the heightfield away from
  118899. * obstructions. [Limit: >=0] [Units: vx]
  118900. */
  118901. walkableRadius: number;
  118902. /**
  118903. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  118904. */
  118905. maxEdgeLen: number;
  118906. /**
  118907. * The maximum distance a simplfied contour's border edges should deviate
  118908. * the original raw contour. [Limit: >=0] [Units: vx]
  118909. */
  118910. maxSimplificationError: number;
  118911. /**
  118912. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  118913. */
  118914. minRegionArea: number;
  118915. /**
  118916. * Any regions with a span count smaller than this value will, if possible,
  118917. * be merged with larger regions. [Limit: >=0] [Units: vx]
  118918. */
  118919. mergeRegionArea: number;
  118920. /**
  118921. * The maximum number of vertices allowed for polygons generated during the
  118922. * contour to polygon conversion process. [Limit: >= 3]
  118923. */
  118924. maxVertsPerPoly: number;
  118925. /**
  118926. * Sets the sampling distance to use when generating the detail mesh.
  118927. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  118928. */
  118929. detailSampleDist: number;
  118930. /**
  118931. * The maximum distance the detail mesh surface should deviate from heightfield
  118932. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  118933. */
  118934. detailSampleMaxError: number;
  118935. }
  118936. }
  118937. declare module BABYLON {
  118938. /**
  118939. * RecastJS navigation plugin
  118940. */
  118941. export class RecastJSPlugin implements INavigationEnginePlugin {
  118942. /**
  118943. * Reference to the Recast library
  118944. */
  118945. bjsRECAST: any;
  118946. /**
  118947. * plugin name
  118948. */
  118949. name: string;
  118950. /**
  118951. * the first navmesh created. We might extend this to support multiple navmeshes
  118952. */
  118953. navMesh: any;
  118954. /**
  118955. * Initializes the recastJS plugin
  118956. * @param recastInjection can be used to inject your own recast reference
  118957. */
  118958. constructor(recastInjection?: any);
  118959. /**
  118960. * Creates a navigation mesh
  118961. * @param meshes array of all the geometry used to compute the navigatio mesh
  118962. * @param parameters bunch of parameters used to filter geometry
  118963. */
  118964. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118965. /**
  118966. * Create a navigation mesh debug mesh
  118967. * @param scene is where the mesh will be added
  118968. * @returns debug display mesh
  118969. */
  118970. createDebugNavMesh(scene: Scene): Mesh;
  118971. /**
  118972. * Get a navigation mesh constrained position, closest to the parameter position
  118973. * @param position world position
  118974. * @returns the closest point to position constrained by the navigation mesh
  118975. */
  118976. getClosestPoint(position: Vector3): Vector3;
  118977. /**
  118978. * Get a navigation mesh constrained position, within a particular radius
  118979. * @param position world position
  118980. * @param maxRadius the maximum distance to the constrained world position
  118981. * @returns the closest point to position constrained by the navigation mesh
  118982. */
  118983. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118984. /**
  118985. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118986. * @param start world position
  118987. * @param end world position
  118988. * @returns array containing world position composing the path
  118989. */
  118990. computePath(start: Vector3, end: Vector3): Vector3[];
  118991. /**
  118992. * Create a new Crowd so you can add agents
  118993. * @param maxAgents the maximum agent count in the crowd
  118994. * @param maxAgentRadius the maximum radius an agent can have
  118995. * @param scene to attach the crowd to
  118996. * @returns the crowd you can add agents to
  118997. */
  118998. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118999. /**
  119000. * Disposes
  119001. */
  119002. dispose(): void;
  119003. /**
  119004. * If this plugin is supported
  119005. * @returns true if plugin is supported
  119006. */
  119007. isSupported(): boolean;
  119008. }
  119009. /**
  119010. * Recast detour crowd implementation
  119011. */
  119012. export class RecastJSCrowd implements ICrowd {
  119013. /**
  119014. * Recast/detour plugin
  119015. */
  119016. bjsRECASTPlugin: RecastJSPlugin;
  119017. /**
  119018. * Link to the detour crowd
  119019. */
  119020. recastCrowd: any;
  119021. /**
  119022. * One transform per agent
  119023. */
  119024. transforms: TransformNode[];
  119025. /**
  119026. * All agents created
  119027. */
  119028. agents: number[];
  119029. /**
  119030. * Link to the scene is kept to unregister the crowd from the scene
  119031. */
  119032. private _scene;
  119033. /**
  119034. * Observer for crowd updates
  119035. */
  119036. private _onBeforeAnimationsObserver;
  119037. /**
  119038. * Constructor
  119039. * @param plugin recastJS plugin
  119040. * @param maxAgents the maximum agent count in the crowd
  119041. * @param maxAgentRadius the maximum radius an agent can have
  119042. * @param scene to attach the crowd to
  119043. * @returns the crowd you can add agents to
  119044. */
  119045. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  119046. /**
  119047. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119048. * You can attach anything to that node. The node position is updated in the scene update tick.
  119049. * @param pos world position that will be constrained by the navigation mesh
  119050. * @param parameters agent parameters
  119051. * @param transform hooked to the agent that will be update by the scene
  119052. * @returns agent index
  119053. */
  119054. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119055. /**
  119056. * Returns the agent position in world space
  119057. * @param index agent index returned by addAgent
  119058. * @returns world space position
  119059. */
  119060. getAgentPosition(index: number): Vector3;
  119061. /**
  119062. * Returns the agent velocity in world space
  119063. * @param index agent index returned by addAgent
  119064. * @returns world space velocity
  119065. */
  119066. getAgentVelocity(index: number): Vector3;
  119067. /**
  119068. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119069. * @param index agent index returned by addAgent
  119070. * @param destination targeted world position
  119071. */
  119072. agentGoto(index: number, destination: Vector3): void;
  119073. /**
  119074. * remove a particular agent previously created
  119075. * @param index agent index returned by addAgent
  119076. */
  119077. removeAgent(index: number): void;
  119078. /**
  119079. * get the list of all agents attached to this crowd
  119080. * @returns list of agent indices
  119081. */
  119082. getAgents(): number[];
  119083. /**
  119084. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119085. * @param deltaTime in seconds
  119086. */
  119087. update(deltaTime: number): void;
  119088. /**
  119089. * Release all resources
  119090. */
  119091. dispose(): void;
  119092. }
  119093. }
  119094. declare module BABYLON {
  119095. /**
  119096. * Class used to enable access to IndexedDB
  119097. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119098. */
  119099. export class Database implements IOfflineProvider {
  119100. private _callbackManifestChecked;
  119101. private _currentSceneUrl;
  119102. private _db;
  119103. private _enableSceneOffline;
  119104. private _enableTexturesOffline;
  119105. private _manifestVersionFound;
  119106. private _mustUpdateRessources;
  119107. private _hasReachedQuota;
  119108. private _isSupported;
  119109. private _idbFactory;
  119110. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  119111. private static IsUASupportingBlobStorage;
  119112. /**
  119113. * Gets a boolean indicating if Database storate is enabled (off by default)
  119114. */
  119115. static IDBStorageEnabled: boolean;
  119116. /**
  119117. * Gets a boolean indicating if scene must be saved in the database
  119118. */
  119119. readonly enableSceneOffline: boolean;
  119120. /**
  119121. * Gets a boolean indicating if textures must be saved in the database
  119122. */
  119123. readonly enableTexturesOffline: boolean;
  119124. /**
  119125. * Creates a new Database
  119126. * @param urlToScene defines the url to load the scene
  119127. * @param callbackManifestChecked defines the callback to use when manifest is checked
  119128. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  119129. */
  119130. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  119131. private static _ParseURL;
  119132. private static _ReturnFullUrlLocation;
  119133. private _checkManifestFile;
  119134. /**
  119135. * Open the database and make it available
  119136. * @param successCallback defines the callback to call on success
  119137. * @param errorCallback defines the callback to call on error
  119138. */
  119139. open(successCallback: () => void, errorCallback: () => void): void;
  119140. /**
  119141. * Loads an image from the database
  119142. * @param url defines the url to load from
  119143. * @param image defines the target DOM image
  119144. */
  119145. loadImage(url: string, image: HTMLImageElement): void;
  119146. private _loadImageFromDBAsync;
  119147. private _saveImageIntoDBAsync;
  119148. private _checkVersionFromDB;
  119149. private _loadVersionFromDBAsync;
  119150. private _saveVersionIntoDBAsync;
  119151. /**
  119152. * Loads a file from database
  119153. * @param url defines the URL to load from
  119154. * @param sceneLoaded defines a callback to call on success
  119155. * @param progressCallBack defines a callback to call when progress changed
  119156. * @param errorCallback defines a callback to call on error
  119157. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  119158. */
  119159. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  119160. private _loadFileAsync;
  119161. private _saveFileAsync;
  119162. /**
  119163. * Validates if xhr data is correct
  119164. * @param xhr defines the request to validate
  119165. * @param dataType defines the expected data type
  119166. * @returns true if data is correct
  119167. */
  119168. private static _ValidateXHRData;
  119169. }
  119170. }
  119171. declare module BABYLON {
  119172. /** @hidden */
  119173. export var gpuUpdateParticlesPixelShader: {
  119174. name: string;
  119175. shader: string;
  119176. };
  119177. }
  119178. declare module BABYLON {
  119179. /** @hidden */
  119180. export var gpuUpdateParticlesVertexShader: {
  119181. name: string;
  119182. shader: string;
  119183. };
  119184. }
  119185. declare module BABYLON {
  119186. /** @hidden */
  119187. export var clipPlaneFragmentDeclaration2: {
  119188. name: string;
  119189. shader: string;
  119190. };
  119191. }
  119192. declare module BABYLON {
  119193. /** @hidden */
  119194. export var gpuRenderParticlesPixelShader: {
  119195. name: string;
  119196. shader: string;
  119197. };
  119198. }
  119199. declare module BABYLON {
  119200. /** @hidden */
  119201. export var clipPlaneVertexDeclaration2: {
  119202. name: string;
  119203. shader: string;
  119204. };
  119205. }
  119206. declare module BABYLON {
  119207. /** @hidden */
  119208. export var gpuRenderParticlesVertexShader: {
  119209. name: string;
  119210. shader: string;
  119211. };
  119212. }
  119213. declare module BABYLON {
  119214. /**
  119215. * This represents a GPU particle system in Babylon
  119216. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  119217. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  119218. */
  119219. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  119220. /**
  119221. * The layer mask we are rendering the particles through.
  119222. */
  119223. layerMask: number;
  119224. private _capacity;
  119225. private _activeCount;
  119226. private _currentActiveCount;
  119227. private _accumulatedCount;
  119228. private _renderEffect;
  119229. private _updateEffect;
  119230. private _buffer0;
  119231. private _buffer1;
  119232. private _spriteBuffer;
  119233. private _updateVAO;
  119234. private _renderVAO;
  119235. private _targetIndex;
  119236. private _sourceBuffer;
  119237. private _targetBuffer;
  119238. private _engine;
  119239. private _currentRenderId;
  119240. private _started;
  119241. private _stopped;
  119242. private _timeDelta;
  119243. private _randomTexture;
  119244. private _randomTexture2;
  119245. private _attributesStrideSize;
  119246. private _updateEffectOptions;
  119247. private _randomTextureSize;
  119248. private _actualFrame;
  119249. private readonly _rawTextureWidth;
  119250. /**
  119251. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  119252. */
  119253. static readonly IsSupported: boolean;
  119254. /**
  119255. * An event triggered when the system is disposed.
  119256. */
  119257. onDisposeObservable: Observable<GPUParticleSystem>;
  119258. /**
  119259. * Gets the maximum number of particles active at the same time.
  119260. * @returns The max number of active particles.
  119261. */
  119262. getCapacity(): number;
  119263. /**
  119264. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  119265. * to override the particles.
  119266. */
  119267. forceDepthWrite: boolean;
  119268. /**
  119269. * Gets or set the number of active particles
  119270. */
  119271. activeParticleCount: number;
  119272. private _preWarmDone;
  119273. /**
  119274. * Is this system ready to be used/rendered
  119275. * @return true if the system is ready
  119276. */
  119277. isReady(): boolean;
  119278. /**
  119279. * Gets if the system has been started. (Note: this will still be true after stop is called)
  119280. * @returns True if it has been started, otherwise false.
  119281. */
  119282. isStarted(): boolean;
  119283. /**
  119284. * Starts the particle system and begins to emit
  119285. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  119286. */
  119287. start(delay?: number): void;
  119288. /**
  119289. * Stops the particle system.
  119290. */
  119291. stop(): void;
  119292. /**
  119293. * Remove all active particles
  119294. */
  119295. reset(): void;
  119296. /**
  119297. * Returns the string "GPUParticleSystem"
  119298. * @returns a string containing the class name
  119299. */
  119300. getClassName(): string;
  119301. private _colorGradientsTexture;
  119302. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  119303. /**
  119304. * Adds a new color gradient
  119305. * @param gradient defines the gradient to use (between 0 and 1)
  119306. * @param color1 defines the color to affect to the specified gradient
  119307. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  119308. * @returns the current particle system
  119309. */
  119310. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  119311. /**
  119312. * Remove a specific color gradient
  119313. * @param gradient defines the gradient to remove
  119314. * @returns the current particle system
  119315. */
  119316. removeColorGradient(gradient: number): GPUParticleSystem;
  119317. private _angularSpeedGradientsTexture;
  119318. private _sizeGradientsTexture;
  119319. private _velocityGradientsTexture;
  119320. private _limitVelocityGradientsTexture;
  119321. private _dragGradientsTexture;
  119322. private _addFactorGradient;
  119323. /**
  119324. * Adds a new size gradient
  119325. * @param gradient defines the gradient to use (between 0 and 1)
  119326. * @param factor defines the size factor to affect to the specified gradient
  119327. * @returns the current particle system
  119328. */
  119329. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  119330. /**
  119331. * Remove a specific size gradient
  119332. * @param gradient defines the gradient to remove
  119333. * @returns the current particle system
  119334. */
  119335. removeSizeGradient(gradient: number): GPUParticleSystem;
  119336. /**
  119337. * Adds a new angular speed gradient
  119338. * @param gradient defines the gradient to use (between 0 and 1)
  119339. * @param factor defines the angular speed to affect to the specified gradient
  119340. * @returns the current particle system
  119341. */
  119342. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  119343. /**
  119344. * Remove a specific angular speed gradient
  119345. * @param gradient defines the gradient to remove
  119346. * @returns the current particle system
  119347. */
  119348. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  119349. /**
  119350. * Adds a new velocity gradient
  119351. * @param gradient defines the gradient to use (between 0 and 1)
  119352. * @param factor defines the velocity to affect to the specified gradient
  119353. * @returns the current particle system
  119354. */
  119355. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119356. /**
  119357. * Remove a specific velocity gradient
  119358. * @param gradient defines the gradient to remove
  119359. * @returns the current particle system
  119360. */
  119361. removeVelocityGradient(gradient: number): GPUParticleSystem;
  119362. /**
  119363. * Adds a new limit velocity gradient
  119364. * @param gradient defines the gradient to use (between 0 and 1)
  119365. * @param factor defines the limit velocity value to affect to the specified gradient
  119366. * @returns the current particle system
  119367. */
  119368. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119369. /**
  119370. * Remove a specific limit velocity gradient
  119371. * @param gradient defines the gradient to remove
  119372. * @returns the current particle system
  119373. */
  119374. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  119375. /**
  119376. * Adds a new drag gradient
  119377. * @param gradient defines the gradient to use (between 0 and 1)
  119378. * @param factor defines the drag value to affect to the specified gradient
  119379. * @returns the current particle system
  119380. */
  119381. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  119382. /**
  119383. * Remove a specific drag gradient
  119384. * @param gradient defines the gradient to remove
  119385. * @returns the current particle system
  119386. */
  119387. removeDragGradient(gradient: number): GPUParticleSystem;
  119388. /**
  119389. * Not supported by GPUParticleSystem
  119390. * @param gradient defines the gradient to use (between 0 and 1)
  119391. * @param factor defines the emit rate value to affect to the specified gradient
  119392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119393. * @returns the current particle system
  119394. */
  119395. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119396. /**
  119397. * Not supported by GPUParticleSystem
  119398. * @param gradient defines the gradient to remove
  119399. * @returns the current particle system
  119400. */
  119401. removeEmitRateGradient(gradient: number): IParticleSystem;
  119402. /**
  119403. * Not supported by GPUParticleSystem
  119404. * @param gradient defines the gradient to use (between 0 and 1)
  119405. * @param factor defines the start size value to affect to the specified gradient
  119406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119407. * @returns the current particle system
  119408. */
  119409. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119410. /**
  119411. * Not supported by GPUParticleSystem
  119412. * @param gradient defines the gradient to remove
  119413. * @returns the current particle system
  119414. */
  119415. removeStartSizeGradient(gradient: number): IParticleSystem;
  119416. /**
  119417. * Not supported by GPUParticleSystem
  119418. * @param gradient defines the gradient to use (between 0 and 1)
  119419. * @param min defines the color remap minimal range
  119420. * @param max defines the color remap maximal range
  119421. * @returns the current particle system
  119422. */
  119423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119424. /**
  119425. * Not supported by GPUParticleSystem
  119426. * @param gradient defines the gradient to remove
  119427. * @returns the current particle system
  119428. */
  119429. removeColorRemapGradient(): IParticleSystem;
  119430. /**
  119431. * Not supported by GPUParticleSystem
  119432. * @param gradient defines the gradient to use (between 0 and 1)
  119433. * @param min defines the alpha remap minimal range
  119434. * @param max defines the alpha remap maximal range
  119435. * @returns the current particle system
  119436. */
  119437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119438. /**
  119439. * Not supported by GPUParticleSystem
  119440. * @param gradient defines the gradient to remove
  119441. * @returns the current particle system
  119442. */
  119443. removeAlphaRemapGradient(): IParticleSystem;
  119444. /**
  119445. * Not supported by GPUParticleSystem
  119446. * @param gradient defines the gradient to use (between 0 and 1)
  119447. * @param color defines the color to affect to the specified gradient
  119448. * @returns the current particle system
  119449. */
  119450. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119451. /**
  119452. * Not supported by GPUParticleSystem
  119453. * @param gradient defines the gradient to remove
  119454. * @returns the current particle system
  119455. */
  119456. removeRampGradient(): IParticleSystem;
  119457. /**
  119458. * Not supported by GPUParticleSystem
  119459. * @returns the list of ramp gradients
  119460. */
  119461. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119462. /**
  119463. * Not supported by GPUParticleSystem
  119464. * Gets or sets a boolean indicating that ramp gradients must be used
  119465. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119466. */
  119467. useRampGradients: boolean;
  119468. /**
  119469. * Not supported by GPUParticleSystem
  119470. * @param gradient defines the gradient to use (between 0 and 1)
  119471. * @param factor defines the life time factor to affect to the specified gradient
  119472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119473. * @returns the current particle system
  119474. */
  119475. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119476. /**
  119477. * Not supported by GPUParticleSystem
  119478. * @param gradient defines the gradient to remove
  119479. * @returns the current particle system
  119480. */
  119481. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119482. /**
  119483. * Instantiates a GPU particle system.
  119484. * 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.
  119485. * @param name The name of the particle system
  119486. * @param options The options used to create the system
  119487. * @param scene The scene the particle system belongs to
  119488. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119489. */
  119490. constructor(name: string, options: Partial<{
  119491. capacity: number;
  119492. randomTextureSize: number;
  119493. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119494. protected _reset(): void;
  119495. private _createUpdateVAO;
  119496. private _createRenderVAO;
  119497. private _initialize;
  119498. /** @hidden */
  119499. _recreateUpdateEffect(): void;
  119500. /** @hidden */
  119501. _recreateRenderEffect(): void;
  119502. /**
  119503. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119504. * @param preWarm defines if we are in the pre-warmimg phase
  119505. */
  119506. animate(preWarm?: boolean): void;
  119507. private _createFactorGradientTexture;
  119508. private _createSizeGradientTexture;
  119509. private _createAngularSpeedGradientTexture;
  119510. private _createVelocityGradientTexture;
  119511. private _createLimitVelocityGradientTexture;
  119512. private _createDragGradientTexture;
  119513. private _createColorGradientTexture;
  119514. /**
  119515. * Renders the particle system in its current state
  119516. * @param preWarm defines if the system should only update the particles but not render them
  119517. * @returns the current number of particles
  119518. */
  119519. render(preWarm?: boolean): number;
  119520. /**
  119521. * Rebuilds the particle system
  119522. */
  119523. rebuild(): void;
  119524. private _releaseBuffers;
  119525. private _releaseVAOs;
  119526. /**
  119527. * Disposes the particle system and free the associated resources
  119528. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  119529. */
  119530. dispose(disposeTexture?: boolean): void;
  119531. /**
  119532. * Clones the particle system.
  119533. * @param name The name of the cloned object
  119534. * @param newEmitter The new emitter to use
  119535. * @returns the cloned particle system
  119536. */
  119537. clone(name: string, newEmitter: any): GPUParticleSystem;
  119538. /**
  119539. * Serializes the particle system to a JSON object.
  119540. * @returns the JSON object
  119541. */
  119542. serialize(): any;
  119543. /**
  119544. * Parses a JSON object to create a GPU particle system.
  119545. * @param parsedParticleSystem The JSON object to parse
  119546. * @param scene The scene to create the particle system in
  119547. * @param rootUrl The root url to use to load external dependencies like texture
  119548. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  119549. * @returns the parsed GPU particle system
  119550. */
  119551. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  119552. }
  119553. }
  119554. declare module BABYLON {
  119555. /**
  119556. * Represents a set of particle systems working together to create a specific effect
  119557. */
  119558. export class ParticleSystemSet implements IDisposable {
  119559. private _emitterCreationOptions;
  119560. private _emitterNode;
  119561. /**
  119562. * Gets the particle system list
  119563. */
  119564. systems: IParticleSystem[];
  119565. /**
  119566. * Gets the emitter node used with this set
  119567. */
  119568. readonly emitterNode: Nullable<TransformNode>;
  119569. /**
  119570. * Creates a new emitter mesh as a sphere
  119571. * @param options defines the options used to create the sphere
  119572. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  119573. * @param scene defines the hosting scene
  119574. */
  119575. setEmitterAsSphere(options: {
  119576. diameter: number;
  119577. segments: number;
  119578. color: Color3;
  119579. }, renderingGroupId: number, scene: Scene): void;
  119580. /**
  119581. * Starts all particle systems of the set
  119582. * @param emitter defines an optional mesh to use as emitter for the particle systems
  119583. */
  119584. start(emitter?: AbstractMesh): void;
  119585. /**
  119586. * Release all associated resources
  119587. */
  119588. dispose(): void;
  119589. /**
  119590. * Serialize the set into a JSON compatible object
  119591. * @returns a JSON compatible representation of the set
  119592. */
  119593. serialize(): any;
  119594. /**
  119595. * Parse a new ParticleSystemSet from a serialized source
  119596. * @param data defines a JSON compatible representation of the set
  119597. * @param scene defines the hosting scene
  119598. * @param gpu defines if we want GPU particles or CPU particles
  119599. * @returns a new ParticleSystemSet
  119600. */
  119601. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  119602. }
  119603. }
  119604. declare module BABYLON {
  119605. /**
  119606. * This class is made for on one-liner static method to help creating particle system set.
  119607. */
  119608. export class ParticleHelper {
  119609. /**
  119610. * Gets or sets base Assets URL
  119611. */
  119612. static BaseAssetsUrl: string;
  119613. /**
  119614. * Create a default particle system that you can tweak
  119615. * @param emitter defines the emitter to use
  119616. * @param capacity defines the system capacity (default is 500 particles)
  119617. * @param scene defines the hosting scene
  119618. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  119619. * @returns the new Particle system
  119620. */
  119621. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  119622. /**
  119623. * This is the main static method (one-liner) of this helper to create different particle systems
  119624. * @param type This string represents the type to the particle system to create
  119625. * @param scene The scene where the particle system should live
  119626. * @param gpu If the system will use gpu
  119627. * @returns the ParticleSystemSet created
  119628. */
  119629. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  119630. /**
  119631. * Static function used to export a particle system to a ParticleSystemSet variable.
  119632. * Please note that the emitter shape is not exported
  119633. * @param systems defines the particle systems to export
  119634. * @returns the created particle system set
  119635. */
  119636. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  119637. }
  119638. }
  119639. declare module BABYLON {
  119640. interface Engine {
  119641. /**
  119642. * Create an effect to use with particle systems.
  119643. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  119644. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  119645. * @param uniformsNames defines a list of attribute names
  119646. * @param samplers defines an array of string used to represent textures
  119647. * @param defines defines the string containing the defines to use to compile the shaders
  119648. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119649. * @param onCompiled defines a function to call when the effect creation is successful
  119650. * @param onError defines a function to call when the effect creation has failed
  119651. * @returns the new Effect
  119652. */
  119653. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  119654. }
  119655. interface Mesh {
  119656. /**
  119657. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  119658. * @returns an array of IParticleSystem
  119659. */
  119660. getEmittedParticleSystems(): IParticleSystem[];
  119661. /**
  119662. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  119663. * @returns an array of IParticleSystem
  119664. */
  119665. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  119666. }
  119667. /**
  119668. * @hidden
  119669. */
  119670. export var _IDoNeedToBeInTheBuild: number;
  119671. }
  119672. declare module BABYLON {
  119673. interface Scene {
  119674. /** @hidden (Backing field) */
  119675. _physicsEngine: Nullable<IPhysicsEngine>;
  119676. /**
  119677. * Gets the current physics engine
  119678. * @returns a IPhysicsEngine or null if none attached
  119679. */
  119680. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  119681. /**
  119682. * Enables physics to the current scene
  119683. * @param gravity defines the scene's gravity for the physics engine
  119684. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  119685. * @return a boolean indicating if the physics engine was initialized
  119686. */
  119687. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  119688. /**
  119689. * Disables and disposes the physics engine associated with the scene
  119690. */
  119691. disablePhysicsEngine(): void;
  119692. /**
  119693. * Gets a boolean indicating if there is an active physics engine
  119694. * @returns a boolean indicating if there is an active physics engine
  119695. */
  119696. isPhysicsEnabled(): boolean;
  119697. /**
  119698. * Deletes a physics compound impostor
  119699. * @param compound defines the compound to delete
  119700. */
  119701. deleteCompoundImpostor(compound: any): void;
  119702. /**
  119703. * An event triggered when physic simulation is about to be run
  119704. */
  119705. onBeforePhysicsObservable: Observable<Scene>;
  119706. /**
  119707. * An event triggered when physic simulation has been done
  119708. */
  119709. onAfterPhysicsObservable: Observable<Scene>;
  119710. }
  119711. interface AbstractMesh {
  119712. /** @hidden */
  119713. _physicsImpostor: Nullable<PhysicsImpostor>;
  119714. /**
  119715. * Gets or sets impostor used for physic simulation
  119716. * @see http://doc.babylonjs.com/features/physics_engine
  119717. */
  119718. physicsImpostor: Nullable<PhysicsImpostor>;
  119719. /**
  119720. * Gets the current physics impostor
  119721. * @see http://doc.babylonjs.com/features/physics_engine
  119722. * @returns a physics impostor or null
  119723. */
  119724. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  119725. /** Apply a physic impulse to the mesh
  119726. * @param force defines the force to apply
  119727. * @param contactPoint defines where to apply the force
  119728. * @returns the current mesh
  119729. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119730. */
  119731. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  119732. /**
  119733. * Creates a physic joint between two meshes
  119734. * @param otherMesh defines the other mesh to use
  119735. * @param pivot1 defines the pivot to use on this mesh
  119736. * @param pivot2 defines the pivot to use on the other mesh
  119737. * @param options defines additional options (can be plugin dependent)
  119738. * @returns the current mesh
  119739. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  119740. */
  119741. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  119742. /** @hidden */
  119743. _disposePhysicsObserver: Nullable<Observer<Node>>;
  119744. }
  119745. /**
  119746. * Defines the physics engine scene component responsible to manage a physics engine
  119747. */
  119748. export class PhysicsEngineSceneComponent implements ISceneComponent {
  119749. /**
  119750. * The component name helpful to identify the component in the list of scene components.
  119751. */
  119752. readonly name: string;
  119753. /**
  119754. * The scene the component belongs to.
  119755. */
  119756. scene: Scene;
  119757. /**
  119758. * Creates a new instance of the component for the given scene
  119759. * @param scene Defines the scene to register the component in
  119760. */
  119761. constructor(scene: Scene);
  119762. /**
  119763. * Registers the component in a given scene
  119764. */
  119765. register(): void;
  119766. /**
  119767. * Rebuilds the elements related to this component in case of
  119768. * context lost for instance.
  119769. */
  119770. rebuild(): void;
  119771. /**
  119772. * Disposes the component and the associated ressources
  119773. */
  119774. dispose(): void;
  119775. }
  119776. }
  119777. declare module BABYLON {
  119778. /**
  119779. * A helper for physics simulations
  119780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119781. */
  119782. export class PhysicsHelper {
  119783. private _scene;
  119784. private _physicsEngine;
  119785. /**
  119786. * Initializes the Physics helper
  119787. * @param scene Babylon.js scene
  119788. */
  119789. constructor(scene: Scene);
  119790. /**
  119791. * Applies a radial explosion impulse
  119792. * @param origin the origin of the explosion
  119793. * @param radiusOrEventOptions the radius or the options of radial explosion
  119794. * @param strength the explosion strength
  119795. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119796. * @returns A physics radial explosion event, or null
  119797. */
  119798. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119799. /**
  119800. * Applies a radial explosion force
  119801. * @param origin the origin of the explosion
  119802. * @param radiusOrEventOptions the radius or the options of radial explosion
  119803. * @param strength the explosion strength
  119804. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119805. * @returns A physics radial explosion event, or null
  119806. */
  119807. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119808. /**
  119809. * Creates a gravitational field
  119810. * @param origin the origin of the explosion
  119811. * @param radiusOrEventOptions the radius or the options of radial explosion
  119812. * @param strength the explosion strength
  119813. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119814. * @returns A physics gravitational field event, or null
  119815. */
  119816. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  119817. /**
  119818. * Creates a physics updraft event
  119819. * @param origin the origin of the updraft
  119820. * @param radiusOrEventOptions the radius or the options of the updraft
  119821. * @param strength the strength of the updraft
  119822. * @param height the height of the updraft
  119823. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  119824. * @returns A physics updraft event, or null
  119825. */
  119826. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  119827. /**
  119828. * Creates a physics vortex event
  119829. * @param origin the of the vortex
  119830. * @param radiusOrEventOptions the radius or the options of the vortex
  119831. * @param strength the strength of the vortex
  119832. * @param height the height of the vortex
  119833. * @returns a Physics vortex event, or null
  119834. * A physics vortex event or null
  119835. */
  119836. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  119837. }
  119838. /**
  119839. * Represents a physics radial explosion event
  119840. */
  119841. class PhysicsRadialExplosionEvent {
  119842. private _scene;
  119843. private _options;
  119844. private _sphere;
  119845. private _dataFetched;
  119846. /**
  119847. * Initializes a radial explosioin event
  119848. * @param _scene BabylonJS scene
  119849. * @param _options The options for the vortex event
  119850. */
  119851. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  119852. /**
  119853. * Returns the data related to the radial explosion event (sphere).
  119854. * @returns The radial explosion event data
  119855. */
  119856. getData(): PhysicsRadialExplosionEventData;
  119857. /**
  119858. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119859. * @param impostor A physics imposter
  119860. * @param origin the origin of the explosion
  119861. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119862. */
  119863. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  119864. /**
  119865. * Triggers affecterd impostors callbacks
  119866. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119867. */
  119868. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  119869. /**
  119870. * Disposes the sphere.
  119871. * @param force Specifies if the sphere should be disposed by force
  119872. */
  119873. dispose(force?: boolean): void;
  119874. /*** Helpers ***/
  119875. private _prepareSphere;
  119876. private _intersectsWithSphere;
  119877. }
  119878. /**
  119879. * Represents a gravitational field event
  119880. */
  119881. class PhysicsGravitationalFieldEvent {
  119882. private _physicsHelper;
  119883. private _scene;
  119884. private _origin;
  119885. private _options;
  119886. private _tickCallback;
  119887. private _sphere;
  119888. private _dataFetched;
  119889. /**
  119890. * Initializes the physics gravitational field event
  119891. * @param _physicsHelper A physics helper
  119892. * @param _scene BabylonJS scene
  119893. * @param _origin The origin position of the gravitational field event
  119894. * @param _options The options for the vortex event
  119895. */
  119896. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  119897. /**
  119898. * Returns the data related to the gravitational field event (sphere).
  119899. * @returns A gravitational field event
  119900. */
  119901. getData(): PhysicsGravitationalFieldEventData;
  119902. /**
  119903. * Enables the gravitational field.
  119904. */
  119905. enable(): void;
  119906. /**
  119907. * Disables the gravitational field.
  119908. */
  119909. disable(): void;
  119910. /**
  119911. * Disposes the sphere.
  119912. * @param force The force to dispose from the gravitational field event
  119913. */
  119914. dispose(force?: boolean): void;
  119915. private _tick;
  119916. }
  119917. /**
  119918. * Represents a physics updraft event
  119919. */
  119920. class PhysicsUpdraftEvent {
  119921. private _scene;
  119922. private _origin;
  119923. private _options;
  119924. private _physicsEngine;
  119925. private _originTop;
  119926. private _originDirection;
  119927. private _tickCallback;
  119928. private _cylinder;
  119929. private _cylinderPosition;
  119930. private _dataFetched;
  119931. /**
  119932. * Initializes the physics updraft event
  119933. * @param _scene BabylonJS scene
  119934. * @param _origin The origin position of the updraft
  119935. * @param _options The options for the updraft event
  119936. */
  119937. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  119938. /**
  119939. * Returns the data related to the updraft event (cylinder).
  119940. * @returns A physics updraft event
  119941. */
  119942. getData(): PhysicsUpdraftEventData;
  119943. /**
  119944. * Enables the updraft.
  119945. */
  119946. enable(): void;
  119947. /**
  119948. * Disables the updraft.
  119949. */
  119950. disable(): void;
  119951. /**
  119952. * Disposes the cylinder.
  119953. * @param force Specifies if the updraft should be disposed by force
  119954. */
  119955. dispose(force?: boolean): void;
  119956. private getImpostorHitData;
  119957. private _tick;
  119958. /*** Helpers ***/
  119959. private _prepareCylinder;
  119960. private _intersectsWithCylinder;
  119961. }
  119962. /**
  119963. * Represents a physics vortex event
  119964. */
  119965. class PhysicsVortexEvent {
  119966. private _scene;
  119967. private _origin;
  119968. private _options;
  119969. private _physicsEngine;
  119970. private _originTop;
  119971. private _tickCallback;
  119972. private _cylinder;
  119973. private _cylinderPosition;
  119974. private _dataFetched;
  119975. /**
  119976. * Initializes the physics vortex event
  119977. * @param _scene The BabylonJS scene
  119978. * @param _origin The origin position of the vortex
  119979. * @param _options The options for the vortex event
  119980. */
  119981. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  119982. /**
  119983. * Returns the data related to the vortex event (cylinder).
  119984. * @returns The physics vortex event data
  119985. */
  119986. getData(): PhysicsVortexEventData;
  119987. /**
  119988. * Enables the vortex.
  119989. */
  119990. enable(): void;
  119991. /**
  119992. * Disables the cortex.
  119993. */
  119994. disable(): void;
  119995. /**
  119996. * Disposes the sphere.
  119997. * @param force
  119998. */
  119999. dispose(force?: boolean): void;
  120000. private getImpostorHitData;
  120001. private _tick;
  120002. /*** Helpers ***/
  120003. private _prepareCylinder;
  120004. private _intersectsWithCylinder;
  120005. }
  120006. /**
  120007. * Options fot the radial explosion event
  120008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120009. */
  120010. export class PhysicsRadialExplosionEventOptions {
  120011. /**
  120012. * The radius of the sphere for the radial explosion.
  120013. */
  120014. radius: number;
  120015. /**
  120016. * The strenth of the explosion.
  120017. */
  120018. strength: number;
  120019. /**
  120020. * The strenght of the force in correspondence to the distance of the affected object
  120021. */
  120022. falloff: PhysicsRadialImpulseFalloff;
  120023. /**
  120024. * Sphere options for the radial explosion.
  120025. */
  120026. sphere: {
  120027. segments: number;
  120028. diameter: number;
  120029. };
  120030. /**
  120031. * Sphere options for the radial explosion.
  120032. */
  120033. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  120034. }
  120035. /**
  120036. * Options fot the updraft event
  120037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120038. */
  120039. export class PhysicsUpdraftEventOptions {
  120040. /**
  120041. * The radius of the cylinder for the vortex
  120042. */
  120043. radius: number;
  120044. /**
  120045. * The strenth of the updraft.
  120046. */
  120047. strength: number;
  120048. /**
  120049. * The height of the cylinder for the updraft.
  120050. */
  120051. height: number;
  120052. /**
  120053. * The mode for the the updraft.
  120054. */
  120055. updraftMode: PhysicsUpdraftMode;
  120056. }
  120057. /**
  120058. * Options fot the vortex event
  120059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120060. */
  120061. export class PhysicsVortexEventOptions {
  120062. /**
  120063. * The radius of the cylinder for the vortex
  120064. */
  120065. radius: number;
  120066. /**
  120067. * The strenth of the vortex.
  120068. */
  120069. strength: number;
  120070. /**
  120071. * The height of the cylinder for the vortex.
  120072. */
  120073. height: number;
  120074. /**
  120075. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  120076. */
  120077. centripetalForceThreshold: number;
  120078. /**
  120079. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  120080. */
  120081. centripetalForceMultiplier: number;
  120082. /**
  120083. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  120084. */
  120085. centrifugalForceMultiplier: number;
  120086. /**
  120087. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  120088. */
  120089. updraftForceMultiplier: number;
  120090. }
  120091. /**
  120092. * The strenght of the force in correspondence to the distance of the affected object
  120093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120094. */
  120095. export enum PhysicsRadialImpulseFalloff {
  120096. /** Defines that impulse is constant in strength across it's whole radius */
  120097. Constant = 0,
  120098. /** Defines that impulse gets weaker if it's further from the origin */
  120099. Linear = 1
  120100. }
  120101. /**
  120102. * The strength of the force in correspondence to the distance of the affected object
  120103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120104. */
  120105. export enum PhysicsUpdraftMode {
  120106. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  120107. Center = 0,
  120108. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  120109. Perpendicular = 1
  120110. }
  120111. /**
  120112. * Interface for a physics hit data
  120113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120114. */
  120115. export interface PhysicsHitData {
  120116. /**
  120117. * The force applied at the contact point
  120118. */
  120119. force: Vector3;
  120120. /**
  120121. * The contact point
  120122. */
  120123. contactPoint: Vector3;
  120124. /**
  120125. * The distance from the origin to the contact point
  120126. */
  120127. distanceFromOrigin: number;
  120128. }
  120129. /**
  120130. * Interface for radial explosion event data
  120131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120132. */
  120133. export interface PhysicsRadialExplosionEventData {
  120134. /**
  120135. * A sphere used for the radial explosion event
  120136. */
  120137. sphere: Mesh;
  120138. }
  120139. /**
  120140. * Interface for gravitational field event data
  120141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120142. */
  120143. export interface PhysicsGravitationalFieldEventData {
  120144. /**
  120145. * A sphere mesh used for the gravitational field event
  120146. */
  120147. sphere: Mesh;
  120148. }
  120149. /**
  120150. * Interface for updraft event data
  120151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120152. */
  120153. export interface PhysicsUpdraftEventData {
  120154. /**
  120155. * A cylinder used for the updraft event
  120156. */
  120157. cylinder: Mesh;
  120158. }
  120159. /**
  120160. * Interface for vortex event data
  120161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120162. */
  120163. export interface PhysicsVortexEventData {
  120164. /**
  120165. * A cylinder used for the vortex event
  120166. */
  120167. cylinder: Mesh;
  120168. }
  120169. /**
  120170. * Interface for an affected physics impostor
  120171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120172. */
  120173. export interface PhysicsAffectedImpostorWithData {
  120174. /**
  120175. * The impostor affected by the effect
  120176. */
  120177. impostor: PhysicsImpostor;
  120178. /**
  120179. * The data about the hit/horce from the explosion
  120180. */
  120181. hitData: PhysicsHitData;
  120182. }
  120183. }
  120184. declare module BABYLON {
  120185. /** @hidden */
  120186. export var blackAndWhitePixelShader: {
  120187. name: string;
  120188. shader: string;
  120189. };
  120190. }
  120191. declare module BABYLON {
  120192. /**
  120193. * Post process used to render in black and white
  120194. */
  120195. export class BlackAndWhitePostProcess extends PostProcess {
  120196. /**
  120197. * Linear about to convert he result to black and white (default: 1)
  120198. */
  120199. degree: number;
  120200. /**
  120201. * Creates a black and white post process
  120202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120203. * @param name The name of the effect.
  120204. * @param options The required width/height ratio to downsize to before computing the render pass.
  120205. * @param camera The camera to apply the render pass to.
  120206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120207. * @param engine The engine which the post process will be applied. (default: current engine)
  120208. * @param reusable If the post process can be reused on the same frame. (default: false)
  120209. */
  120210. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120211. }
  120212. }
  120213. declare module BABYLON {
  120214. /**
  120215. * This represents a set of one or more post processes in Babylon.
  120216. * A post process can be used to apply a shader to a texture after it is rendered.
  120217. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120218. */
  120219. export class PostProcessRenderEffect {
  120220. private _postProcesses;
  120221. private _getPostProcesses;
  120222. private _singleInstance;
  120223. private _cameras;
  120224. private _indicesForCamera;
  120225. /**
  120226. * Name of the effect
  120227. * @hidden
  120228. */
  120229. _name: string;
  120230. /**
  120231. * Instantiates a post process render effect.
  120232. * A post process can be used to apply a shader to a texture after it is rendered.
  120233. * @param engine The engine the effect is tied to
  120234. * @param name The name of the effect
  120235. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120236. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120237. */
  120238. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  120239. /**
  120240. * Checks if all the post processes in the effect are supported.
  120241. */
  120242. readonly isSupported: boolean;
  120243. /**
  120244. * Updates the current state of the effect
  120245. * @hidden
  120246. */
  120247. _update(): void;
  120248. /**
  120249. * Attaches the effect on cameras
  120250. * @param cameras The camera to attach to.
  120251. * @hidden
  120252. */
  120253. _attachCameras(cameras: Camera): void;
  120254. /**
  120255. * Attaches the effect on cameras
  120256. * @param cameras The camera to attach to.
  120257. * @hidden
  120258. */
  120259. _attachCameras(cameras: Camera[]): void;
  120260. /**
  120261. * Detaches the effect on cameras
  120262. * @param cameras The camera to detatch from.
  120263. * @hidden
  120264. */
  120265. _detachCameras(cameras: Camera): void;
  120266. /**
  120267. * Detatches the effect on cameras
  120268. * @param cameras The camera to detatch from.
  120269. * @hidden
  120270. */
  120271. _detachCameras(cameras: Camera[]): void;
  120272. /**
  120273. * Enables the effect on given cameras
  120274. * @param cameras The camera to enable.
  120275. * @hidden
  120276. */
  120277. _enable(cameras: Camera): void;
  120278. /**
  120279. * Enables the effect on given cameras
  120280. * @param cameras The camera to enable.
  120281. * @hidden
  120282. */
  120283. _enable(cameras: Nullable<Camera[]>): void;
  120284. /**
  120285. * Disables the effect on the given cameras
  120286. * @param cameras The camera to disable.
  120287. * @hidden
  120288. */
  120289. _disable(cameras: Camera): void;
  120290. /**
  120291. * Disables the effect on the given cameras
  120292. * @param cameras The camera to disable.
  120293. * @hidden
  120294. */
  120295. _disable(cameras: Nullable<Camera[]>): void;
  120296. /**
  120297. * Gets a list of the post processes contained in the effect.
  120298. * @param camera The camera to get the post processes on.
  120299. * @returns The list of the post processes in the effect.
  120300. */
  120301. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  120302. }
  120303. }
  120304. declare module BABYLON {
  120305. /** @hidden */
  120306. export var extractHighlightsPixelShader: {
  120307. name: string;
  120308. shader: string;
  120309. };
  120310. }
  120311. declare module BABYLON {
  120312. /**
  120313. * 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.
  120314. */
  120315. export class ExtractHighlightsPostProcess extends PostProcess {
  120316. /**
  120317. * The luminance threshold, pixels below this value will be set to black.
  120318. */
  120319. threshold: number;
  120320. /** @hidden */
  120321. _exposure: number;
  120322. /**
  120323. * Post process which has the input texture to be used when performing highlight extraction
  120324. * @hidden
  120325. */
  120326. _inputPostProcess: Nullable<PostProcess>;
  120327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120328. }
  120329. }
  120330. declare module BABYLON {
  120331. /** @hidden */
  120332. export var bloomMergePixelShader: {
  120333. name: string;
  120334. shader: string;
  120335. };
  120336. }
  120337. declare module BABYLON {
  120338. /**
  120339. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120340. */
  120341. export class BloomMergePostProcess extends PostProcess {
  120342. /** Weight of the bloom to be added to the original input. */
  120343. weight: number;
  120344. /**
  120345. * Creates a new instance of @see BloomMergePostProcess
  120346. * @param name The name of the effect.
  120347. * @param originalFromInput Post process which's input will be used for the merge.
  120348. * @param blurred Blurred highlights post process which's output will be used.
  120349. * @param weight Weight of the bloom to be added to the original input.
  120350. * @param options The required width/height ratio to downsize to before computing the render pass.
  120351. * @param camera The camera to apply the render pass to.
  120352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120353. * @param engine The engine which the post process will be applied. (default: current engine)
  120354. * @param reusable If the post process can be reused on the same frame. (default: false)
  120355. * @param textureType Type of textures used when performing the post process. (default: 0)
  120356. * @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)
  120357. */
  120358. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  120359. /** Weight of the bloom to be added to the original input. */
  120360. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120361. }
  120362. }
  120363. declare module BABYLON {
  120364. /**
  120365. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120366. */
  120367. export class BloomEffect extends PostProcessRenderEffect {
  120368. private bloomScale;
  120369. /**
  120370. * @hidden Internal
  120371. */
  120372. _effects: Array<PostProcess>;
  120373. /**
  120374. * @hidden Internal
  120375. */
  120376. _downscale: ExtractHighlightsPostProcess;
  120377. private _blurX;
  120378. private _blurY;
  120379. private _merge;
  120380. /**
  120381. * The luminance threshold to find bright areas of the image to bloom.
  120382. */
  120383. threshold: number;
  120384. /**
  120385. * The strength of the bloom.
  120386. */
  120387. weight: number;
  120388. /**
  120389. * Specifies the size of the bloom blur kernel, relative to the final output size
  120390. */
  120391. kernel: number;
  120392. /**
  120393. * Creates a new instance of @see BloomEffect
  120394. * @param scene The scene the effect belongs to.
  120395. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120396. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120397. * @param bloomWeight The the strength of bloom.
  120398. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120399. * @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)
  120400. */
  120401. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120402. /**
  120403. * Disposes each of the internal effects for a given camera.
  120404. * @param camera The camera to dispose the effect on.
  120405. */
  120406. disposeEffects(camera: Camera): void;
  120407. /**
  120408. * @hidden Internal
  120409. */
  120410. _updateEffects(): void;
  120411. /**
  120412. * Internal
  120413. * @returns if all the contained post processes are ready.
  120414. * @hidden
  120415. */
  120416. _isReady(): boolean;
  120417. }
  120418. }
  120419. declare module BABYLON {
  120420. /** @hidden */
  120421. export var chromaticAberrationPixelShader: {
  120422. name: string;
  120423. shader: string;
  120424. };
  120425. }
  120426. declare module BABYLON {
  120427. /**
  120428. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120429. */
  120430. export class ChromaticAberrationPostProcess extends PostProcess {
  120431. /**
  120432. * The amount of seperation of rgb channels (default: 30)
  120433. */
  120434. aberrationAmount: number;
  120435. /**
  120436. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120437. */
  120438. radialIntensity: number;
  120439. /**
  120440. * 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))
  120441. */
  120442. direction: Vector2;
  120443. /**
  120444. * 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))
  120445. */
  120446. centerPosition: Vector2;
  120447. /**
  120448. * Creates a new instance ChromaticAberrationPostProcess
  120449. * @param name The name of the effect.
  120450. * @param screenWidth The width of the screen to apply the effect on.
  120451. * @param screenHeight The height of the screen to apply the effect on.
  120452. * @param options The required width/height ratio to downsize to before computing the render pass.
  120453. * @param camera The camera to apply the render pass to.
  120454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120455. * @param engine The engine which the post process will be applied. (default: current engine)
  120456. * @param reusable If the post process can be reused on the same frame. (default: false)
  120457. * @param textureType Type of textures used when performing the post process. (default: 0)
  120458. * @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)
  120459. */
  120460. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120461. }
  120462. }
  120463. declare module BABYLON {
  120464. /** @hidden */
  120465. export var circleOfConfusionPixelShader: {
  120466. name: string;
  120467. shader: string;
  120468. };
  120469. }
  120470. declare module BABYLON {
  120471. /**
  120472. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120473. */
  120474. export class CircleOfConfusionPostProcess extends PostProcess {
  120475. /**
  120476. * 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.
  120477. */
  120478. lensSize: number;
  120479. /**
  120480. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120481. */
  120482. fStop: number;
  120483. /**
  120484. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120485. */
  120486. focusDistance: number;
  120487. /**
  120488. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120489. */
  120490. focalLength: number;
  120491. private _depthTexture;
  120492. /**
  120493. * Creates a new instance CircleOfConfusionPostProcess
  120494. * @param name The name of the effect.
  120495. * @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.
  120496. * @param options The required width/height ratio to downsize to before computing the render pass.
  120497. * @param camera The camera to apply the render pass to.
  120498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120499. * @param engine The engine which the post process will be applied. (default: current engine)
  120500. * @param reusable If the post process can be reused on the same frame. (default: false)
  120501. * @param textureType Type of textures used when performing the post process. (default: 0)
  120502. * @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)
  120503. */
  120504. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120505. /**
  120506. * 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.
  120507. */
  120508. depthTexture: RenderTargetTexture;
  120509. }
  120510. }
  120511. declare module BABYLON {
  120512. /** @hidden */
  120513. export var colorCorrectionPixelShader: {
  120514. name: string;
  120515. shader: string;
  120516. };
  120517. }
  120518. declare module BABYLON {
  120519. /**
  120520. *
  120521. * This post-process allows the modification of rendered colors by using
  120522. * a 'look-up table' (LUT). This effect is also called Color Grading.
  120523. *
  120524. * The object needs to be provided an url to a texture containing the color
  120525. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  120526. * Use an image editing software to tweak the LUT to match your needs.
  120527. *
  120528. * For an example of a color LUT, see here:
  120529. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  120530. * For explanations on color grading, see here:
  120531. * @see http://udn.epicgames.com/Three/ColorGrading.html
  120532. *
  120533. */
  120534. export class ColorCorrectionPostProcess extends PostProcess {
  120535. private _colorTableTexture;
  120536. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120537. }
  120538. }
  120539. declare module BABYLON {
  120540. /** @hidden */
  120541. export var convolutionPixelShader: {
  120542. name: string;
  120543. shader: string;
  120544. };
  120545. }
  120546. declare module BABYLON {
  120547. /**
  120548. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  120549. * input texture to perform effects such as edge detection or sharpening
  120550. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120551. */
  120552. export class ConvolutionPostProcess extends PostProcess {
  120553. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120554. kernel: number[];
  120555. /**
  120556. * Creates a new instance ConvolutionPostProcess
  120557. * @param name The name of the effect.
  120558. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  120559. * @param options The required width/height ratio to downsize to before computing the render pass.
  120560. * @param camera The camera to apply the render pass to.
  120561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120562. * @param engine The engine which the post process will be applied. (default: current engine)
  120563. * @param reusable If the post process can be reused on the same frame. (default: false)
  120564. * @param textureType Type of textures used when performing the post process. (default: 0)
  120565. */
  120566. constructor(name: string,
  120567. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120568. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120569. /**
  120570. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120571. */
  120572. static EdgeDetect0Kernel: number[];
  120573. /**
  120574. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120575. */
  120576. static EdgeDetect1Kernel: number[];
  120577. /**
  120578. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120579. */
  120580. static EdgeDetect2Kernel: number[];
  120581. /**
  120582. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120583. */
  120584. static SharpenKernel: number[];
  120585. /**
  120586. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120587. */
  120588. static EmbossKernel: number[];
  120589. /**
  120590. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120591. */
  120592. static GaussianKernel: number[];
  120593. }
  120594. }
  120595. declare module BABYLON {
  120596. /**
  120597. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  120598. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  120599. * based on samples that have a large difference in distance than the center pixel.
  120600. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  120601. */
  120602. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  120603. direction: Vector2;
  120604. /**
  120605. * Creates a new instance CircleOfConfusionPostProcess
  120606. * @param name The name of the effect.
  120607. * @param scene The scene the effect belongs to.
  120608. * @param direction The direction the blur should be applied.
  120609. * @param kernel The size of the kernel used to blur.
  120610. * @param options The required width/height ratio to downsize to before computing the render pass.
  120611. * @param camera The camera to apply the render pass to.
  120612. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  120613. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  120614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120615. * @param engine The engine which the post process will be applied. (default: current engine)
  120616. * @param reusable If the post process can be reused on the same frame. (default: false)
  120617. * @param textureType Type of textures used when performing the post process. (default: 0)
  120618. * @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)
  120619. */
  120620. 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);
  120621. }
  120622. }
  120623. declare module BABYLON {
  120624. /** @hidden */
  120625. export var depthOfFieldMergePixelShader: {
  120626. name: string;
  120627. shader: string;
  120628. };
  120629. }
  120630. declare module BABYLON {
  120631. /**
  120632. * Options to be set when merging outputs from the default pipeline.
  120633. */
  120634. export class DepthOfFieldMergePostProcessOptions {
  120635. /**
  120636. * The original image to merge on top of
  120637. */
  120638. originalFromInput: PostProcess;
  120639. /**
  120640. * Parameters to perform the merge of the depth of field effect
  120641. */
  120642. depthOfField?: {
  120643. circleOfConfusion: PostProcess;
  120644. blurSteps: Array<PostProcess>;
  120645. };
  120646. /**
  120647. * Parameters to perform the merge of bloom effect
  120648. */
  120649. bloom?: {
  120650. blurred: PostProcess;
  120651. weight: number;
  120652. };
  120653. }
  120654. /**
  120655. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120656. */
  120657. export class DepthOfFieldMergePostProcess extends PostProcess {
  120658. private blurSteps;
  120659. /**
  120660. * Creates a new instance of DepthOfFieldMergePostProcess
  120661. * @param name The name of the effect.
  120662. * @param originalFromInput Post process which's input will be used for the merge.
  120663. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  120664. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  120665. * @param options The required width/height ratio to downsize to before computing the render pass.
  120666. * @param camera The camera to apply the render pass to.
  120667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120668. * @param engine The engine which the post process will be applied. (default: current engine)
  120669. * @param reusable If the post process can be reused on the same frame. (default: false)
  120670. * @param textureType Type of textures used when performing the post process. (default: 0)
  120671. * @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)
  120672. */
  120673. 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);
  120674. /**
  120675. * Updates the effect with the current post process compile time values and recompiles the shader.
  120676. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120677. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120678. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120679. * @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
  120680. * @param onCompiled Called when the shader has been compiled.
  120681. * @param onError Called if there is an error when compiling a shader.
  120682. */
  120683. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  120684. }
  120685. }
  120686. declare module BABYLON {
  120687. /**
  120688. * Specifies the level of max blur that should be applied when using the depth of field effect
  120689. */
  120690. export enum DepthOfFieldEffectBlurLevel {
  120691. /**
  120692. * Subtle blur
  120693. */
  120694. Low = 0,
  120695. /**
  120696. * Medium blur
  120697. */
  120698. Medium = 1,
  120699. /**
  120700. * Large blur
  120701. */
  120702. High = 2
  120703. }
  120704. /**
  120705. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  120706. */
  120707. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  120708. private _circleOfConfusion;
  120709. /**
  120710. * @hidden Internal, blurs from high to low
  120711. */
  120712. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  120713. private _depthOfFieldBlurY;
  120714. private _dofMerge;
  120715. /**
  120716. * @hidden Internal post processes in depth of field effect
  120717. */
  120718. _effects: Array<PostProcess>;
  120719. /**
  120720. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  120721. */
  120722. focalLength: number;
  120723. /**
  120724. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120725. */
  120726. fStop: number;
  120727. /**
  120728. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120729. */
  120730. focusDistance: number;
  120731. /**
  120732. * 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.
  120733. */
  120734. lensSize: number;
  120735. /**
  120736. * Creates a new instance DepthOfFieldEffect
  120737. * @param scene The scene the effect belongs to.
  120738. * @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.
  120739. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120740. * @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)
  120741. */
  120742. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  120743. /**
  120744. * Get the current class name of the current effet
  120745. * @returns "DepthOfFieldEffect"
  120746. */
  120747. getClassName(): string;
  120748. /**
  120749. * 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.
  120750. */
  120751. depthTexture: RenderTargetTexture;
  120752. /**
  120753. * Disposes each of the internal effects for a given camera.
  120754. * @param camera The camera to dispose the effect on.
  120755. */
  120756. disposeEffects(camera: Camera): void;
  120757. /**
  120758. * @hidden Internal
  120759. */
  120760. _updateEffects(): void;
  120761. /**
  120762. * Internal
  120763. * @returns if all the contained post processes are ready.
  120764. * @hidden
  120765. */
  120766. _isReady(): boolean;
  120767. }
  120768. }
  120769. declare module BABYLON {
  120770. /** @hidden */
  120771. export var displayPassPixelShader: {
  120772. name: string;
  120773. shader: string;
  120774. };
  120775. }
  120776. declare module BABYLON {
  120777. /**
  120778. * DisplayPassPostProcess which produces an output the same as it's input
  120779. */
  120780. export class DisplayPassPostProcess extends PostProcess {
  120781. /**
  120782. * Creates the DisplayPassPostProcess
  120783. * @param name The name of the effect.
  120784. * @param options The required width/height ratio to downsize to before computing the render pass.
  120785. * @param camera The camera to apply the render pass to.
  120786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120787. * @param engine The engine which the post process will be applied. (default: current engine)
  120788. * @param reusable If the post process can be reused on the same frame. (default: false)
  120789. */
  120790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120791. }
  120792. }
  120793. declare module BABYLON {
  120794. /** @hidden */
  120795. export var filterPixelShader: {
  120796. name: string;
  120797. shader: string;
  120798. };
  120799. }
  120800. declare module BABYLON {
  120801. /**
  120802. * Applies a kernel filter to the image
  120803. */
  120804. export class FilterPostProcess extends PostProcess {
  120805. /** The matrix to be applied to the image */
  120806. kernelMatrix: Matrix;
  120807. /**
  120808. *
  120809. * @param name The name of the effect.
  120810. * @param kernelMatrix The matrix to be applied to the image
  120811. * @param options The required width/height ratio to downsize to before computing the render pass.
  120812. * @param camera The camera to apply the render pass to.
  120813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120814. * @param engine The engine which the post process will be applied. (default: current engine)
  120815. * @param reusable If the post process can be reused on the same frame. (default: false)
  120816. */
  120817. constructor(name: string,
  120818. /** The matrix to be applied to the image */
  120819. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120820. }
  120821. }
  120822. declare module BABYLON {
  120823. /** @hidden */
  120824. export var fxaaPixelShader: {
  120825. name: string;
  120826. shader: string;
  120827. };
  120828. }
  120829. declare module BABYLON {
  120830. /** @hidden */
  120831. export var fxaaVertexShader: {
  120832. name: string;
  120833. shader: string;
  120834. };
  120835. }
  120836. declare module BABYLON {
  120837. /**
  120838. * Fxaa post process
  120839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  120840. */
  120841. export class FxaaPostProcess extends PostProcess {
  120842. /** @hidden */
  120843. texelWidth: number;
  120844. /** @hidden */
  120845. texelHeight: number;
  120846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120847. private _getDefines;
  120848. }
  120849. }
  120850. declare module BABYLON {
  120851. /** @hidden */
  120852. export var grainPixelShader: {
  120853. name: string;
  120854. shader: string;
  120855. };
  120856. }
  120857. declare module BABYLON {
  120858. /**
  120859. * The GrainPostProcess adds noise to the image at mid luminance levels
  120860. */
  120861. export class GrainPostProcess extends PostProcess {
  120862. /**
  120863. * The intensity of the grain added (default: 30)
  120864. */
  120865. intensity: number;
  120866. /**
  120867. * If the grain should be randomized on every frame
  120868. */
  120869. animated: boolean;
  120870. /**
  120871. * Creates a new instance of @see GrainPostProcess
  120872. * @param name The name of the effect.
  120873. * @param options The required width/height ratio to downsize to before computing the render pass.
  120874. * @param camera The camera to apply the render pass to.
  120875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120876. * @param engine The engine which the post process will be applied. (default: current engine)
  120877. * @param reusable If the post process can be reused on the same frame. (default: false)
  120878. * @param textureType Type of textures used when performing the post process. (default: 0)
  120879. * @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)
  120880. */
  120881. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120882. }
  120883. }
  120884. declare module BABYLON {
  120885. /** @hidden */
  120886. export var highlightsPixelShader: {
  120887. name: string;
  120888. shader: string;
  120889. };
  120890. }
  120891. declare module BABYLON {
  120892. /**
  120893. * Extracts highlights from the image
  120894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120895. */
  120896. export class HighlightsPostProcess extends PostProcess {
  120897. /**
  120898. * Extracts highlights from the image
  120899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120900. * @param name The name of the effect.
  120901. * @param options The required width/height ratio to downsize to before computing the render pass.
  120902. * @param camera The camera to apply the render pass to.
  120903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120904. * @param engine The engine which the post process will be applied. (default: current engine)
  120905. * @param reusable If the post process can be reused on the same frame. (default: false)
  120906. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  120907. */
  120908. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120909. }
  120910. }
  120911. declare module BABYLON {
  120912. /** @hidden */
  120913. export var mrtFragmentDeclaration: {
  120914. name: string;
  120915. shader: string;
  120916. };
  120917. }
  120918. declare module BABYLON {
  120919. /** @hidden */
  120920. export var geometryPixelShader: {
  120921. name: string;
  120922. shader: string;
  120923. };
  120924. }
  120925. declare module BABYLON {
  120926. /** @hidden */
  120927. export var geometryVertexShader: {
  120928. name: string;
  120929. shader: string;
  120930. };
  120931. }
  120932. declare module BABYLON {
  120933. /** @hidden */
  120934. interface ISavedTransformationMatrix {
  120935. world: Matrix;
  120936. viewProjection: Matrix;
  120937. }
  120938. /**
  120939. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120940. */
  120941. export class GeometryBufferRenderer {
  120942. /**
  120943. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120944. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120945. */
  120946. static readonly POSITION_TEXTURE_TYPE: number;
  120947. /**
  120948. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120949. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120950. */
  120951. static readonly VELOCITY_TEXTURE_TYPE: number;
  120952. /**
  120953. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120954. * in order to compute objects velocities when enableVelocity is set to "true"
  120955. * @hidden
  120956. */
  120957. _previousTransformationMatrices: {
  120958. [index: number]: ISavedTransformationMatrix;
  120959. };
  120960. /**
  120961. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  120962. * in order to compute objects velocities when enableVelocity is set to "true"
  120963. * @hidden
  120964. */
  120965. _previousBonesTransformationMatrices: {
  120966. [index: number]: Float32Array;
  120967. };
  120968. /**
  120969. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  120970. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  120971. */
  120972. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  120973. private _scene;
  120974. private _multiRenderTarget;
  120975. private _ratio;
  120976. private _enablePosition;
  120977. private _enableVelocity;
  120978. private _positionIndex;
  120979. private _velocityIndex;
  120980. protected _effect: Effect;
  120981. protected _cachedDefines: string;
  120982. /**
  120983. * Set the render list (meshes to be rendered) used in the G buffer.
  120984. */
  120985. renderList: Mesh[];
  120986. /**
  120987. * Gets wether or not G buffer are supported by the running hardware.
  120988. * This requires draw buffer supports
  120989. */
  120990. readonly isSupported: boolean;
  120991. /**
  120992. * Returns the index of the given texture type in the G-Buffer textures array
  120993. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120994. * @returns the index of the given texture type in the G-Buffer textures array
  120995. */
  120996. getTextureIndex(textureType: number): number;
  120997. /**
  120998. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120999. */
  121000. /**
  121001. * Sets whether or not objects positions are enabled for the G buffer.
  121002. */
  121003. enablePosition: boolean;
  121004. /**
  121005. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121006. */
  121007. /**
  121008. * Sets wether or not objects velocities are enabled for the G buffer.
  121009. */
  121010. enableVelocity: boolean;
  121011. /**
  121012. * Gets the scene associated with the buffer.
  121013. */
  121014. readonly scene: Scene;
  121015. /**
  121016. * Gets the ratio used by the buffer during its creation.
  121017. * How big is the buffer related to the main canvas.
  121018. */
  121019. readonly ratio: number;
  121020. /** @hidden */
  121021. static _SceneComponentInitialization: (scene: Scene) => void;
  121022. /**
  121023. * Creates a new G Buffer for the scene
  121024. * @param scene The scene the buffer belongs to
  121025. * @param ratio How big is the buffer related to the main canvas.
  121026. */
  121027. constructor(scene: Scene, ratio?: number);
  121028. /**
  121029. * Checks wether everything is ready to render a submesh to the G buffer.
  121030. * @param subMesh the submesh to check readiness for
  121031. * @param useInstances is the mesh drawn using instance or not
  121032. * @returns true if ready otherwise false
  121033. */
  121034. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121035. /**
  121036. * Gets the current underlying G Buffer.
  121037. * @returns the buffer
  121038. */
  121039. getGBuffer(): MultiRenderTarget;
  121040. /**
  121041. * Gets the number of samples used to render the buffer (anti aliasing).
  121042. */
  121043. /**
  121044. * Sets the number of samples used to render the buffer (anti aliasing).
  121045. */
  121046. samples: number;
  121047. /**
  121048. * Disposes the renderer and frees up associated resources.
  121049. */
  121050. dispose(): void;
  121051. protected _createRenderTargets(): void;
  121052. private _copyBonesTransformationMatrices;
  121053. }
  121054. }
  121055. declare module BABYLON {
  121056. interface Scene {
  121057. /** @hidden (Backing field) */
  121058. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121059. /**
  121060. * Gets or Sets the current geometry buffer associated to the scene.
  121061. */
  121062. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121063. /**
  121064. * Enables a GeometryBufferRender and associates it with the scene
  121065. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  121066. * @returns the GeometryBufferRenderer
  121067. */
  121068. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  121069. /**
  121070. * Disables the GeometryBufferRender associated with the scene
  121071. */
  121072. disableGeometryBufferRenderer(): void;
  121073. }
  121074. /**
  121075. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121076. * in several rendering techniques.
  121077. */
  121078. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  121079. /**
  121080. * The component name helpful to identify the component in the list of scene components.
  121081. */
  121082. readonly name: string;
  121083. /**
  121084. * The scene the component belongs to.
  121085. */
  121086. scene: Scene;
  121087. /**
  121088. * Creates a new instance of the component for the given scene
  121089. * @param scene Defines the scene to register the component in
  121090. */
  121091. constructor(scene: Scene);
  121092. /**
  121093. * Registers the component in a given scene
  121094. */
  121095. register(): void;
  121096. /**
  121097. * Rebuilds the elements related to this component in case of
  121098. * context lost for instance.
  121099. */
  121100. rebuild(): void;
  121101. /**
  121102. * Disposes the component and the associated ressources
  121103. */
  121104. dispose(): void;
  121105. private _gatherRenderTargets;
  121106. }
  121107. }
  121108. declare module BABYLON {
  121109. /** @hidden */
  121110. export var motionBlurPixelShader: {
  121111. name: string;
  121112. shader: string;
  121113. };
  121114. }
  121115. declare module BABYLON {
  121116. /**
  121117. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  121118. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  121119. * As an example, all you have to do is to create the post-process:
  121120. * var mb = new BABYLON.MotionBlurPostProcess(
  121121. * 'mb', // The name of the effect.
  121122. * scene, // The scene containing the objects to blur according to their velocity.
  121123. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  121124. * camera // The camera to apply the render pass to.
  121125. * );
  121126. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  121127. */
  121128. export class MotionBlurPostProcess extends PostProcess {
  121129. /**
  121130. * Defines how much the image is blurred by the movement. Default value is equal to 1
  121131. */
  121132. motionStrength: number;
  121133. /**
  121134. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  121135. */
  121136. /**
  121137. * Sets the number of iterations to be used for motion blur quality
  121138. */
  121139. motionBlurSamples: number;
  121140. private _motionBlurSamples;
  121141. private _geometryBufferRenderer;
  121142. /**
  121143. * Creates a new instance MotionBlurPostProcess
  121144. * @param name The name of the effect.
  121145. * @param scene The scene containing the objects to blur according to their velocity.
  121146. * @param options The required width/height ratio to downsize to before computing the render pass.
  121147. * @param camera The camera to apply the render pass to.
  121148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121149. * @param engine The engine which the post process will be applied. (default: current engine)
  121150. * @param reusable If the post process can be reused on the same frame. (default: false)
  121151. * @param textureType Type of textures used when performing the post process. (default: 0)
  121152. * @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)
  121153. */
  121154. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121155. /**
  121156. * Excludes the given skinned mesh from computing bones velocities.
  121157. * 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.
  121158. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  121159. */
  121160. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121161. /**
  121162. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  121163. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  121164. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  121165. */
  121166. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121167. /**
  121168. * Disposes the post process.
  121169. * @param camera The camera to dispose the post process on.
  121170. */
  121171. dispose(camera?: Camera): void;
  121172. }
  121173. }
  121174. declare module BABYLON {
  121175. /** @hidden */
  121176. export var refractionPixelShader: {
  121177. name: string;
  121178. shader: string;
  121179. };
  121180. }
  121181. declare module BABYLON {
  121182. /**
  121183. * Post process which applies a refractin texture
  121184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121185. */
  121186. export class RefractionPostProcess extends PostProcess {
  121187. /** the base color of the refraction (used to taint the rendering) */
  121188. color: Color3;
  121189. /** simulated refraction depth */
  121190. depth: number;
  121191. /** the coefficient of the base color (0 to remove base color tainting) */
  121192. colorLevel: number;
  121193. private _refTexture;
  121194. private _ownRefractionTexture;
  121195. /**
  121196. * Gets or sets the refraction texture
  121197. * Please note that you are responsible for disposing the texture if you set it manually
  121198. */
  121199. refractionTexture: Texture;
  121200. /**
  121201. * Initializes the RefractionPostProcess
  121202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121203. * @param name The name of the effect.
  121204. * @param refractionTextureUrl Url of the refraction texture to use
  121205. * @param color the base color of the refraction (used to taint the rendering)
  121206. * @param depth simulated refraction depth
  121207. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  121208. * @param camera The camera to apply the render pass to.
  121209. * @param options The required width/height ratio to downsize to before computing the render pass.
  121210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121211. * @param engine The engine which the post process will be applied. (default: current engine)
  121212. * @param reusable If the post process can be reused on the same frame. (default: false)
  121213. */
  121214. constructor(name: string, refractionTextureUrl: string,
  121215. /** the base color of the refraction (used to taint the rendering) */
  121216. color: Color3,
  121217. /** simulated refraction depth */
  121218. depth: number,
  121219. /** the coefficient of the base color (0 to remove base color tainting) */
  121220. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121221. /**
  121222. * Disposes of the post process
  121223. * @param camera Camera to dispose post process on
  121224. */
  121225. dispose(camera: Camera): void;
  121226. }
  121227. }
  121228. declare module BABYLON {
  121229. /** @hidden */
  121230. export var sharpenPixelShader: {
  121231. name: string;
  121232. shader: string;
  121233. };
  121234. }
  121235. declare module BABYLON {
  121236. /**
  121237. * The SharpenPostProcess applies a sharpen kernel to every pixel
  121238. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121239. */
  121240. export class SharpenPostProcess extends PostProcess {
  121241. /**
  121242. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  121243. */
  121244. colorAmount: number;
  121245. /**
  121246. * How much sharpness should be applied (default: 0.3)
  121247. */
  121248. edgeAmount: number;
  121249. /**
  121250. * Creates a new instance ConvolutionPostProcess
  121251. * @param name The name of the effect.
  121252. * @param options The required width/height ratio to downsize to before computing the render pass.
  121253. * @param camera The camera to apply the render pass to.
  121254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121255. * @param engine The engine which the post process will be applied. (default: current engine)
  121256. * @param reusable If the post process can be reused on the same frame. (default: false)
  121257. * @param textureType Type of textures used when performing the post process. (default: 0)
  121258. * @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)
  121259. */
  121260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121261. }
  121262. }
  121263. declare module BABYLON {
  121264. /**
  121265. * PostProcessRenderPipeline
  121266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121267. */
  121268. export class PostProcessRenderPipeline {
  121269. private engine;
  121270. private _renderEffects;
  121271. private _renderEffectsForIsolatedPass;
  121272. /**
  121273. * List of inspectable custom properties (used by the Inspector)
  121274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121275. */
  121276. inspectableCustomProperties: IInspectable[];
  121277. /**
  121278. * @hidden
  121279. */
  121280. protected _cameras: Camera[];
  121281. /** @hidden */
  121282. _name: string;
  121283. /**
  121284. * Gets pipeline name
  121285. */
  121286. readonly name: string;
  121287. /**
  121288. * Initializes a PostProcessRenderPipeline
  121289. * @param engine engine to add the pipeline to
  121290. * @param name name of the pipeline
  121291. */
  121292. constructor(engine: Engine, name: string);
  121293. /**
  121294. * Gets the class name
  121295. * @returns "PostProcessRenderPipeline"
  121296. */
  121297. getClassName(): string;
  121298. /**
  121299. * If all the render effects in the pipeline are supported
  121300. */
  121301. readonly isSupported: boolean;
  121302. /**
  121303. * Adds an effect to the pipeline
  121304. * @param renderEffect the effect to add
  121305. */
  121306. addEffect(renderEffect: PostProcessRenderEffect): void;
  121307. /** @hidden */
  121308. _rebuild(): void;
  121309. /** @hidden */
  121310. _enableEffect(renderEffectName: string, cameras: Camera): void;
  121311. /** @hidden */
  121312. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  121313. /** @hidden */
  121314. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121315. /** @hidden */
  121316. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121317. /** @hidden */
  121318. _attachCameras(cameras: Camera, unique: boolean): void;
  121319. /** @hidden */
  121320. _attachCameras(cameras: Camera[], unique: boolean): void;
  121321. /** @hidden */
  121322. _detachCameras(cameras: Camera): void;
  121323. /** @hidden */
  121324. _detachCameras(cameras: Nullable<Camera[]>): void;
  121325. /** @hidden */
  121326. _update(): void;
  121327. /** @hidden */
  121328. _reset(): void;
  121329. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  121330. /**
  121331. * Disposes of the pipeline
  121332. */
  121333. dispose(): void;
  121334. }
  121335. }
  121336. declare module BABYLON {
  121337. /**
  121338. * PostProcessRenderPipelineManager class
  121339. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121340. */
  121341. export class PostProcessRenderPipelineManager {
  121342. private _renderPipelines;
  121343. /**
  121344. * Initializes a PostProcessRenderPipelineManager
  121345. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121346. */
  121347. constructor();
  121348. /**
  121349. * Gets the list of supported render pipelines
  121350. */
  121351. readonly supportedPipelines: PostProcessRenderPipeline[];
  121352. /**
  121353. * Adds a pipeline to the manager
  121354. * @param renderPipeline The pipeline to add
  121355. */
  121356. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  121357. /**
  121358. * Attaches a camera to the pipeline
  121359. * @param renderPipelineName The name of the pipeline to attach to
  121360. * @param cameras the camera to attach
  121361. * @param unique if the camera can be attached multiple times to the pipeline
  121362. */
  121363. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  121364. /**
  121365. * Detaches a camera from the pipeline
  121366. * @param renderPipelineName The name of the pipeline to detach from
  121367. * @param cameras the camera to detach
  121368. */
  121369. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  121370. /**
  121371. * Enables an effect by name on a pipeline
  121372. * @param renderPipelineName the name of the pipeline to enable the effect in
  121373. * @param renderEffectName the name of the effect to enable
  121374. * @param cameras the cameras that the effect should be enabled on
  121375. */
  121376. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121377. /**
  121378. * Disables an effect by name on a pipeline
  121379. * @param renderPipelineName the name of the pipeline to disable the effect in
  121380. * @param renderEffectName the name of the effect to disable
  121381. * @param cameras the cameras that the effect should be disabled on
  121382. */
  121383. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121384. /**
  121385. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121386. */
  121387. update(): void;
  121388. /** @hidden */
  121389. _rebuild(): void;
  121390. /**
  121391. * Disposes of the manager and pipelines
  121392. */
  121393. dispose(): void;
  121394. }
  121395. }
  121396. declare module BABYLON {
  121397. interface Scene {
  121398. /** @hidden (Backing field) */
  121399. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121400. /**
  121401. * Gets the postprocess render pipeline manager
  121402. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121403. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121404. */
  121405. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121406. }
  121407. /**
  121408. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121409. */
  121410. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121411. /**
  121412. * The component name helpfull to identify the component in the list of scene components.
  121413. */
  121414. readonly name: string;
  121415. /**
  121416. * The scene the component belongs to.
  121417. */
  121418. scene: Scene;
  121419. /**
  121420. * Creates a new instance of the component for the given scene
  121421. * @param scene Defines the scene to register the component in
  121422. */
  121423. constructor(scene: Scene);
  121424. /**
  121425. * Registers the component in a given scene
  121426. */
  121427. register(): void;
  121428. /**
  121429. * Rebuilds the elements related to this component in case of
  121430. * context lost for instance.
  121431. */
  121432. rebuild(): void;
  121433. /**
  121434. * Disposes the component and the associated ressources
  121435. */
  121436. dispose(): void;
  121437. private _gatherRenderTargets;
  121438. }
  121439. }
  121440. declare module BABYLON {
  121441. /**
  121442. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121443. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121444. */
  121445. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121446. private _scene;
  121447. private _camerasToBeAttached;
  121448. /**
  121449. * ID of the sharpen post process,
  121450. */
  121451. private readonly SharpenPostProcessId;
  121452. /**
  121453. * @ignore
  121454. * ID of the image processing post process;
  121455. */
  121456. readonly ImageProcessingPostProcessId: string;
  121457. /**
  121458. * @ignore
  121459. * ID of the Fast Approximate Anti-Aliasing post process;
  121460. */
  121461. readonly FxaaPostProcessId: string;
  121462. /**
  121463. * ID of the chromatic aberration post process,
  121464. */
  121465. private readonly ChromaticAberrationPostProcessId;
  121466. /**
  121467. * ID of the grain post process
  121468. */
  121469. private readonly GrainPostProcessId;
  121470. /**
  121471. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121472. */
  121473. sharpen: SharpenPostProcess;
  121474. private _sharpenEffect;
  121475. private bloom;
  121476. /**
  121477. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121478. */
  121479. depthOfField: DepthOfFieldEffect;
  121480. /**
  121481. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121482. */
  121483. fxaa: FxaaPostProcess;
  121484. /**
  121485. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121486. */
  121487. imageProcessing: ImageProcessingPostProcess;
  121488. /**
  121489. * Chromatic aberration post process which will shift rgb colors in the image
  121490. */
  121491. chromaticAberration: ChromaticAberrationPostProcess;
  121492. private _chromaticAberrationEffect;
  121493. /**
  121494. * Grain post process which add noise to the image
  121495. */
  121496. grain: GrainPostProcess;
  121497. private _grainEffect;
  121498. /**
  121499. * Glow post process which adds a glow to emissive areas of the image
  121500. */
  121501. private _glowLayer;
  121502. /**
  121503. * Animations which can be used to tweak settings over a period of time
  121504. */
  121505. animations: Animation[];
  121506. private _imageProcessingConfigurationObserver;
  121507. private _sharpenEnabled;
  121508. private _bloomEnabled;
  121509. private _depthOfFieldEnabled;
  121510. private _depthOfFieldBlurLevel;
  121511. private _fxaaEnabled;
  121512. private _imageProcessingEnabled;
  121513. private _defaultPipelineTextureType;
  121514. private _bloomScale;
  121515. private _chromaticAberrationEnabled;
  121516. private _grainEnabled;
  121517. private _buildAllowed;
  121518. /**
  121519. * Gets active scene
  121520. */
  121521. readonly scene: Scene;
  121522. /**
  121523. * Enable or disable the sharpen process from the pipeline
  121524. */
  121525. sharpenEnabled: boolean;
  121526. private _resizeObserver;
  121527. private _hardwareScaleLevel;
  121528. private _bloomKernel;
  121529. /**
  121530. * Specifies the size of the bloom blur kernel, relative to the final output size
  121531. */
  121532. bloomKernel: number;
  121533. /**
  121534. * Specifies the weight of the bloom in the final rendering
  121535. */
  121536. private _bloomWeight;
  121537. /**
  121538. * Specifies the luma threshold for the area that will be blurred by the bloom
  121539. */
  121540. private _bloomThreshold;
  121541. private _hdr;
  121542. /**
  121543. * The strength of the bloom.
  121544. */
  121545. bloomWeight: number;
  121546. /**
  121547. * The strength of the bloom.
  121548. */
  121549. bloomThreshold: number;
  121550. /**
  121551. * The scale of the bloom, lower value will provide better performance.
  121552. */
  121553. bloomScale: number;
  121554. /**
  121555. * Enable or disable the bloom from the pipeline
  121556. */
  121557. bloomEnabled: boolean;
  121558. private _rebuildBloom;
  121559. /**
  121560. * If the depth of field is enabled.
  121561. */
  121562. depthOfFieldEnabled: boolean;
  121563. /**
  121564. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121565. */
  121566. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  121567. /**
  121568. * If the anti aliasing is enabled.
  121569. */
  121570. fxaaEnabled: boolean;
  121571. private _samples;
  121572. /**
  121573. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121574. */
  121575. samples: number;
  121576. /**
  121577. * If image processing is enabled.
  121578. */
  121579. imageProcessingEnabled: boolean;
  121580. /**
  121581. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121582. */
  121583. glowLayerEnabled: boolean;
  121584. /**
  121585. * Gets the glow layer (or null if not defined)
  121586. */
  121587. readonly glowLayer: Nullable<GlowLayer>;
  121588. /**
  121589. * Enable or disable the chromaticAberration process from the pipeline
  121590. */
  121591. chromaticAberrationEnabled: boolean;
  121592. /**
  121593. * Enable or disable the grain process from the pipeline
  121594. */
  121595. grainEnabled: boolean;
  121596. /**
  121597. * @constructor
  121598. * @param name - The rendering pipeline name (default: "")
  121599. * @param hdr - If high dynamic range textures should be used (default: true)
  121600. * @param scene - The scene linked to this pipeline (default: the last created scene)
  121601. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  121602. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  121603. */
  121604. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  121605. /**
  121606. * Get the class name
  121607. * @returns "DefaultRenderingPipeline"
  121608. */
  121609. getClassName(): string;
  121610. /**
  121611. * Force the compilation of the entire pipeline.
  121612. */
  121613. prepare(): void;
  121614. private _hasCleared;
  121615. private _prevPostProcess;
  121616. private _prevPrevPostProcess;
  121617. private _setAutoClearAndTextureSharing;
  121618. private _depthOfFieldSceneObserver;
  121619. private _buildPipeline;
  121620. private _disposePostProcesses;
  121621. /**
  121622. * Adds a camera to the pipeline
  121623. * @param camera the camera to be added
  121624. */
  121625. addCamera(camera: Camera): void;
  121626. /**
  121627. * Removes a camera from the pipeline
  121628. * @param camera the camera to remove
  121629. */
  121630. removeCamera(camera: Camera): void;
  121631. /**
  121632. * Dispose of the pipeline and stop all post processes
  121633. */
  121634. dispose(): void;
  121635. /**
  121636. * Serialize the rendering pipeline (Used when exporting)
  121637. * @returns the serialized object
  121638. */
  121639. serialize(): any;
  121640. /**
  121641. * Parse the serialized pipeline
  121642. * @param source Source pipeline.
  121643. * @param scene The scene to load the pipeline to.
  121644. * @param rootUrl The URL of the serialized pipeline.
  121645. * @returns An instantiated pipeline from the serialized object.
  121646. */
  121647. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  121648. }
  121649. }
  121650. declare module BABYLON {
  121651. /** @hidden */
  121652. export var lensHighlightsPixelShader: {
  121653. name: string;
  121654. shader: string;
  121655. };
  121656. }
  121657. declare module BABYLON {
  121658. /** @hidden */
  121659. export var depthOfFieldPixelShader: {
  121660. name: string;
  121661. shader: string;
  121662. };
  121663. }
  121664. declare module BABYLON {
  121665. /**
  121666. * BABYLON.JS Chromatic Aberration GLSL Shader
  121667. * Author: Olivier Guyot
  121668. * Separates very slightly R, G and B colors on the edges of the screen
  121669. * Inspired by Francois Tarlier & Martins Upitis
  121670. */
  121671. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  121672. /**
  121673. * @ignore
  121674. * The chromatic aberration PostProcess id in the pipeline
  121675. */
  121676. LensChromaticAberrationEffect: string;
  121677. /**
  121678. * @ignore
  121679. * The highlights enhancing PostProcess id in the pipeline
  121680. */
  121681. HighlightsEnhancingEffect: string;
  121682. /**
  121683. * @ignore
  121684. * The depth-of-field PostProcess id in the pipeline
  121685. */
  121686. LensDepthOfFieldEffect: string;
  121687. private _scene;
  121688. private _depthTexture;
  121689. private _grainTexture;
  121690. private _chromaticAberrationPostProcess;
  121691. private _highlightsPostProcess;
  121692. private _depthOfFieldPostProcess;
  121693. private _edgeBlur;
  121694. private _grainAmount;
  121695. private _chromaticAberration;
  121696. private _distortion;
  121697. private _highlightsGain;
  121698. private _highlightsThreshold;
  121699. private _dofDistance;
  121700. private _dofAperture;
  121701. private _dofDarken;
  121702. private _dofPentagon;
  121703. private _blurNoise;
  121704. /**
  121705. * @constructor
  121706. *
  121707. * Effect parameters are as follow:
  121708. * {
  121709. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121710. * edge_blur: number; // from 0 to x (1 for realism)
  121711. * distortion: number; // from 0 to x (1 for realism)
  121712. * grain_amount: number; // from 0 to 1
  121713. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121714. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121715. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121716. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121717. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121718. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121719. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121720. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121721. * }
  121722. * Note: if an effect parameter is unset, effect is disabled
  121723. *
  121724. * @param name The rendering pipeline name
  121725. * @param parameters - An object containing all parameters (see above)
  121726. * @param scene The scene linked to this pipeline
  121727. * @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)
  121728. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121729. */
  121730. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  121731. /**
  121732. * Get the class name
  121733. * @returns "LensRenderingPipeline"
  121734. */
  121735. getClassName(): string;
  121736. /**
  121737. * Gets associated scene
  121738. */
  121739. readonly scene: Scene;
  121740. /**
  121741. * Gets or sets the edge blur
  121742. */
  121743. edgeBlur: number;
  121744. /**
  121745. * Gets or sets the grain amount
  121746. */
  121747. grainAmount: number;
  121748. /**
  121749. * Gets or sets the chromatic aberration amount
  121750. */
  121751. chromaticAberration: number;
  121752. /**
  121753. * Gets or sets the depth of field aperture
  121754. */
  121755. dofAperture: number;
  121756. /**
  121757. * Gets or sets the edge distortion
  121758. */
  121759. edgeDistortion: number;
  121760. /**
  121761. * Gets or sets the depth of field distortion
  121762. */
  121763. dofDistortion: number;
  121764. /**
  121765. * Gets or sets the darken out of focus amount
  121766. */
  121767. darkenOutOfFocus: number;
  121768. /**
  121769. * Gets or sets a boolean indicating if blur noise is enabled
  121770. */
  121771. blurNoise: boolean;
  121772. /**
  121773. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121774. */
  121775. pentagonBokeh: boolean;
  121776. /**
  121777. * Gets or sets the highlight grain amount
  121778. */
  121779. highlightsGain: number;
  121780. /**
  121781. * Gets or sets the highlight threshold
  121782. */
  121783. highlightsThreshold: number;
  121784. /**
  121785. * Sets the amount of blur at the edges
  121786. * @param amount blur amount
  121787. */
  121788. setEdgeBlur(amount: number): void;
  121789. /**
  121790. * Sets edge blur to 0
  121791. */
  121792. disableEdgeBlur(): void;
  121793. /**
  121794. * Sets the amout of grain
  121795. * @param amount Amount of grain
  121796. */
  121797. setGrainAmount(amount: number): void;
  121798. /**
  121799. * Set grain amount to 0
  121800. */
  121801. disableGrain(): void;
  121802. /**
  121803. * Sets the chromatic aberration amount
  121804. * @param amount amount of chromatic aberration
  121805. */
  121806. setChromaticAberration(amount: number): void;
  121807. /**
  121808. * Sets chromatic aberration amount to 0
  121809. */
  121810. disableChromaticAberration(): void;
  121811. /**
  121812. * Sets the EdgeDistortion amount
  121813. * @param amount amount of EdgeDistortion
  121814. */
  121815. setEdgeDistortion(amount: number): void;
  121816. /**
  121817. * Sets edge distortion to 0
  121818. */
  121819. disableEdgeDistortion(): void;
  121820. /**
  121821. * Sets the FocusDistance amount
  121822. * @param amount amount of FocusDistance
  121823. */
  121824. setFocusDistance(amount: number): void;
  121825. /**
  121826. * Disables depth of field
  121827. */
  121828. disableDepthOfField(): void;
  121829. /**
  121830. * Sets the Aperture amount
  121831. * @param amount amount of Aperture
  121832. */
  121833. setAperture(amount: number): void;
  121834. /**
  121835. * Sets the DarkenOutOfFocus amount
  121836. * @param amount amount of DarkenOutOfFocus
  121837. */
  121838. setDarkenOutOfFocus(amount: number): void;
  121839. private _pentagonBokehIsEnabled;
  121840. /**
  121841. * Creates a pentagon bokeh effect
  121842. */
  121843. enablePentagonBokeh(): void;
  121844. /**
  121845. * Disables the pentagon bokeh effect
  121846. */
  121847. disablePentagonBokeh(): void;
  121848. /**
  121849. * Enables noise blur
  121850. */
  121851. enableNoiseBlur(): void;
  121852. /**
  121853. * Disables noise blur
  121854. */
  121855. disableNoiseBlur(): void;
  121856. /**
  121857. * Sets the HighlightsGain amount
  121858. * @param amount amount of HighlightsGain
  121859. */
  121860. setHighlightsGain(amount: number): void;
  121861. /**
  121862. * Sets the HighlightsThreshold amount
  121863. * @param amount amount of HighlightsThreshold
  121864. */
  121865. setHighlightsThreshold(amount: number): void;
  121866. /**
  121867. * Disables highlights
  121868. */
  121869. disableHighlights(): void;
  121870. /**
  121871. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  121872. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  121873. */
  121874. dispose(disableDepthRender?: boolean): void;
  121875. private _createChromaticAberrationPostProcess;
  121876. private _createHighlightsPostProcess;
  121877. private _createDepthOfFieldPostProcess;
  121878. private _createGrainTexture;
  121879. }
  121880. }
  121881. declare module BABYLON {
  121882. /** @hidden */
  121883. export var ssao2PixelShader: {
  121884. name: string;
  121885. shader: string;
  121886. };
  121887. }
  121888. declare module BABYLON {
  121889. /** @hidden */
  121890. export var ssaoCombinePixelShader: {
  121891. name: string;
  121892. shader: string;
  121893. };
  121894. }
  121895. declare module BABYLON {
  121896. /**
  121897. * Render pipeline to produce ssao effect
  121898. */
  121899. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  121900. /**
  121901. * @ignore
  121902. * The PassPostProcess id in the pipeline that contains the original scene color
  121903. */
  121904. SSAOOriginalSceneColorEffect: string;
  121905. /**
  121906. * @ignore
  121907. * The SSAO PostProcess id in the pipeline
  121908. */
  121909. SSAORenderEffect: string;
  121910. /**
  121911. * @ignore
  121912. * The horizontal blur PostProcess id in the pipeline
  121913. */
  121914. SSAOBlurHRenderEffect: string;
  121915. /**
  121916. * @ignore
  121917. * The vertical blur PostProcess id in the pipeline
  121918. */
  121919. SSAOBlurVRenderEffect: string;
  121920. /**
  121921. * @ignore
  121922. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121923. */
  121924. SSAOCombineRenderEffect: string;
  121925. /**
  121926. * The output strength of the SSAO post-process. Default value is 1.0.
  121927. */
  121928. totalStrength: number;
  121929. /**
  121930. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  121931. */
  121932. maxZ: number;
  121933. /**
  121934. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  121935. */
  121936. minZAspect: number;
  121937. private _samples;
  121938. /**
  121939. * Number of samples used for the SSAO calculations. Default value is 8
  121940. */
  121941. samples: number;
  121942. private _textureSamples;
  121943. /**
  121944. * Number of samples to use for antialiasing
  121945. */
  121946. textureSamples: number;
  121947. /**
  121948. * Ratio object used for SSAO ratio and blur ratio
  121949. */
  121950. private _ratio;
  121951. /**
  121952. * Dynamically generated sphere sampler.
  121953. */
  121954. private _sampleSphere;
  121955. /**
  121956. * Blur filter offsets
  121957. */
  121958. private _samplerOffsets;
  121959. private _expensiveBlur;
  121960. /**
  121961. * If bilateral blur should be used
  121962. */
  121963. expensiveBlur: boolean;
  121964. /**
  121965. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  121966. */
  121967. radius: number;
  121968. /**
  121969. * The base color of the SSAO post-process
  121970. * The final result is "base + ssao" between [0, 1]
  121971. */
  121972. base: number;
  121973. /**
  121974. * Support test.
  121975. */
  121976. static readonly IsSupported: boolean;
  121977. private _scene;
  121978. private _depthTexture;
  121979. private _normalTexture;
  121980. private _randomTexture;
  121981. private _originalColorPostProcess;
  121982. private _ssaoPostProcess;
  121983. private _blurHPostProcess;
  121984. private _blurVPostProcess;
  121985. private _ssaoCombinePostProcess;
  121986. private _firstUpdate;
  121987. /**
  121988. * Gets active scene
  121989. */
  121990. readonly scene: Scene;
  121991. /**
  121992. * @constructor
  121993. * @param name The rendering pipeline name
  121994. * @param scene The scene linked to this pipeline
  121995. * @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 }
  121996. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121997. */
  121998. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121999. /**
  122000. * Get the class name
  122001. * @returns "SSAO2RenderingPipeline"
  122002. */
  122003. getClassName(): string;
  122004. /**
  122005. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122006. */
  122007. dispose(disableGeometryBufferRenderer?: boolean): void;
  122008. private _createBlurPostProcess;
  122009. /** @hidden */
  122010. _rebuild(): void;
  122011. private _bits;
  122012. private _radicalInverse_VdC;
  122013. private _hammersley;
  122014. private _hemisphereSample_uniform;
  122015. private _generateHemisphere;
  122016. private _createSSAOPostProcess;
  122017. private _createSSAOCombinePostProcess;
  122018. private _createRandomTexture;
  122019. /**
  122020. * Serialize the rendering pipeline (Used when exporting)
  122021. * @returns the serialized object
  122022. */
  122023. serialize(): any;
  122024. /**
  122025. * Parse the serialized pipeline
  122026. * @param source Source pipeline.
  122027. * @param scene The scene to load the pipeline to.
  122028. * @param rootUrl The URL of the serialized pipeline.
  122029. * @returns An instantiated pipeline from the serialized object.
  122030. */
  122031. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  122032. }
  122033. }
  122034. declare module BABYLON {
  122035. /** @hidden */
  122036. export var ssaoPixelShader: {
  122037. name: string;
  122038. shader: string;
  122039. };
  122040. }
  122041. declare module BABYLON {
  122042. /**
  122043. * Render pipeline to produce ssao effect
  122044. */
  122045. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  122046. /**
  122047. * @ignore
  122048. * The PassPostProcess id in the pipeline that contains the original scene color
  122049. */
  122050. SSAOOriginalSceneColorEffect: string;
  122051. /**
  122052. * @ignore
  122053. * The SSAO PostProcess id in the pipeline
  122054. */
  122055. SSAORenderEffect: string;
  122056. /**
  122057. * @ignore
  122058. * The horizontal blur PostProcess id in the pipeline
  122059. */
  122060. SSAOBlurHRenderEffect: string;
  122061. /**
  122062. * @ignore
  122063. * The vertical blur PostProcess id in the pipeline
  122064. */
  122065. SSAOBlurVRenderEffect: string;
  122066. /**
  122067. * @ignore
  122068. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122069. */
  122070. SSAOCombineRenderEffect: string;
  122071. /**
  122072. * The output strength of the SSAO post-process. Default value is 1.0.
  122073. */
  122074. totalStrength: number;
  122075. /**
  122076. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  122077. */
  122078. radius: number;
  122079. /**
  122080. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  122081. * Must not be equal to fallOff and superior to fallOff.
  122082. * Default value is 0.0075
  122083. */
  122084. area: number;
  122085. /**
  122086. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  122087. * Must not be equal to area and inferior to area.
  122088. * Default value is 0.000001
  122089. */
  122090. fallOff: number;
  122091. /**
  122092. * The base color of the SSAO post-process
  122093. * The final result is "base + ssao" between [0, 1]
  122094. */
  122095. base: number;
  122096. private _scene;
  122097. private _depthTexture;
  122098. private _randomTexture;
  122099. private _originalColorPostProcess;
  122100. private _ssaoPostProcess;
  122101. private _blurHPostProcess;
  122102. private _blurVPostProcess;
  122103. private _ssaoCombinePostProcess;
  122104. private _firstUpdate;
  122105. /**
  122106. * Gets active scene
  122107. */
  122108. readonly scene: Scene;
  122109. /**
  122110. * @constructor
  122111. * @param name - The rendering pipeline name
  122112. * @param scene - The scene linked to this pipeline
  122113. * @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 }
  122114. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122115. */
  122116. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122117. /**
  122118. * Get the class name
  122119. * @returns "SSAORenderingPipeline"
  122120. */
  122121. getClassName(): string;
  122122. /**
  122123. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122124. */
  122125. dispose(disableDepthRender?: boolean): void;
  122126. private _createBlurPostProcess;
  122127. /** @hidden */
  122128. _rebuild(): void;
  122129. private _createSSAOPostProcess;
  122130. private _createSSAOCombinePostProcess;
  122131. private _createRandomTexture;
  122132. }
  122133. }
  122134. declare module BABYLON {
  122135. /** @hidden */
  122136. export var standardPixelShader: {
  122137. name: string;
  122138. shader: string;
  122139. };
  122140. }
  122141. declare module BABYLON {
  122142. /**
  122143. * Standard rendering pipeline
  122144. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122145. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122146. */
  122147. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122148. /**
  122149. * Public members
  122150. */
  122151. /**
  122152. * Post-process which contains the original scene color before the pipeline applies all the effects
  122153. */
  122154. originalPostProcess: Nullable<PostProcess>;
  122155. /**
  122156. * Post-process used to down scale an image x4
  122157. */
  122158. downSampleX4PostProcess: Nullable<PostProcess>;
  122159. /**
  122160. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122161. */
  122162. brightPassPostProcess: Nullable<PostProcess>;
  122163. /**
  122164. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122165. */
  122166. blurHPostProcesses: PostProcess[];
  122167. /**
  122168. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122169. */
  122170. blurVPostProcesses: PostProcess[];
  122171. /**
  122172. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122173. */
  122174. textureAdderPostProcess: Nullable<PostProcess>;
  122175. /**
  122176. * Post-process used to create volumetric lighting effect
  122177. */
  122178. volumetricLightPostProcess: Nullable<PostProcess>;
  122179. /**
  122180. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122181. */
  122182. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  122183. /**
  122184. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122185. */
  122186. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  122187. /**
  122188. * Post-process used to merge the volumetric light effect and the real scene color
  122189. */
  122190. volumetricLightMergePostProces: Nullable<PostProcess>;
  122191. /**
  122192. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  122193. */
  122194. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  122195. /**
  122196. * Base post-process used to calculate the average luminance of the final image for HDR
  122197. */
  122198. luminancePostProcess: Nullable<PostProcess>;
  122199. /**
  122200. * Post-processes used to create down sample post-processes in order to get
  122201. * the average luminance of the final image for HDR
  122202. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  122203. */
  122204. luminanceDownSamplePostProcesses: PostProcess[];
  122205. /**
  122206. * Post-process used to create a HDR effect (light adaptation)
  122207. */
  122208. hdrPostProcess: Nullable<PostProcess>;
  122209. /**
  122210. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  122211. */
  122212. textureAdderFinalPostProcess: Nullable<PostProcess>;
  122213. /**
  122214. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  122215. */
  122216. lensFlareFinalPostProcess: Nullable<PostProcess>;
  122217. /**
  122218. * Post-process used to merge the final HDR post-process and the real scene color
  122219. */
  122220. hdrFinalPostProcess: Nullable<PostProcess>;
  122221. /**
  122222. * Post-process used to create a lens flare effect
  122223. */
  122224. lensFlarePostProcess: Nullable<PostProcess>;
  122225. /**
  122226. * Post-process that merges the result of the lens flare post-process and the real scene color
  122227. */
  122228. lensFlareComposePostProcess: Nullable<PostProcess>;
  122229. /**
  122230. * Post-process used to create a motion blur effect
  122231. */
  122232. motionBlurPostProcess: Nullable<PostProcess>;
  122233. /**
  122234. * Post-process used to create a depth of field effect
  122235. */
  122236. depthOfFieldPostProcess: Nullable<PostProcess>;
  122237. /**
  122238. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122239. */
  122240. fxaaPostProcess: Nullable<FxaaPostProcess>;
  122241. /**
  122242. * Represents the brightness threshold in order to configure the illuminated surfaces
  122243. */
  122244. brightThreshold: number;
  122245. /**
  122246. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  122247. */
  122248. blurWidth: number;
  122249. /**
  122250. * Sets if the blur for highlighted surfaces must be only horizontal
  122251. */
  122252. horizontalBlur: boolean;
  122253. /**
  122254. * Gets the overall exposure used by the pipeline
  122255. */
  122256. /**
  122257. * Sets the overall exposure used by the pipeline
  122258. */
  122259. exposure: number;
  122260. /**
  122261. * Texture used typically to simulate "dirty" on camera lens
  122262. */
  122263. lensTexture: Nullable<Texture>;
  122264. /**
  122265. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  122266. */
  122267. volumetricLightCoefficient: number;
  122268. /**
  122269. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  122270. */
  122271. volumetricLightPower: number;
  122272. /**
  122273. * Used the set the blur intensity to smooth the volumetric lights
  122274. */
  122275. volumetricLightBlurScale: number;
  122276. /**
  122277. * Light (spot or directional) used to generate the volumetric lights rays
  122278. * The source light must have a shadow generate so the pipeline can get its
  122279. * depth map
  122280. */
  122281. sourceLight: Nullable<SpotLight | DirectionalLight>;
  122282. /**
  122283. * For eye adaptation, represents the minimum luminance the eye can see
  122284. */
  122285. hdrMinimumLuminance: number;
  122286. /**
  122287. * For eye adaptation, represents the decrease luminance speed
  122288. */
  122289. hdrDecreaseRate: number;
  122290. /**
  122291. * For eye adaptation, represents the increase luminance speed
  122292. */
  122293. hdrIncreaseRate: number;
  122294. /**
  122295. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122296. */
  122297. /**
  122298. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122299. */
  122300. hdrAutoExposure: boolean;
  122301. /**
  122302. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  122303. */
  122304. lensColorTexture: Nullable<Texture>;
  122305. /**
  122306. * The overall strengh for the lens flare effect
  122307. */
  122308. lensFlareStrength: number;
  122309. /**
  122310. * Dispersion coefficient for lens flare ghosts
  122311. */
  122312. lensFlareGhostDispersal: number;
  122313. /**
  122314. * Main lens flare halo width
  122315. */
  122316. lensFlareHaloWidth: number;
  122317. /**
  122318. * Based on the lens distortion effect, defines how much the lens flare result
  122319. * is distorted
  122320. */
  122321. lensFlareDistortionStrength: number;
  122322. /**
  122323. * Lens star texture must be used to simulate rays on the flares and is available
  122324. * in the documentation
  122325. */
  122326. lensStarTexture: Nullable<Texture>;
  122327. /**
  122328. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  122329. * flare effect by taking account of the dirt texture
  122330. */
  122331. lensFlareDirtTexture: Nullable<Texture>;
  122332. /**
  122333. * Represents the focal length for the depth of field effect
  122334. */
  122335. depthOfFieldDistance: number;
  122336. /**
  122337. * Represents the blur intensity for the blurred part of the depth of field effect
  122338. */
  122339. depthOfFieldBlurWidth: number;
  122340. /**
  122341. * Gets how much the image is blurred by the movement while using the motion blur post-process
  122342. */
  122343. /**
  122344. * Sets how much the image is blurred by the movement while using the motion blur post-process
  122345. */
  122346. motionStrength: number;
  122347. /**
  122348. * Gets wether or not the motion blur post-process is object based or screen based.
  122349. */
  122350. /**
  122351. * Sets wether or not the motion blur post-process should be object based or screen based
  122352. */
  122353. objectBasedMotionBlur: boolean;
  122354. /**
  122355. * List of animations for the pipeline (IAnimatable implementation)
  122356. */
  122357. animations: Animation[];
  122358. /**
  122359. * Private members
  122360. */
  122361. private _scene;
  122362. private _currentDepthOfFieldSource;
  122363. private _basePostProcess;
  122364. private _fixedExposure;
  122365. private _currentExposure;
  122366. private _hdrAutoExposure;
  122367. private _hdrCurrentLuminance;
  122368. private _motionStrength;
  122369. private _isObjectBasedMotionBlur;
  122370. private _floatTextureType;
  122371. private _ratio;
  122372. private _bloomEnabled;
  122373. private _depthOfFieldEnabled;
  122374. private _vlsEnabled;
  122375. private _lensFlareEnabled;
  122376. private _hdrEnabled;
  122377. private _motionBlurEnabled;
  122378. private _fxaaEnabled;
  122379. private _motionBlurSamples;
  122380. private _volumetricLightStepsCount;
  122381. private _samples;
  122382. /**
  122383. * @ignore
  122384. * Specifies if the bloom pipeline is enabled
  122385. */
  122386. BloomEnabled: boolean;
  122387. /**
  122388. * @ignore
  122389. * Specifies if the depth of field pipeline is enabed
  122390. */
  122391. DepthOfFieldEnabled: boolean;
  122392. /**
  122393. * @ignore
  122394. * Specifies if the lens flare pipeline is enabed
  122395. */
  122396. LensFlareEnabled: boolean;
  122397. /**
  122398. * @ignore
  122399. * Specifies if the HDR pipeline is enabled
  122400. */
  122401. HDREnabled: boolean;
  122402. /**
  122403. * @ignore
  122404. * Specifies if the volumetric lights scattering effect is enabled
  122405. */
  122406. VLSEnabled: boolean;
  122407. /**
  122408. * @ignore
  122409. * Specifies if the motion blur effect is enabled
  122410. */
  122411. MotionBlurEnabled: boolean;
  122412. /**
  122413. * Specifies if anti-aliasing is enabled
  122414. */
  122415. fxaaEnabled: boolean;
  122416. /**
  122417. * Specifies the number of steps used to calculate the volumetric lights
  122418. * Typically in interval [50, 200]
  122419. */
  122420. volumetricLightStepsCount: number;
  122421. /**
  122422. * Specifies the number of samples used for the motion blur effect
  122423. * Typically in interval [16, 64]
  122424. */
  122425. motionBlurSamples: number;
  122426. /**
  122427. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122428. */
  122429. samples: number;
  122430. /**
  122431. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122432. * @constructor
  122433. * @param name The rendering pipeline name
  122434. * @param scene The scene linked to this pipeline
  122435. * @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)
  122436. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122437. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122438. */
  122439. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122440. private _buildPipeline;
  122441. private _createDownSampleX4PostProcess;
  122442. private _createBrightPassPostProcess;
  122443. private _createBlurPostProcesses;
  122444. private _createTextureAdderPostProcess;
  122445. private _createVolumetricLightPostProcess;
  122446. private _createLuminancePostProcesses;
  122447. private _createHdrPostProcess;
  122448. private _createLensFlarePostProcess;
  122449. private _createDepthOfFieldPostProcess;
  122450. private _createMotionBlurPostProcess;
  122451. private _getDepthTexture;
  122452. private _disposePostProcesses;
  122453. /**
  122454. * Dispose of the pipeline and stop all post processes
  122455. */
  122456. dispose(): void;
  122457. /**
  122458. * Serialize the rendering pipeline (Used when exporting)
  122459. * @returns the serialized object
  122460. */
  122461. serialize(): any;
  122462. /**
  122463. * Parse the serialized pipeline
  122464. * @param source Source pipeline.
  122465. * @param scene The scene to load the pipeline to.
  122466. * @param rootUrl The URL of the serialized pipeline.
  122467. * @returns An instantiated pipeline from the serialized object.
  122468. */
  122469. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122470. /**
  122471. * Luminance steps
  122472. */
  122473. static LuminanceSteps: number;
  122474. }
  122475. }
  122476. declare module BABYLON {
  122477. /** @hidden */
  122478. export var tonemapPixelShader: {
  122479. name: string;
  122480. shader: string;
  122481. };
  122482. }
  122483. declare module BABYLON {
  122484. /** Defines operator used for tonemapping */
  122485. export enum TonemappingOperator {
  122486. /** Hable */
  122487. Hable = 0,
  122488. /** Reinhard */
  122489. Reinhard = 1,
  122490. /** HejiDawson */
  122491. HejiDawson = 2,
  122492. /** Photographic */
  122493. Photographic = 3
  122494. }
  122495. /**
  122496. * Defines a post process to apply tone mapping
  122497. */
  122498. export class TonemapPostProcess extends PostProcess {
  122499. private _operator;
  122500. /** Defines the required exposure adjustement */
  122501. exposureAdjustment: number;
  122502. /**
  122503. * Creates a new TonemapPostProcess
  122504. * @param name defines the name of the postprocess
  122505. * @param _operator defines the operator to use
  122506. * @param exposureAdjustment defines the required exposure adjustement
  122507. * @param camera defines the camera to use (can be null)
  122508. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  122509. * @param engine defines the hosting engine (can be ignore if camera is set)
  122510. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122511. */
  122512. constructor(name: string, _operator: TonemappingOperator,
  122513. /** Defines the required exposure adjustement */
  122514. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  122515. }
  122516. }
  122517. declare module BABYLON {
  122518. /** @hidden */
  122519. export var depthVertexShader: {
  122520. name: string;
  122521. shader: string;
  122522. };
  122523. }
  122524. declare module BABYLON {
  122525. /** @hidden */
  122526. export var volumetricLightScatteringPixelShader: {
  122527. name: string;
  122528. shader: string;
  122529. };
  122530. }
  122531. declare module BABYLON {
  122532. /** @hidden */
  122533. export var volumetricLightScatteringPassVertexShader: {
  122534. name: string;
  122535. shader: string;
  122536. };
  122537. }
  122538. declare module BABYLON {
  122539. /** @hidden */
  122540. export var volumetricLightScatteringPassPixelShader: {
  122541. name: string;
  122542. shader: string;
  122543. };
  122544. }
  122545. declare module BABYLON {
  122546. /**
  122547. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  122548. */
  122549. export class VolumetricLightScatteringPostProcess extends PostProcess {
  122550. private _volumetricLightScatteringPass;
  122551. private _volumetricLightScatteringRTT;
  122552. private _viewPort;
  122553. private _screenCoordinates;
  122554. private _cachedDefines;
  122555. /**
  122556. * If not undefined, the mesh position is computed from the attached node position
  122557. */
  122558. attachedNode: {
  122559. position: Vector3;
  122560. };
  122561. /**
  122562. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  122563. */
  122564. customMeshPosition: Vector3;
  122565. /**
  122566. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  122567. */
  122568. useCustomMeshPosition: boolean;
  122569. /**
  122570. * If the post-process should inverse the light scattering direction
  122571. */
  122572. invert: boolean;
  122573. /**
  122574. * The internal mesh used by the post-process
  122575. */
  122576. mesh: Mesh;
  122577. /**
  122578. * @hidden
  122579. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  122580. */
  122581. useDiffuseColor: boolean;
  122582. /**
  122583. * Array containing the excluded meshes not rendered in the internal pass
  122584. */
  122585. excludedMeshes: AbstractMesh[];
  122586. /**
  122587. * Controls the overall intensity of the post-process
  122588. */
  122589. exposure: number;
  122590. /**
  122591. * Dissipates each sample's contribution in range [0, 1]
  122592. */
  122593. decay: number;
  122594. /**
  122595. * Controls the overall intensity of each sample
  122596. */
  122597. weight: number;
  122598. /**
  122599. * Controls the density of each sample
  122600. */
  122601. density: number;
  122602. /**
  122603. * @constructor
  122604. * @param name The post-process name
  122605. * @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)
  122606. * @param camera The camera that the post-process will be attached to
  122607. * @param mesh The mesh used to create the light scattering
  122608. * @param samples The post-process quality, default 100
  122609. * @param samplingModeThe post-process filtering mode
  122610. * @param engine The babylon engine
  122611. * @param reusable If the post-process is reusable
  122612. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  122613. */
  122614. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  122615. /**
  122616. * Returns the string "VolumetricLightScatteringPostProcess"
  122617. * @returns "VolumetricLightScatteringPostProcess"
  122618. */
  122619. getClassName(): string;
  122620. private _isReady;
  122621. /**
  122622. * Sets the new light position for light scattering effect
  122623. * @param position The new custom light position
  122624. */
  122625. setCustomMeshPosition(position: Vector3): void;
  122626. /**
  122627. * Returns the light position for light scattering effect
  122628. * @return Vector3 The custom light position
  122629. */
  122630. getCustomMeshPosition(): Vector3;
  122631. /**
  122632. * Disposes the internal assets and detaches the post-process from the camera
  122633. */
  122634. dispose(camera: Camera): void;
  122635. /**
  122636. * Returns the render target texture used by the post-process
  122637. * @return the render target texture used by the post-process
  122638. */
  122639. getPass(): RenderTargetTexture;
  122640. private _meshExcluded;
  122641. private _createPass;
  122642. private _updateMeshScreenCoordinates;
  122643. /**
  122644. * Creates a default mesh for the Volumeric Light Scattering post-process
  122645. * @param name The mesh name
  122646. * @param scene The scene where to create the mesh
  122647. * @return the default mesh
  122648. */
  122649. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  122650. }
  122651. }
  122652. declare module BABYLON {
  122653. interface Scene {
  122654. /** @hidden (Backing field) */
  122655. _boundingBoxRenderer: BoundingBoxRenderer;
  122656. /** @hidden (Backing field) */
  122657. _forceShowBoundingBoxes: boolean;
  122658. /**
  122659. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  122660. */
  122661. forceShowBoundingBoxes: boolean;
  122662. /**
  122663. * Gets the bounding box renderer associated with the scene
  122664. * @returns a BoundingBoxRenderer
  122665. */
  122666. getBoundingBoxRenderer(): BoundingBoxRenderer;
  122667. }
  122668. interface AbstractMesh {
  122669. /** @hidden (Backing field) */
  122670. _showBoundingBox: boolean;
  122671. /**
  122672. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  122673. */
  122674. showBoundingBox: boolean;
  122675. }
  122676. /**
  122677. * Component responsible of rendering the bounding box of the meshes in a scene.
  122678. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122679. */
  122680. export class BoundingBoxRenderer implements ISceneComponent {
  122681. /**
  122682. * The component name helpfull to identify the component in the list of scene components.
  122683. */
  122684. readonly name: string;
  122685. /**
  122686. * The scene the component belongs to.
  122687. */
  122688. scene: Scene;
  122689. /**
  122690. * Color of the bounding box lines placed in front of an object
  122691. */
  122692. frontColor: Color3;
  122693. /**
  122694. * Color of the bounding box lines placed behind an object
  122695. */
  122696. backColor: Color3;
  122697. /**
  122698. * Defines if the renderer should show the back lines or not
  122699. */
  122700. showBackLines: boolean;
  122701. /**
  122702. * @hidden
  122703. */
  122704. renderList: SmartArray<BoundingBox>;
  122705. private _colorShader;
  122706. private _vertexBuffers;
  122707. private _indexBuffer;
  122708. private _fillIndexBuffer;
  122709. private _fillIndexData;
  122710. /**
  122711. * Instantiates a new bounding box renderer in a scene.
  122712. * @param scene the scene the renderer renders in
  122713. */
  122714. constructor(scene: Scene);
  122715. /**
  122716. * Registers the component in a given scene
  122717. */
  122718. register(): void;
  122719. private _evaluateSubMesh;
  122720. private _activeMesh;
  122721. private _prepareRessources;
  122722. private _createIndexBuffer;
  122723. /**
  122724. * Rebuilds the elements related to this component in case of
  122725. * context lost for instance.
  122726. */
  122727. rebuild(): void;
  122728. /**
  122729. * @hidden
  122730. */
  122731. reset(): void;
  122732. /**
  122733. * Render the bounding boxes of a specific rendering group
  122734. * @param renderingGroupId defines the rendering group to render
  122735. */
  122736. render(renderingGroupId: number): void;
  122737. /**
  122738. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122739. * @param mesh Define the mesh to render the occlusion bounding box for
  122740. */
  122741. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  122742. /**
  122743. * Dispose and release the resources attached to this renderer.
  122744. */
  122745. dispose(): void;
  122746. }
  122747. }
  122748. declare module BABYLON {
  122749. /** @hidden */
  122750. export var depthPixelShader: {
  122751. name: string;
  122752. shader: string;
  122753. };
  122754. }
  122755. declare module BABYLON {
  122756. /**
  122757. * This represents a depth renderer in Babylon.
  122758. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122759. */
  122760. export class DepthRenderer {
  122761. private _scene;
  122762. private _depthMap;
  122763. private _effect;
  122764. private readonly _storeNonLinearDepth;
  122765. private readonly _clearColor;
  122766. /** Get if the depth renderer is using packed depth or not */
  122767. readonly isPacked: boolean;
  122768. private _cachedDefines;
  122769. private _camera;
  122770. /**
  122771. * Specifiess that the depth renderer will only be used within
  122772. * the camera it is created for.
  122773. * This can help forcing its rendering during the camera processing.
  122774. */
  122775. useOnlyInActiveCamera: boolean;
  122776. /** @hidden */
  122777. static _SceneComponentInitialization: (scene: Scene) => void;
  122778. /**
  122779. * Instantiates a depth renderer
  122780. * @param scene The scene the renderer belongs to
  122781. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122782. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122783. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122784. */
  122785. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  122786. /**
  122787. * Creates the depth rendering effect and checks if the effect is ready.
  122788. * @param subMesh The submesh to be used to render the depth map of
  122789. * @param useInstances If multiple world instances should be used
  122790. * @returns if the depth renderer is ready to render the depth map
  122791. */
  122792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122793. /**
  122794. * Gets the texture which the depth map will be written to.
  122795. * @returns The depth map texture
  122796. */
  122797. getDepthMap(): RenderTargetTexture;
  122798. /**
  122799. * Disposes of the depth renderer.
  122800. */
  122801. dispose(): void;
  122802. }
  122803. }
  122804. declare module BABYLON {
  122805. interface Scene {
  122806. /** @hidden (Backing field) */
  122807. _depthRenderer: {
  122808. [id: string]: DepthRenderer;
  122809. };
  122810. /**
  122811. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  122812. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  122813. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122814. * @returns the created depth renderer
  122815. */
  122816. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  122817. /**
  122818. * Disables a depth renderer for a given camera
  122819. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  122820. */
  122821. disableDepthRenderer(camera?: Nullable<Camera>): void;
  122822. }
  122823. /**
  122824. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122825. * in several rendering techniques.
  122826. */
  122827. export class DepthRendererSceneComponent implements ISceneComponent {
  122828. /**
  122829. * The component name helpfull to identify the component in the list of scene components.
  122830. */
  122831. readonly name: string;
  122832. /**
  122833. * The scene the component belongs to.
  122834. */
  122835. scene: Scene;
  122836. /**
  122837. * Creates a new instance of the component for the given scene
  122838. * @param scene Defines the scene to register the component in
  122839. */
  122840. constructor(scene: Scene);
  122841. /**
  122842. * Registers the component in a given scene
  122843. */
  122844. register(): void;
  122845. /**
  122846. * Rebuilds the elements related to this component in case of
  122847. * context lost for instance.
  122848. */
  122849. rebuild(): void;
  122850. /**
  122851. * Disposes the component and the associated ressources
  122852. */
  122853. dispose(): void;
  122854. private _gatherRenderTargets;
  122855. private _gatherActiveCameraRenderTargets;
  122856. }
  122857. }
  122858. declare module BABYLON {
  122859. /** @hidden */
  122860. export var outlinePixelShader: {
  122861. name: string;
  122862. shader: string;
  122863. };
  122864. }
  122865. declare module BABYLON {
  122866. /** @hidden */
  122867. export var outlineVertexShader: {
  122868. name: string;
  122869. shader: string;
  122870. };
  122871. }
  122872. declare module BABYLON {
  122873. interface Scene {
  122874. /** @hidden */
  122875. _outlineRenderer: OutlineRenderer;
  122876. /**
  122877. * Gets the outline renderer associated with the scene
  122878. * @returns a OutlineRenderer
  122879. */
  122880. getOutlineRenderer(): OutlineRenderer;
  122881. }
  122882. interface AbstractMesh {
  122883. /** @hidden (Backing field) */
  122884. _renderOutline: boolean;
  122885. /**
  122886. * Gets or sets a boolean indicating if the outline must be rendered as well
  122887. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  122888. */
  122889. renderOutline: boolean;
  122890. /** @hidden (Backing field) */
  122891. _renderOverlay: boolean;
  122892. /**
  122893. * Gets or sets a boolean indicating if the overlay must be rendered as well
  122894. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  122895. */
  122896. renderOverlay: boolean;
  122897. }
  122898. /**
  122899. * This class is responsible to draw bothe outline/overlay of meshes.
  122900. * It should not be used directly but through the available method on mesh.
  122901. */
  122902. export class OutlineRenderer implements ISceneComponent {
  122903. /**
  122904. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  122905. */
  122906. private static _StencilReference;
  122907. /**
  122908. * The name of the component. Each component must have a unique name.
  122909. */
  122910. name: string;
  122911. /**
  122912. * The scene the component belongs to.
  122913. */
  122914. scene: Scene;
  122915. /**
  122916. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122917. */
  122918. zOffset: number;
  122919. private _engine;
  122920. private _effect;
  122921. private _cachedDefines;
  122922. private _savedDepthWrite;
  122923. /**
  122924. * Instantiates a new outline renderer. (There could be only one per scene).
  122925. * @param scene Defines the scene it belongs to
  122926. */
  122927. constructor(scene: Scene);
  122928. /**
  122929. * Register the component to one instance of a scene.
  122930. */
  122931. register(): void;
  122932. /**
  122933. * Rebuilds the elements related to this component in case of
  122934. * context lost for instance.
  122935. */
  122936. rebuild(): void;
  122937. /**
  122938. * Disposes the component and the associated ressources.
  122939. */
  122940. dispose(): void;
  122941. /**
  122942. * Renders the outline in the canvas.
  122943. * @param subMesh Defines the sumesh to render
  122944. * @param batch Defines the batch of meshes in case of instances
  122945. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122946. */
  122947. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  122948. /**
  122949. * Returns whether or not the outline renderer is ready for a given submesh.
  122950. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122951. * @param subMesh Defines the submesh to check readyness for
  122952. * @param useInstances Defines wheter wee are trying to render instances or not
  122953. * @returns true if ready otherwise false
  122954. */
  122955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122956. private _beforeRenderingMesh;
  122957. private _afterRenderingMesh;
  122958. }
  122959. }
  122960. declare module BABYLON {
  122961. /**
  122962. * Defines the list of states available for a task inside a AssetsManager
  122963. */
  122964. export enum AssetTaskState {
  122965. /**
  122966. * Initialization
  122967. */
  122968. INIT = 0,
  122969. /**
  122970. * Running
  122971. */
  122972. RUNNING = 1,
  122973. /**
  122974. * Done
  122975. */
  122976. DONE = 2,
  122977. /**
  122978. * Error
  122979. */
  122980. ERROR = 3
  122981. }
  122982. /**
  122983. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  122984. */
  122985. export abstract class AbstractAssetTask {
  122986. /**
  122987. * Task name
  122988. */ name: string;
  122989. /**
  122990. * Callback called when the task is successful
  122991. */
  122992. onSuccess: (task: any) => void;
  122993. /**
  122994. * Callback called when the task is not successful
  122995. */
  122996. onError: (task: any, message?: string, exception?: any) => void;
  122997. /**
  122998. * Creates a new AssetsManager
  122999. * @param name defines the name of the task
  123000. */
  123001. constructor(
  123002. /**
  123003. * Task name
  123004. */ name: string);
  123005. private _isCompleted;
  123006. private _taskState;
  123007. private _errorObject;
  123008. /**
  123009. * Get if the task is completed
  123010. */
  123011. readonly isCompleted: boolean;
  123012. /**
  123013. * Gets the current state of the task
  123014. */
  123015. readonly taskState: AssetTaskState;
  123016. /**
  123017. * Gets the current error object (if task is in error)
  123018. */
  123019. readonly errorObject: {
  123020. message?: string;
  123021. exception?: any;
  123022. };
  123023. /**
  123024. * Internal only
  123025. * @hidden
  123026. */
  123027. _setErrorObject(message?: string, exception?: any): void;
  123028. /**
  123029. * Execute the current task
  123030. * @param scene defines the scene where you want your assets to be loaded
  123031. * @param onSuccess is a callback called when the task is successfully executed
  123032. * @param onError is a callback called if an error occurs
  123033. */
  123034. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123035. /**
  123036. * Execute the current task
  123037. * @param scene defines the scene where you want your assets to be loaded
  123038. * @param onSuccess is a callback called when the task is successfully executed
  123039. * @param onError is a callback called if an error occurs
  123040. */
  123041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123042. /**
  123043. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  123044. * This can be used with failed tasks that have the reason for failure fixed.
  123045. */
  123046. reset(): void;
  123047. private onErrorCallback;
  123048. private onDoneCallback;
  123049. }
  123050. /**
  123051. * Define the interface used by progress events raised during assets loading
  123052. */
  123053. export interface IAssetsProgressEvent {
  123054. /**
  123055. * Defines the number of remaining tasks to process
  123056. */
  123057. remainingCount: number;
  123058. /**
  123059. * Defines the total number of tasks
  123060. */
  123061. totalCount: number;
  123062. /**
  123063. * Defines the task that was just processed
  123064. */
  123065. task: AbstractAssetTask;
  123066. }
  123067. /**
  123068. * Class used to share progress information about assets loading
  123069. */
  123070. export class AssetsProgressEvent implements IAssetsProgressEvent {
  123071. /**
  123072. * Defines the number of remaining tasks to process
  123073. */
  123074. remainingCount: number;
  123075. /**
  123076. * Defines the total number of tasks
  123077. */
  123078. totalCount: number;
  123079. /**
  123080. * Defines the task that was just processed
  123081. */
  123082. task: AbstractAssetTask;
  123083. /**
  123084. * Creates a AssetsProgressEvent
  123085. * @param remainingCount defines the number of remaining tasks to process
  123086. * @param totalCount defines the total number of tasks
  123087. * @param task defines the task that was just processed
  123088. */
  123089. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  123090. }
  123091. /**
  123092. * Define a task used by AssetsManager to load meshes
  123093. */
  123094. export class MeshAssetTask extends AbstractAssetTask {
  123095. /**
  123096. * Defines the name of the task
  123097. */
  123098. name: string;
  123099. /**
  123100. * Defines the list of mesh's names you want to load
  123101. */
  123102. meshesNames: any;
  123103. /**
  123104. * Defines the root url to use as a base to load your meshes and associated resources
  123105. */
  123106. rootUrl: string;
  123107. /**
  123108. * Defines the filename of the scene to load from
  123109. */
  123110. sceneFilename: string;
  123111. /**
  123112. * Gets the list of loaded meshes
  123113. */
  123114. loadedMeshes: Array<AbstractMesh>;
  123115. /**
  123116. * Gets the list of loaded particle systems
  123117. */
  123118. loadedParticleSystems: Array<IParticleSystem>;
  123119. /**
  123120. * Gets the list of loaded skeletons
  123121. */
  123122. loadedSkeletons: Array<Skeleton>;
  123123. /**
  123124. * Gets the list of loaded animation groups
  123125. */
  123126. loadedAnimationGroups: Array<AnimationGroup>;
  123127. /**
  123128. * Callback called when the task is successful
  123129. */
  123130. onSuccess: (task: MeshAssetTask) => void;
  123131. /**
  123132. * Callback called when the task is successful
  123133. */
  123134. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  123135. /**
  123136. * Creates a new MeshAssetTask
  123137. * @param name defines the name of the task
  123138. * @param meshesNames defines the list of mesh's names you want to load
  123139. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  123140. * @param sceneFilename defines the filename of the scene to load from
  123141. */
  123142. constructor(
  123143. /**
  123144. * Defines the name of the task
  123145. */
  123146. name: string,
  123147. /**
  123148. * Defines the list of mesh's names you want to load
  123149. */
  123150. meshesNames: any,
  123151. /**
  123152. * Defines the root url to use as a base to load your meshes and associated resources
  123153. */
  123154. rootUrl: string,
  123155. /**
  123156. * Defines the filename of the scene to load from
  123157. */
  123158. sceneFilename: string);
  123159. /**
  123160. * Execute the current task
  123161. * @param scene defines the scene where you want your assets to be loaded
  123162. * @param onSuccess is a callback called when the task is successfully executed
  123163. * @param onError is a callback called if an error occurs
  123164. */
  123165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123166. }
  123167. /**
  123168. * Define a task used by AssetsManager to load text content
  123169. */
  123170. export class TextFileAssetTask extends AbstractAssetTask {
  123171. /**
  123172. * Defines the name of the task
  123173. */
  123174. name: string;
  123175. /**
  123176. * Defines the location of the file to load
  123177. */
  123178. url: string;
  123179. /**
  123180. * Gets the loaded text string
  123181. */
  123182. text: string;
  123183. /**
  123184. * Callback called when the task is successful
  123185. */
  123186. onSuccess: (task: TextFileAssetTask) => void;
  123187. /**
  123188. * Callback called when the task is successful
  123189. */
  123190. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  123191. /**
  123192. * Creates a new TextFileAssetTask object
  123193. * @param name defines the name of the task
  123194. * @param url defines the location of the file to load
  123195. */
  123196. constructor(
  123197. /**
  123198. * Defines the name of the task
  123199. */
  123200. name: string,
  123201. /**
  123202. * Defines the location of the file to load
  123203. */
  123204. url: string);
  123205. /**
  123206. * Execute the current task
  123207. * @param scene defines the scene where you want your assets to be loaded
  123208. * @param onSuccess is a callback called when the task is successfully executed
  123209. * @param onError is a callback called if an error occurs
  123210. */
  123211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123212. }
  123213. /**
  123214. * Define a task used by AssetsManager to load binary data
  123215. */
  123216. export class BinaryFileAssetTask extends AbstractAssetTask {
  123217. /**
  123218. * Defines the name of the task
  123219. */
  123220. name: string;
  123221. /**
  123222. * Defines the location of the file to load
  123223. */
  123224. url: string;
  123225. /**
  123226. * Gets the lodaded data (as an array buffer)
  123227. */
  123228. data: ArrayBuffer;
  123229. /**
  123230. * Callback called when the task is successful
  123231. */
  123232. onSuccess: (task: BinaryFileAssetTask) => void;
  123233. /**
  123234. * Callback called when the task is successful
  123235. */
  123236. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  123237. /**
  123238. * Creates a new BinaryFileAssetTask object
  123239. * @param name defines the name of the new task
  123240. * @param url defines the location of the file to load
  123241. */
  123242. constructor(
  123243. /**
  123244. * Defines the name of the task
  123245. */
  123246. name: string,
  123247. /**
  123248. * Defines the location of the file to load
  123249. */
  123250. url: string);
  123251. /**
  123252. * Execute the current task
  123253. * @param scene defines the scene where you want your assets to be loaded
  123254. * @param onSuccess is a callback called when the task is successfully executed
  123255. * @param onError is a callback called if an error occurs
  123256. */
  123257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123258. }
  123259. /**
  123260. * Define a task used by AssetsManager to load images
  123261. */
  123262. export class ImageAssetTask extends AbstractAssetTask {
  123263. /**
  123264. * Defines the name of the task
  123265. */
  123266. name: string;
  123267. /**
  123268. * Defines the location of the image to load
  123269. */
  123270. url: string;
  123271. /**
  123272. * Gets the loaded images
  123273. */
  123274. image: HTMLImageElement;
  123275. /**
  123276. * Callback called when the task is successful
  123277. */
  123278. onSuccess: (task: ImageAssetTask) => void;
  123279. /**
  123280. * Callback called when the task is successful
  123281. */
  123282. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  123283. /**
  123284. * Creates a new ImageAssetTask
  123285. * @param name defines the name of the task
  123286. * @param url defines the location of the image to load
  123287. */
  123288. constructor(
  123289. /**
  123290. * Defines the name of the task
  123291. */
  123292. name: string,
  123293. /**
  123294. * Defines the location of the image to load
  123295. */
  123296. url: string);
  123297. /**
  123298. * Execute the current task
  123299. * @param scene defines the scene where you want your assets to be loaded
  123300. * @param onSuccess is a callback called when the task is successfully executed
  123301. * @param onError is a callback called if an error occurs
  123302. */
  123303. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123304. }
  123305. /**
  123306. * Defines the interface used by texture loading tasks
  123307. */
  123308. export interface ITextureAssetTask<TEX extends BaseTexture> {
  123309. /**
  123310. * Gets the loaded texture
  123311. */
  123312. texture: TEX;
  123313. }
  123314. /**
  123315. * Define a task used by AssetsManager to load 2D textures
  123316. */
  123317. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  123318. /**
  123319. * Defines the name of the task
  123320. */
  123321. name: string;
  123322. /**
  123323. * Defines the location of the file to load
  123324. */
  123325. url: string;
  123326. /**
  123327. * Defines if mipmap should not be generated (default is false)
  123328. */
  123329. noMipmap?: boolean | undefined;
  123330. /**
  123331. * Defines if texture must be inverted on Y axis (default is false)
  123332. */
  123333. invertY?: boolean | undefined;
  123334. /**
  123335. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123336. */
  123337. samplingMode: number;
  123338. /**
  123339. * Gets the loaded texture
  123340. */
  123341. texture: Texture;
  123342. /**
  123343. * Callback called when the task is successful
  123344. */
  123345. onSuccess: (task: TextureAssetTask) => void;
  123346. /**
  123347. * Callback called when the task is successful
  123348. */
  123349. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  123350. /**
  123351. * Creates a new TextureAssetTask object
  123352. * @param name defines the name of the task
  123353. * @param url defines the location of the file to load
  123354. * @param noMipmap defines if mipmap should not be generated (default is false)
  123355. * @param invertY defines if texture must be inverted on Y axis (default is false)
  123356. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123357. */
  123358. constructor(
  123359. /**
  123360. * Defines the name of the task
  123361. */
  123362. name: string,
  123363. /**
  123364. * Defines the location of the file to load
  123365. */
  123366. url: string,
  123367. /**
  123368. * Defines if mipmap should not be generated (default is false)
  123369. */
  123370. noMipmap?: boolean | undefined,
  123371. /**
  123372. * Defines if texture must be inverted on Y axis (default is false)
  123373. */
  123374. invertY?: boolean | undefined,
  123375. /**
  123376. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123377. */
  123378. samplingMode?: number);
  123379. /**
  123380. * Execute the current task
  123381. * @param scene defines the scene where you want your assets to be loaded
  123382. * @param onSuccess is a callback called when the task is successfully executed
  123383. * @param onError is a callback called if an error occurs
  123384. */
  123385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123386. }
  123387. /**
  123388. * Define a task used by AssetsManager to load cube textures
  123389. */
  123390. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  123391. /**
  123392. * Defines the name of the task
  123393. */
  123394. name: string;
  123395. /**
  123396. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123397. */
  123398. url: string;
  123399. /**
  123400. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123401. */
  123402. extensions?: string[] | undefined;
  123403. /**
  123404. * Defines if mipmaps should not be generated (default is false)
  123405. */
  123406. noMipmap?: boolean | undefined;
  123407. /**
  123408. * Defines the explicit list of files (undefined by default)
  123409. */
  123410. files?: string[] | undefined;
  123411. /**
  123412. * Gets the loaded texture
  123413. */
  123414. texture: CubeTexture;
  123415. /**
  123416. * Callback called when the task is successful
  123417. */
  123418. onSuccess: (task: CubeTextureAssetTask) => void;
  123419. /**
  123420. * Callback called when the task is successful
  123421. */
  123422. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123423. /**
  123424. * Creates a new CubeTextureAssetTask
  123425. * @param name defines the name of the task
  123426. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123427. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123428. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123429. * @param files defines the explicit list of files (undefined by default)
  123430. */
  123431. constructor(
  123432. /**
  123433. * Defines the name of the task
  123434. */
  123435. name: string,
  123436. /**
  123437. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123438. */
  123439. url: string,
  123440. /**
  123441. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123442. */
  123443. extensions?: string[] | undefined,
  123444. /**
  123445. * Defines if mipmaps should not be generated (default is false)
  123446. */
  123447. noMipmap?: boolean | undefined,
  123448. /**
  123449. * Defines the explicit list of files (undefined by default)
  123450. */
  123451. files?: string[] | undefined);
  123452. /**
  123453. * Execute the current task
  123454. * @param scene defines the scene where you want your assets to be loaded
  123455. * @param onSuccess is a callback called when the task is successfully executed
  123456. * @param onError is a callback called if an error occurs
  123457. */
  123458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123459. }
  123460. /**
  123461. * Define a task used by AssetsManager to load HDR cube textures
  123462. */
  123463. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123464. /**
  123465. * Defines the name of the task
  123466. */
  123467. name: string;
  123468. /**
  123469. * Defines the location of the file to load
  123470. */
  123471. url: string;
  123472. /**
  123473. * Defines the desired size (the more it increases the longer the generation will be)
  123474. */
  123475. size: number;
  123476. /**
  123477. * Defines if mipmaps should not be generated (default is false)
  123478. */
  123479. noMipmap: boolean;
  123480. /**
  123481. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123482. */
  123483. generateHarmonics: boolean;
  123484. /**
  123485. * 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)
  123486. */
  123487. gammaSpace: boolean;
  123488. /**
  123489. * Internal Use Only
  123490. */
  123491. reserved: boolean;
  123492. /**
  123493. * Gets the loaded texture
  123494. */
  123495. texture: HDRCubeTexture;
  123496. /**
  123497. * Callback called when the task is successful
  123498. */
  123499. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123500. /**
  123501. * Callback called when the task is successful
  123502. */
  123503. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123504. /**
  123505. * Creates a new HDRCubeTextureAssetTask object
  123506. * @param name defines the name of the task
  123507. * @param url defines the location of the file to load
  123508. * @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.
  123509. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123510. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123511. * @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)
  123512. * @param reserved Internal use only
  123513. */
  123514. constructor(
  123515. /**
  123516. * Defines the name of the task
  123517. */
  123518. name: string,
  123519. /**
  123520. * Defines the location of the file to load
  123521. */
  123522. url: string,
  123523. /**
  123524. * Defines the desired size (the more it increases the longer the generation will be)
  123525. */
  123526. size: number,
  123527. /**
  123528. * Defines if mipmaps should not be generated (default is false)
  123529. */
  123530. noMipmap?: boolean,
  123531. /**
  123532. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123533. */
  123534. generateHarmonics?: boolean,
  123535. /**
  123536. * 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)
  123537. */
  123538. gammaSpace?: boolean,
  123539. /**
  123540. * Internal Use Only
  123541. */
  123542. reserved?: boolean);
  123543. /**
  123544. * Execute the current task
  123545. * @param scene defines the scene where you want your assets to be loaded
  123546. * @param onSuccess is a callback called when the task is successfully executed
  123547. * @param onError is a callback called if an error occurs
  123548. */
  123549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123550. }
  123551. /**
  123552. * Define a task used by AssetsManager to load Equirectangular cube textures
  123553. */
  123554. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  123555. /**
  123556. * Defines the name of the task
  123557. */
  123558. name: string;
  123559. /**
  123560. * Defines the location of the file to load
  123561. */
  123562. url: string;
  123563. /**
  123564. * Defines the desired size (the more it increases the longer the generation will be)
  123565. */
  123566. size: number;
  123567. /**
  123568. * Defines if mipmaps should not be generated (default is false)
  123569. */
  123570. noMipmap: boolean;
  123571. /**
  123572. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123573. * but the standard material would require them in Gamma space) (default is true)
  123574. */
  123575. gammaSpace: boolean;
  123576. /**
  123577. * Gets the loaded texture
  123578. */
  123579. texture: EquiRectangularCubeTexture;
  123580. /**
  123581. * Callback called when the task is successful
  123582. */
  123583. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  123584. /**
  123585. * Callback called when the task is successful
  123586. */
  123587. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  123588. /**
  123589. * Creates a new EquiRectangularCubeTextureAssetTask object
  123590. * @param name defines the name of the task
  123591. * @param url defines the location of the file to load
  123592. * @param size defines the desired size (the more it increases the longer the generation will be)
  123593. * If the size is omitted this implies you are using a preprocessed cubemap.
  123594. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123595. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  123596. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  123597. * (default is true)
  123598. */
  123599. constructor(
  123600. /**
  123601. * Defines the name of the task
  123602. */
  123603. name: string,
  123604. /**
  123605. * Defines the location of the file to load
  123606. */
  123607. url: string,
  123608. /**
  123609. * Defines the desired size (the more it increases the longer the generation will be)
  123610. */
  123611. size: number,
  123612. /**
  123613. * Defines if mipmaps should not be generated (default is false)
  123614. */
  123615. noMipmap?: boolean,
  123616. /**
  123617. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123618. * but the standard material would require them in Gamma space) (default is true)
  123619. */
  123620. gammaSpace?: boolean);
  123621. /**
  123622. * Execute the current task
  123623. * @param scene defines the scene where you want your assets to be loaded
  123624. * @param onSuccess is a callback called when the task is successfully executed
  123625. * @param onError is a callback called if an error occurs
  123626. */
  123627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123628. }
  123629. /**
  123630. * This class can be used to easily import assets into a scene
  123631. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  123632. */
  123633. export class AssetsManager {
  123634. private _scene;
  123635. private _isLoading;
  123636. protected _tasks: AbstractAssetTask[];
  123637. protected _waitingTasksCount: number;
  123638. protected _totalTasksCount: number;
  123639. /**
  123640. * Callback called when all tasks are processed
  123641. */
  123642. onFinish: (tasks: AbstractAssetTask[]) => void;
  123643. /**
  123644. * Callback called when a task is successful
  123645. */
  123646. onTaskSuccess: (task: AbstractAssetTask) => void;
  123647. /**
  123648. * Callback called when a task had an error
  123649. */
  123650. onTaskError: (task: AbstractAssetTask) => void;
  123651. /**
  123652. * Callback called when a task is done (whatever the result is)
  123653. */
  123654. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  123655. /**
  123656. * Observable called when all tasks are processed
  123657. */
  123658. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  123659. /**
  123660. * Observable called when a task had an error
  123661. */
  123662. onTaskErrorObservable: Observable<AbstractAssetTask>;
  123663. /**
  123664. * Observable called when all tasks were executed
  123665. */
  123666. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  123667. /**
  123668. * Observable called when a task is done (whatever the result is)
  123669. */
  123670. onProgressObservable: Observable<IAssetsProgressEvent>;
  123671. /**
  123672. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  123673. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123674. */
  123675. useDefaultLoadingScreen: boolean;
  123676. /**
  123677. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  123678. * when all assets have been downloaded.
  123679. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  123680. */
  123681. autoHideLoadingUI: boolean;
  123682. /**
  123683. * Creates a new AssetsManager
  123684. * @param scene defines the scene to work on
  123685. */
  123686. constructor(scene: Scene);
  123687. /**
  123688. * Add a MeshAssetTask to the list of active tasks
  123689. * @param taskName defines the name of the new task
  123690. * @param meshesNames defines the name of meshes to load
  123691. * @param rootUrl defines the root url to use to locate files
  123692. * @param sceneFilename defines the filename of the scene file
  123693. * @returns a new MeshAssetTask object
  123694. */
  123695. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  123696. /**
  123697. * Add a TextFileAssetTask to the list of active tasks
  123698. * @param taskName defines the name of the new task
  123699. * @param url defines the url of the file to load
  123700. * @returns a new TextFileAssetTask object
  123701. */
  123702. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  123703. /**
  123704. * Add a BinaryFileAssetTask to the list of active tasks
  123705. * @param taskName defines the name of the new task
  123706. * @param url defines the url of the file to load
  123707. * @returns a new BinaryFileAssetTask object
  123708. */
  123709. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  123710. /**
  123711. * Add a ImageAssetTask to the list of active tasks
  123712. * @param taskName defines the name of the new task
  123713. * @param url defines the url of the file to load
  123714. * @returns a new ImageAssetTask object
  123715. */
  123716. addImageTask(taskName: string, url: string): ImageAssetTask;
  123717. /**
  123718. * Add a TextureAssetTask to the list of active tasks
  123719. * @param taskName defines the name of the new task
  123720. * @param url defines the url of the file to load
  123721. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123722. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  123723. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123724. * @returns a new TextureAssetTask object
  123725. */
  123726. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  123727. /**
  123728. * Add a CubeTextureAssetTask to the list of active tasks
  123729. * @param taskName defines the name of the new task
  123730. * @param url defines the url of the file to load
  123731. * @param extensions defines the extension to use to load the cube map (can be null)
  123732. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123733. * @param files defines the list of files to load (can be null)
  123734. * @returns a new CubeTextureAssetTask object
  123735. */
  123736. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  123737. /**
  123738. *
  123739. * Add a HDRCubeTextureAssetTask to the list of active tasks
  123740. * @param taskName defines the name of the new task
  123741. * @param url defines the url of the file to load
  123742. * @param size defines the size you want for the cubemap (can be null)
  123743. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123744. * @param generateHarmonics defines if you want to automatically generate (true by default)
  123745. * @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)
  123746. * @param reserved Internal use only
  123747. * @returns a new HDRCubeTextureAssetTask object
  123748. */
  123749. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  123750. /**
  123751. *
  123752. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  123753. * @param taskName defines the name of the new task
  123754. * @param url defines the url of the file to load
  123755. * @param size defines the size you want for the cubemap (can be null)
  123756. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123757. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123758. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123759. * @returns a new EquiRectangularCubeTextureAssetTask object
  123760. */
  123761. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  123762. /**
  123763. * Remove a task from the assets manager.
  123764. * @param task the task to remove
  123765. */
  123766. removeTask(task: AbstractAssetTask): void;
  123767. private _decreaseWaitingTasksCount;
  123768. private _runTask;
  123769. /**
  123770. * Reset the AssetsManager and remove all tasks
  123771. * @return the current instance of the AssetsManager
  123772. */
  123773. reset(): AssetsManager;
  123774. /**
  123775. * Start the loading process
  123776. * @return the current instance of the AssetsManager
  123777. */
  123778. load(): AssetsManager;
  123779. /**
  123780. * Start the loading process as an async operation
  123781. * @return a promise returning the list of failed tasks
  123782. */
  123783. loadAsync(): Promise<void>;
  123784. }
  123785. }
  123786. declare module BABYLON {
  123787. /**
  123788. * Wrapper class for promise with external resolve and reject.
  123789. */
  123790. export class Deferred<T> {
  123791. /**
  123792. * The promise associated with this deferred object.
  123793. */
  123794. readonly promise: Promise<T>;
  123795. private _resolve;
  123796. private _reject;
  123797. /**
  123798. * The resolve method of the promise associated with this deferred object.
  123799. */
  123800. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  123801. /**
  123802. * The reject method of the promise associated with this deferred object.
  123803. */
  123804. readonly reject: (reason?: any) => void;
  123805. /**
  123806. * Constructor for this deferred object.
  123807. */
  123808. constructor();
  123809. }
  123810. }
  123811. declare module BABYLON {
  123812. /**
  123813. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  123814. */
  123815. export class MeshExploder {
  123816. private _centerMesh;
  123817. private _meshes;
  123818. private _meshesOrigins;
  123819. private _toCenterVectors;
  123820. private _scaledDirection;
  123821. private _newPosition;
  123822. private _centerPosition;
  123823. /**
  123824. * Explodes meshes from a center mesh.
  123825. * @param meshes The meshes to explode.
  123826. * @param centerMesh The mesh to be center of explosion.
  123827. */
  123828. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  123829. private _setCenterMesh;
  123830. /**
  123831. * Get class name
  123832. * @returns "MeshExploder"
  123833. */
  123834. getClassName(): string;
  123835. /**
  123836. * "Exploded meshes"
  123837. * @returns Array of meshes with the centerMesh at index 0.
  123838. */
  123839. getMeshes(): Array<Mesh>;
  123840. /**
  123841. * Explodes meshes giving a specific direction
  123842. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  123843. */
  123844. explode(direction?: number): void;
  123845. }
  123846. }
  123847. declare module BABYLON {
  123848. /**
  123849. * Class used to help managing file picking and drag'n'drop
  123850. */
  123851. export class FilesInput {
  123852. /**
  123853. * List of files ready to be loaded
  123854. */
  123855. static readonly FilesToLoad: {
  123856. [key: string]: File;
  123857. };
  123858. /**
  123859. * Callback called when a file is processed
  123860. */
  123861. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  123862. private _engine;
  123863. private _currentScene;
  123864. private _sceneLoadedCallback;
  123865. private _progressCallback;
  123866. private _additionalRenderLoopLogicCallback;
  123867. private _textureLoadingCallback;
  123868. private _startingProcessingFilesCallback;
  123869. private _onReloadCallback;
  123870. private _errorCallback;
  123871. private _elementToMonitor;
  123872. private _sceneFileToLoad;
  123873. private _filesToLoad;
  123874. /**
  123875. * Creates a new FilesInput
  123876. * @param engine defines the rendering engine
  123877. * @param scene defines the hosting scene
  123878. * @param sceneLoadedCallback callback called when scene is loaded
  123879. * @param progressCallback callback called to track progress
  123880. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  123881. * @param textureLoadingCallback callback called when a texture is loading
  123882. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  123883. * @param onReloadCallback callback called when a reload is requested
  123884. * @param errorCallback callback call if an error occurs
  123885. */
  123886. 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);
  123887. private _dragEnterHandler;
  123888. private _dragOverHandler;
  123889. private _dropHandler;
  123890. /**
  123891. * Calls this function to listen to drag'n'drop events on a specific DOM element
  123892. * @param elementToMonitor defines the DOM element to track
  123893. */
  123894. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  123895. /**
  123896. * Release all associated resources
  123897. */
  123898. dispose(): void;
  123899. private renderFunction;
  123900. private drag;
  123901. private drop;
  123902. private _traverseFolder;
  123903. private _processFiles;
  123904. /**
  123905. * Load files from a drop event
  123906. * @param event defines the drop event to use as source
  123907. */
  123908. loadFiles(event: any): void;
  123909. private _processReload;
  123910. /**
  123911. * Reload the current scene from the loaded files
  123912. */
  123913. reload(): void;
  123914. }
  123915. }
  123916. declare module BABYLON {
  123917. /**
  123918. * Defines the root class used to create scene optimization to use with SceneOptimizer
  123919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123920. */
  123921. export class SceneOptimization {
  123922. /**
  123923. * Defines the priority of this optimization (0 by default which means first in the list)
  123924. */
  123925. priority: number;
  123926. /**
  123927. * Gets a string describing the action executed by the current optimization
  123928. * @returns description string
  123929. */
  123930. getDescription(): string;
  123931. /**
  123932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123933. * @param scene defines the current scene where to apply this optimization
  123934. * @param optimizer defines the current optimizer
  123935. * @returns true if everything that can be done was applied
  123936. */
  123937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123938. /**
  123939. * Creates the SceneOptimization object
  123940. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123941. * @param desc defines the description associated with the optimization
  123942. */
  123943. constructor(
  123944. /**
  123945. * Defines the priority of this optimization (0 by default which means first in the list)
  123946. */
  123947. priority?: number);
  123948. }
  123949. /**
  123950. * Defines an optimization used to reduce the size of render target textures
  123951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123952. */
  123953. export class TextureOptimization extends SceneOptimization {
  123954. /**
  123955. * Defines the priority of this optimization (0 by default which means first in the list)
  123956. */
  123957. priority: number;
  123958. /**
  123959. * 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
  123960. */
  123961. maximumSize: number;
  123962. /**
  123963. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123964. */
  123965. step: number;
  123966. /**
  123967. * Gets a string describing the action executed by the current optimization
  123968. * @returns description string
  123969. */
  123970. getDescription(): string;
  123971. /**
  123972. * Creates the TextureOptimization object
  123973. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123974. * @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
  123975. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123976. */
  123977. constructor(
  123978. /**
  123979. * Defines the priority of this optimization (0 by default which means first in the list)
  123980. */
  123981. priority?: number,
  123982. /**
  123983. * 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
  123984. */
  123985. maximumSize?: number,
  123986. /**
  123987. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123988. */
  123989. step?: number);
  123990. /**
  123991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123992. * @param scene defines the current scene where to apply this optimization
  123993. * @param optimizer defines the current optimizer
  123994. * @returns true if everything that can be done was applied
  123995. */
  123996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123997. }
  123998. /**
  123999. * Defines an optimization used to increase or decrease the rendering resolution
  124000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124001. */
  124002. export class HardwareScalingOptimization extends SceneOptimization {
  124003. /**
  124004. * Defines the priority of this optimization (0 by default which means first in the list)
  124005. */
  124006. priority: number;
  124007. /**
  124008. * Defines the maximum scale to use (2 by default)
  124009. */
  124010. maximumScale: number;
  124011. /**
  124012. * Defines the step to use between two passes (0.5 by default)
  124013. */
  124014. step: number;
  124015. private _currentScale;
  124016. private _directionOffset;
  124017. /**
  124018. * Gets a string describing the action executed by the current optimization
  124019. * @return description string
  124020. */
  124021. getDescription(): string;
  124022. /**
  124023. * Creates the HardwareScalingOptimization object
  124024. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124025. * @param maximumScale defines the maximum scale to use (2 by default)
  124026. * @param step defines the step to use between two passes (0.5 by default)
  124027. */
  124028. constructor(
  124029. /**
  124030. * Defines the priority of this optimization (0 by default which means first in the list)
  124031. */
  124032. priority?: number,
  124033. /**
  124034. * Defines the maximum scale to use (2 by default)
  124035. */
  124036. maximumScale?: number,
  124037. /**
  124038. * Defines the step to use between two passes (0.5 by default)
  124039. */
  124040. step?: number);
  124041. /**
  124042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124043. * @param scene defines the current scene where to apply this optimization
  124044. * @param optimizer defines the current optimizer
  124045. * @returns true if everything that can be done was applied
  124046. */
  124047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124048. }
  124049. /**
  124050. * Defines an optimization used to remove shadows
  124051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124052. */
  124053. export class ShadowsOptimization extends SceneOptimization {
  124054. /**
  124055. * Gets a string describing the action executed by the current optimization
  124056. * @return description string
  124057. */
  124058. getDescription(): string;
  124059. /**
  124060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124061. * @param scene defines the current scene where to apply this optimization
  124062. * @param optimizer defines the current optimizer
  124063. * @returns true if everything that can be done was applied
  124064. */
  124065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124066. }
  124067. /**
  124068. * Defines an optimization used to turn post-processes off
  124069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124070. */
  124071. export class PostProcessesOptimization extends SceneOptimization {
  124072. /**
  124073. * Gets a string describing the action executed by the current optimization
  124074. * @return description string
  124075. */
  124076. getDescription(): string;
  124077. /**
  124078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124079. * @param scene defines the current scene where to apply this optimization
  124080. * @param optimizer defines the current optimizer
  124081. * @returns true if everything that can be done was applied
  124082. */
  124083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124084. }
  124085. /**
  124086. * Defines an optimization used to turn lens flares off
  124087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124088. */
  124089. export class LensFlaresOptimization extends SceneOptimization {
  124090. /**
  124091. * Gets a string describing the action executed by the current optimization
  124092. * @return description string
  124093. */
  124094. getDescription(): string;
  124095. /**
  124096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124097. * @param scene defines the current scene where to apply this optimization
  124098. * @param optimizer defines the current optimizer
  124099. * @returns true if everything that can be done was applied
  124100. */
  124101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124102. }
  124103. /**
  124104. * Defines an optimization based on user defined callback.
  124105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124106. */
  124107. export class CustomOptimization extends SceneOptimization {
  124108. /**
  124109. * Callback called to apply the custom optimization.
  124110. */
  124111. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  124112. /**
  124113. * Callback called to get custom description
  124114. */
  124115. onGetDescription: () => string;
  124116. /**
  124117. * Gets a string describing the action executed by the current optimization
  124118. * @returns description string
  124119. */
  124120. getDescription(): string;
  124121. /**
  124122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124123. * @param scene defines the current scene where to apply this optimization
  124124. * @param optimizer defines the current optimizer
  124125. * @returns true if everything that can be done was applied
  124126. */
  124127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124128. }
  124129. /**
  124130. * Defines an optimization used to turn particles off
  124131. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124132. */
  124133. export class ParticlesOptimization extends SceneOptimization {
  124134. /**
  124135. * Gets a string describing the action executed by the current optimization
  124136. * @return description string
  124137. */
  124138. getDescription(): string;
  124139. /**
  124140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124141. * @param scene defines the current scene where to apply this optimization
  124142. * @param optimizer defines the current optimizer
  124143. * @returns true if everything that can be done was applied
  124144. */
  124145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124146. }
  124147. /**
  124148. * Defines an optimization used to turn render targets off
  124149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124150. */
  124151. export class RenderTargetsOptimization extends SceneOptimization {
  124152. /**
  124153. * Gets a string describing the action executed by the current optimization
  124154. * @return description string
  124155. */
  124156. getDescription(): string;
  124157. /**
  124158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124159. * @param scene defines the current scene where to apply this optimization
  124160. * @param optimizer defines the current optimizer
  124161. * @returns true if everything that can be done was applied
  124162. */
  124163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124164. }
  124165. /**
  124166. * Defines an optimization used to merge meshes with compatible materials
  124167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124168. */
  124169. export class MergeMeshesOptimization extends SceneOptimization {
  124170. private static _UpdateSelectionTree;
  124171. /**
  124172. * Gets or sets a boolean which defines if optimization octree has to be updated
  124173. */
  124174. /**
  124175. * Gets or sets a boolean which defines if optimization octree has to be updated
  124176. */
  124177. static UpdateSelectionTree: boolean;
  124178. /**
  124179. * Gets a string describing the action executed by the current optimization
  124180. * @return description string
  124181. */
  124182. getDescription(): string;
  124183. private _canBeMerged;
  124184. /**
  124185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124186. * @param scene defines the current scene where to apply this optimization
  124187. * @param optimizer defines the current optimizer
  124188. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  124189. * @returns true if everything that can be done was applied
  124190. */
  124191. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  124192. }
  124193. /**
  124194. * Defines a list of options used by SceneOptimizer
  124195. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124196. */
  124197. export class SceneOptimizerOptions {
  124198. /**
  124199. * Defines the target frame rate to reach (60 by default)
  124200. */
  124201. targetFrameRate: number;
  124202. /**
  124203. * Defines the interval between two checkes (2000ms by default)
  124204. */
  124205. trackerDuration: number;
  124206. /**
  124207. * Gets the list of optimizations to apply
  124208. */
  124209. optimizations: SceneOptimization[];
  124210. /**
  124211. * Creates a new list of options used by SceneOptimizer
  124212. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  124213. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  124214. */
  124215. constructor(
  124216. /**
  124217. * Defines the target frame rate to reach (60 by default)
  124218. */
  124219. targetFrameRate?: number,
  124220. /**
  124221. * Defines the interval between two checkes (2000ms by default)
  124222. */
  124223. trackerDuration?: number);
  124224. /**
  124225. * Add a new optimization
  124226. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  124227. * @returns the current SceneOptimizerOptions
  124228. */
  124229. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  124230. /**
  124231. * Add a new custom optimization
  124232. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  124233. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  124234. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124235. * @returns the current SceneOptimizerOptions
  124236. */
  124237. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  124238. /**
  124239. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  124240. * @param targetFrameRate defines the target frame rate (60 by default)
  124241. * @returns a SceneOptimizerOptions object
  124242. */
  124243. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124244. /**
  124245. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  124246. * @param targetFrameRate defines the target frame rate (60 by default)
  124247. * @returns a SceneOptimizerOptions object
  124248. */
  124249. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124250. /**
  124251. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  124252. * @param targetFrameRate defines the target frame rate (60 by default)
  124253. * @returns a SceneOptimizerOptions object
  124254. */
  124255. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124256. }
  124257. /**
  124258. * Class used to run optimizations in order to reach a target frame rate
  124259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124260. */
  124261. export class SceneOptimizer implements IDisposable {
  124262. private _isRunning;
  124263. private _options;
  124264. private _scene;
  124265. private _currentPriorityLevel;
  124266. private _targetFrameRate;
  124267. private _trackerDuration;
  124268. private _currentFrameRate;
  124269. private _sceneDisposeObserver;
  124270. private _improvementMode;
  124271. /**
  124272. * Defines an observable called when the optimizer reaches the target frame rate
  124273. */
  124274. onSuccessObservable: Observable<SceneOptimizer>;
  124275. /**
  124276. * Defines an observable called when the optimizer enables an optimization
  124277. */
  124278. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  124279. /**
  124280. * Defines an observable called when the optimizer is not able to reach the target frame rate
  124281. */
  124282. onFailureObservable: Observable<SceneOptimizer>;
  124283. /**
  124284. * Gets a boolean indicating if the optimizer is in improvement mode
  124285. */
  124286. readonly isInImprovementMode: boolean;
  124287. /**
  124288. * Gets the current priority level (0 at start)
  124289. */
  124290. readonly currentPriorityLevel: number;
  124291. /**
  124292. * Gets the current frame rate checked by the SceneOptimizer
  124293. */
  124294. readonly currentFrameRate: number;
  124295. /**
  124296. * Gets or sets the current target frame rate (60 by default)
  124297. */
  124298. /**
  124299. * Gets or sets the current target frame rate (60 by default)
  124300. */
  124301. targetFrameRate: number;
  124302. /**
  124303. * Gets or sets the current interval between two checks (every 2000ms by default)
  124304. */
  124305. /**
  124306. * Gets or sets the current interval between two checks (every 2000ms by default)
  124307. */
  124308. trackerDuration: number;
  124309. /**
  124310. * Gets the list of active optimizations
  124311. */
  124312. readonly optimizations: SceneOptimization[];
  124313. /**
  124314. * Creates a new SceneOptimizer
  124315. * @param scene defines the scene to work on
  124316. * @param options defines the options to use with the SceneOptimizer
  124317. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  124318. * @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)
  124319. */
  124320. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  124321. /**
  124322. * Stops the current optimizer
  124323. */
  124324. stop(): void;
  124325. /**
  124326. * Reset the optimizer to initial step (current priority level = 0)
  124327. */
  124328. reset(): void;
  124329. /**
  124330. * Start the optimizer. By default it will try to reach a specific framerate
  124331. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  124332. */
  124333. start(): void;
  124334. private _checkCurrentState;
  124335. /**
  124336. * Release all resources
  124337. */
  124338. dispose(): void;
  124339. /**
  124340. * Helper function to create a SceneOptimizer with one single line of code
  124341. * @param scene defines the scene to work on
  124342. * @param options defines the options to use with the SceneOptimizer
  124343. * @param onSuccess defines a callback to call on success
  124344. * @param onFailure defines a callback to call on failure
  124345. * @returns the new SceneOptimizer object
  124346. */
  124347. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  124348. }
  124349. }
  124350. declare module BABYLON {
  124351. /**
  124352. * Class used to serialize a scene into a string
  124353. */
  124354. export class SceneSerializer {
  124355. /**
  124356. * Clear cache used by a previous serialization
  124357. */
  124358. static ClearCache(): void;
  124359. /**
  124360. * Serialize a scene into a JSON compatible object
  124361. * @param scene defines the scene to serialize
  124362. * @returns a JSON compatible object
  124363. */
  124364. static Serialize(scene: Scene): any;
  124365. /**
  124366. * Serialize a mesh into a JSON compatible object
  124367. * @param toSerialize defines the mesh to serialize
  124368. * @param withParents defines if parents must be serialized as well
  124369. * @param withChildren defines if children must be serialized as well
  124370. * @returns a JSON compatible object
  124371. */
  124372. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  124373. }
  124374. }
  124375. declare module BABYLON {
  124376. /**
  124377. * Class used to host texture specific utilities
  124378. */
  124379. export class TextureTools {
  124380. /**
  124381. * Uses the GPU to create a copy texture rescaled at a given size
  124382. * @param texture Texture to copy from
  124383. * @param width defines the desired width
  124384. * @param height defines the desired height
  124385. * @param useBilinearMode defines if bilinear mode has to be used
  124386. * @return the generated texture
  124387. */
  124388. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  124389. }
  124390. }
  124391. declare module BABYLON {
  124392. /**
  124393. * This represents the different options available for the video capture.
  124394. */
  124395. export interface VideoRecorderOptions {
  124396. /** Defines the mime type of the video. */
  124397. mimeType: string;
  124398. /** Defines the FPS the video should be recorded at. */
  124399. fps: number;
  124400. /** Defines the chunk size for the recording data. */
  124401. recordChunckSize: number;
  124402. /** The audio tracks to attach to the recording. */
  124403. audioTracks?: MediaStreamTrack[];
  124404. }
  124405. /**
  124406. * This can help with recording videos from BabylonJS.
  124407. * This is based on the available WebRTC functionalities of the browser.
  124408. *
  124409. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124410. */
  124411. export class VideoRecorder {
  124412. private static readonly _defaultOptions;
  124413. /**
  124414. * Returns whether or not the VideoRecorder is available in your browser.
  124415. * @param engine Defines the Babylon Engine.
  124416. * @returns true if supported otherwise false.
  124417. */
  124418. static IsSupported(engine: Engine): boolean;
  124419. private readonly _options;
  124420. private _canvas;
  124421. private _mediaRecorder;
  124422. private _recordedChunks;
  124423. private _fileName;
  124424. private _resolve;
  124425. private _reject;
  124426. /**
  124427. * True when a recording is already in progress.
  124428. */
  124429. readonly isRecording: boolean;
  124430. /**
  124431. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124432. * @param engine Defines the BabylonJS Engine you wish to record.
  124433. * @param options Defines options that can be used to customize the capture.
  124434. */
  124435. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124436. /**
  124437. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124438. */
  124439. stopRecording(): void;
  124440. /**
  124441. * Starts recording the canvas for a max duration specified in parameters.
  124442. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124443. * If null no automatic download will start and you can rely on the promise to get the data back.
  124444. * @param maxDuration Defines the maximum recording time in seconds.
  124445. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124446. * @return A promise callback at the end of the recording with the video data in Blob.
  124447. */
  124448. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124449. /**
  124450. * Releases internal resources used during the recording.
  124451. */
  124452. dispose(): void;
  124453. private _handleDataAvailable;
  124454. private _handleError;
  124455. private _handleStop;
  124456. }
  124457. }
  124458. declare module BABYLON {
  124459. /**
  124460. * Class containing a set of static utilities functions for screenshots
  124461. */
  124462. export class ScreenshotTools {
  124463. /**
  124464. * Captures a screenshot of the current rendering
  124465. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124466. * @param engine defines the rendering engine
  124467. * @param camera defines the source camera
  124468. * @param size This parameter can be set to a single number or to an object with the
  124469. * following (optional) properties: precision, width, height. If a single number is passed,
  124470. * it will be used for both width and height. If an object is passed, the screenshot size
  124471. * will be derived from the parameters. The precision property is a multiplier allowing
  124472. * rendering at a higher or lower resolution
  124473. * @param successCallback defines the callback receives a single parameter which contains the
  124474. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124475. * src parameter of an <img> to display it
  124476. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124477. * Check your browser for supported MIME types
  124478. */
  124479. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  124480. /**
  124481. * Captures a screenshot of the current rendering
  124482. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124483. * @param engine defines the rendering engine
  124484. * @param camera defines the source camera
  124485. * @param size This parameter can be set to a single number or to an object with the
  124486. * following (optional) properties: precision, width, height. If a single number is passed,
  124487. * it will be used for both width and height. If an object is passed, the screenshot size
  124488. * will be derived from the parameters. The precision property is a multiplier allowing
  124489. * rendering at a higher or lower resolution
  124490. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124491. * Check your browser for supported MIME types
  124492. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124493. * to the src parameter of an <img> to display it
  124494. */
  124495. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124496. /**
  124497. * Generates an image screenshot from the specified camera.
  124498. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124499. * @param engine The engine to use for rendering
  124500. * @param camera The camera to use for rendering
  124501. * @param size This parameter can be set to a single number or to an object with the
  124502. * following (optional) properties: precision, width, height. If a single number is passed,
  124503. * it will be used for both width and height. If an object is passed, the screenshot size
  124504. * will be derived from the parameters. The precision property is a multiplier allowing
  124505. * rendering at a higher or lower resolution
  124506. * @param successCallback The callback receives a single parameter which contains the
  124507. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124508. * src parameter of an <img> to display it
  124509. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124510. * Check your browser for supported MIME types
  124511. * @param samples Texture samples (default: 1)
  124512. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124513. * @param fileName A name for for the downloaded file.
  124514. */
  124515. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  124516. /**
  124517. * Generates an image screenshot from the specified camera.
  124518. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124519. * @param engine The engine to use for rendering
  124520. * @param camera The camera to use for rendering
  124521. * @param size This parameter can be set to a single number or to an object with the
  124522. * following (optional) properties: precision, width, height. If a single number is passed,
  124523. * it will be used for both width and height. If an object is passed, the screenshot size
  124524. * will be derived from the parameters. The precision property is a multiplier allowing
  124525. * rendering at a higher or lower resolution
  124526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124527. * Check your browser for supported MIME types
  124528. * @param samples Texture samples (default: 1)
  124529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124530. * @param fileName A name for for the downloaded file.
  124531. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124532. * to the src parameter of an <img> to display it
  124533. */
  124534. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  124535. /**
  124536. * Gets height and width for screenshot size
  124537. * @private
  124538. */
  124539. private static _getScreenshotSize;
  124540. }
  124541. }
  124542. declare module BABYLON {
  124543. /**
  124544. * A cursor which tracks a point on a path
  124545. */
  124546. export class PathCursor {
  124547. private path;
  124548. /**
  124549. * Stores path cursor callbacks for when an onchange event is triggered
  124550. */
  124551. private _onchange;
  124552. /**
  124553. * The value of the path cursor
  124554. */
  124555. value: number;
  124556. /**
  124557. * The animation array of the path cursor
  124558. */
  124559. animations: Animation[];
  124560. /**
  124561. * Initializes the path cursor
  124562. * @param path The path to track
  124563. */
  124564. constructor(path: Path2);
  124565. /**
  124566. * Gets the cursor point on the path
  124567. * @returns A point on the path cursor at the cursor location
  124568. */
  124569. getPoint(): Vector3;
  124570. /**
  124571. * Moves the cursor ahead by the step amount
  124572. * @param step The amount to move the cursor forward
  124573. * @returns This path cursor
  124574. */
  124575. moveAhead(step?: number): PathCursor;
  124576. /**
  124577. * Moves the cursor behind by the step amount
  124578. * @param step The amount to move the cursor back
  124579. * @returns This path cursor
  124580. */
  124581. moveBack(step?: number): PathCursor;
  124582. /**
  124583. * Moves the cursor by the step amount
  124584. * If the step amount is greater than one, an exception is thrown
  124585. * @param step The amount to move the cursor
  124586. * @returns This path cursor
  124587. */
  124588. move(step: number): PathCursor;
  124589. /**
  124590. * Ensures that the value is limited between zero and one
  124591. * @returns This path cursor
  124592. */
  124593. private ensureLimits;
  124594. /**
  124595. * Runs onchange callbacks on change (used by the animation engine)
  124596. * @returns This path cursor
  124597. */
  124598. private raiseOnChange;
  124599. /**
  124600. * Executes a function on change
  124601. * @param f A path cursor onchange callback
  124602. * @returns This path cursor
  124603. */
  124604. onchange(f: (cursor: PathCursor) => void): PathCursor;
  124605. }
  124606. }
  124607. declare module BABYLON {
  124608. /** @hidden */
  124609. export var blurPixelShader: {
  124610. name: string;
  124611. shader: string;
  124612. };
  124613. }
  124614. declare module BABYLON {
  124615. /** @hidden */
  124616. export var pointCloudVertexDeclaration: {
  124617. name: string;
  124618. shader: string;
  124619. };
  124620. }
  124621. // Mixins
  124622. interface Window {
  124623. mozIndexedDB: IDBFactory;
  124624. webkitIndexedDB: IDBFactory;
  124625. msIndexedDB: IDBFactory;
  124626. webkitURL: typeof URL;
  124627. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  124628. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  124629. WebGLRenderingContext: WebGLRenderingContext;
  124630. MSGesture: MSGesture;
  124631. CANNON: any;
  124632. AudioContext: AudioContext;
  124633. webkitAudioContext: AudioContext;
  124634. PointerEvent: any;
  124635. Math: Math;
  124636. Uint8Array: Uint8ArrayConstructor;
  124637. Float32Array: Float32ArrayConstructor;
  124638. mozURL: typeof URL;
  124639. msURL: typeof URL;
  124640. VRFrameData: any; // WebVR, from specs 1.1
  124641. DracoDecoderModule: any;
  124642. setImmediate(handler: (...args: any[]) => void): number;
  124643. }
  124644. interface HTMLCanvasElement {
  124645. requestPointerLock(): void;
  124646. msRequestPointerLock?(): void;
  124647. mozRequestPointerLock?(): void;
  124648. webkitRequestPointerLock?(): void;
  124649. /** Track wether a record is in progress */
  124650. isRecording: boolean;
  124651. /** Capture Stream method defined by some browsers */
  124652. captureStream(fps?: number): MediaStream;
  124653. }
  124654. interface CanvasRenderingContext2D {
  124655. msImageSmoothingEnabled: boolean;
  124656. }
  124657. interface MouseEvent {
  124658. mozMovementX: number;
  124659. mozMovementY: number;
  124660. webkitMovementX: number;
  124661. webkitMovementY: number;
  124662. msMovementX: number;
  124663. msMovementY: number;
  124664. }
  124665. interface Navigator {
  124666. mozGetVRDevices: (any: any) => any;
  124667. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124668. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124669. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124670. webkitGetGamepads(): Gamepad[];
  124671. msGetGamepads(): Gamepad[];
  124672. webkitGamepads(): Gamepad[];
  124673. }
  124674. interface HTMLVideoElement {
  124675. mozSrcObject: any;
  124676. }
  124677. interface Math {
  124678. fround(x: number): number;
  124679. imul(a: number, b: number): number;
  124680. }
  124681. interface WebGLRenderingContext {
  124682. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  124683. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  124684. vertexAttribDivisor(index: number, divisor: number): void;
  124685. createVertexArray(): any;
  124686. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  124687. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  124688. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  124689. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  124690. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  124691. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  124692. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  124693. // Queries
  124694. createQuery(): WebGLQuery;
  124695. deleteQuery(query: WebGLQuery): void;
  124696. beginQuery(target: number, query: WebGLQuery): void;
  124697. endQuery(target: number): void;
  124698. getQueryParameter(query: WebGLQuery, pname: number): any;
  124699. getQuery(target: number, pname: number): any;
  124700. MAX_SAMPLES: number;
  124701. RGBA8: number;
  124702. READ_FRAMEBUFFER: number;
  124703. DRAW_FRAMEBUFFER: number;
  124704. UNIFORM_BUFFER: number;
  124705. HALF_FLOAT_OES: number;
  124706. RGBA16F: number;
  124707. RGBA32F: number;
  124708. R32F: number;
  124709. RG32F: number;
  124710. RGB32F: number;
  124711. R16F: number;
  124712. RG16F: number;
  124713. RGB16F: number;
  124714. RED: number;
  124715. RG: number;
  124716. R8: number;
  124717. RG8: number;
  124718. UNSIGNED_INT_24_8: number;
  124719. DEPTH24_STENCIL8: number;
  124720. /* Multiple Render Targets */
  124721. drawBuffers(buffers: number[]): void;
  124722. readBuffer(src: number): void;
  124723. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  124724. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  124725. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  124726. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  124727. // Occlusion Query
  124728. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  124729. ANY_SAMPLES_PASSED: number;
  124730. QUERY_RESULT_AVAILABLE: number;
  124731. QUERY_RESULT: number;
  124732. }
  124733. interface WebGLProgram {
  124734. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  124735. }
  124736. interface EXT_disjoint_timer_query {
  124737. QUERY_COUNTER_BITS_EXT: number;
  124738. TIME_ELAPSED_EXT: number;
  124739. TIMESTAMP_EXT: number;
  124740. GPU_DISJOINT_EXT: number;
  124741. QUERY_RESULT_EXT: number;
  124742. QUERY_RESULT_AVAILABLE_EXT: number;
  124743. queryCounterEXT(query: WebGLQuery, target: number): void;
  124744. createQueryEXT(): WebGLQuery;
  124745. beginQueryEXT(target: number, query: WebGLQuery): void;
  124746. endQueryEXT(target: number): void;
  124747. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  124748. deleteQueryEXT(query: WebGLQuery): void;
  124749. }
  124750. interface WebGLUniformLocation {
  124751. _currentState: any;
  124752. }
  124753. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  124754. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  124755. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  124756. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124757. interface WebGLRenderingContext {
  124758. readonly RASTERIZER_DISCARD: number;
  124759. readonly DEPTH_COMPONENT24: number;
  124760. readonly TEXTURE_3D: number;
  124761. readonly TEXTURE_2D_ARRAY: number;
  124762. readonly TEXTURE_COMPARE_FUNC: number;
  124763. readonly TEXTURE_COMPARE_MODE: number;
  124764. readonly COMPARE_REF_TO_TEXTURE: number;
  124765. readonly TEXTURE_WRAP_R: number;
  124766. readonly HALF_FLOAT: number;
  124767. readonly RGB8: number;
  124768. readonly RED_INTEGER: number;
  124769. readonly RG_INTEGER: number;
  124770. readonly RGB_INTEGER: number;
  124771. readonly RGBA_INTEGER: number;
  124772. readonly R8_SNORM: number;
  124773. readonly RG8_SNORM: number;
  124774. readonly RGB8_SNORM: number;
  124775. readonly RGBA8_SNORM: number;
  124776. readonly R8I: number;
  124777. readonly RG8I: number;
  124778. readonly RGB8I: number;
  124779. readonly RGBA8I: number;
  124780. readonly R8UI: number;
  124781. readonly RG8UI: number;
  124782. readonly RGB8UI: number;
  124783. readonly RGBA8UI: number;
  124784. readonly R16I: number;
  124785. readonly RG16I: number;
  124786. readonly RGB16I: number;
  124787. readonly RGBA16I: number;
  124788. readonly R16UI: number;
  124789. readonly RG16UI: number;
  124790. readonly RGB16UI: number;
  124791. readonly RGBA16UI: number;
  124792. readonly R32I: number;
  124793. readonly RG32I: number;
  124794. readonly RGB32I: number;
  124795. readonly RGBA32I: number;
  124796. readonly R32UI: number;
  124797. readonly RG32UI: number;
  124798. readonly RGB32UI: number;
  124799. readonly RGBA32UI: number;
  124800. readonly RGB10_A2UI: number;
  124801. readonly R11F_G11F_B10F: number;
  124802. readonly RGB9_E5: number;
  124803. readonly RGB10_A2: number;
  124804. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  124805. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  124806. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  124807. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  124808. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  124809. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  124810. 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;
  124811. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  124812. readonly TRANSFORM_FEEDBACK: number;
  124813. readonly INTERLEAVED_ATTRIBS: number;
  124814. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  124815. createTransformFeedback(): WebGLTransformFeedback;
  124816. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  124817. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  124818. beginTransformFeedback(primitiveMode: number): void;
  124819. endTransformFeedback(): void;
  124820. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  124821. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124822. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124823. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124824. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  124825. }
  124826. interface ImageBitmap {
  124827. readonly width: number;
  124828. readonly height: number;
  124829. close(): void;
  124830. }
  124831. interface WebGLQuery extends WebGLObject {
  124832. }
  124833. declare var WebGLQuery: {
  124834. prototype: WebGLQuery;
  124835. new(): WebGLQuery;
  124836. };
  124837. interface WebGLSampler extends WebGLObject {
  124838. }
  124839. declare var WebGLSampler: {
  124840. prototype: WebGLSampler;
  124841. new(): WebGLSampler;
  124842. };
  124843. interface WebGLSync extends WebGLObject {
  124844. }
  124845. declare var WebGLSync: {
  124846. prototype: WebGLSync;
  124847. new(): WebGLSync;
  124848. };
  124849. interface WebGLTransformFeedback extends WebGLObject {
  124850. }
  124851. declare var WebGLTransformFeedback: {
  124852. prototype: WebGLTransformFeedback;
  124853. new(): WebGLTransformFeedback;
  124854. };
  124855. interface WebGLVertexArrayObject extends WebGLObject {
  124856. }
  124857. declare var WebGLVertexArrayObject: {
  124858. prototype: WebGLVertexArrayObject;
  124859. new(): WebGLVertexArrayObject;
  124860. };
  124861. // Type definitions for WebVR API
  124862. // Project: https://w3c.github.io/webvr/
  124863. // Definitions by: six a <https://github.com/lostfictions>
  124864. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124865. interface VRDisplay extends EventTarget {
  124866. /**
  124867. * Dictionary of capabilities describing the VRDisplay.
  124868. */
  124869. readonly capabilities: VRDisplayCapabilities;
  124870. /**
  124871. * z-depth defining the far plane of the eye view frustum
  124872. * enables mapping of values in the render target depth
  124873. * attachment to scene coordinates. Initially set to 10000.0.
  124874. */
  124875. depthFar: number;
  124876. /**
  124877. * z-depth defining the near plane of the eye view frustum
  124878. * enables mapping of values in the render target depth
  124879. * attachment to scene coordinates. Initially set to 0.01.
  124880. */
  124881. depthNear: number;
  124882. /**
  124883. * An identifier for this distinct VRDisplay. Used as an
  124884. * association point in the Gamepad API.
  124885. */
  124886. readonly displayId: number;
  124887. /**
  124888. * A display name, a user-readable name identifying it.
  124889. */
  124890. readonly displayName: string;
  124891. readonly isConnected: boolean;
  124892. readonly isPresenting: boolean;
  124893. /**
  124894. * If this VRDisplay supports room-scale experiences, the optional
  124895. * stage attribute contains details on the room-scale parameters.
  124896. */
  124897. readonly stageParameters: VRStageParameters | null;
  124898. /**
  124899. * Passing the value returned by `requestAnimationFrame` to
  124900. * `cancelAnimationFrame` will unregister the callback.
  124901. * @param handle Define the hanle of the request to cancel
  124902. */
  124903. cancelAnimationFrame(handle: number): void;
  124904. /**
  124905. * Stops presenting to the VRDisplay.
  124906. * @returns a promise to know when it stopped
  124907. */
  124908. exitPresent(): Promise<void>;
  124909. /**
  124910. * Return the current VREyeParameters for the given eye.
  124911. * @param whichEye Define the eye we want the parameter for
  124912. * @returns the eye parameters
  124913. */
  124914. getEyeParameters(whichEye: string): VREyeParameters;
  124915. /**
  124916. * Populates the passed VRFrameData with the information required to render
  124917. * the current frame.
  124918. * @param frameData Define the data structure to populate
  124919. * @returns true if ok otherwise false
  124920. */
  124921. getFrameData(frameData: VRFrameData): boolean;
  124922. /**
  124923. * Get the layers currently being presented.
  124924. * @returns the list of VR layers
  124925. */
  124926. getLayers(): VRLayer[];
  124927. /**
  124928. * Return a VRPose containing the future predicted pose of the VRDisplay
  124929. * when the current frame will be presented. The value returned will not
  124930. * change until JavaScript has returned control to the browser.
  124931. *
  124932. * The VRPose will contain the position, orientation, velocity,
  124933. * and acceleration of each of these properties.
  124934. * @returns the pose object
  124935. */
  124936. getPose(): VRPose;
  124937. /**
  124938. * Return the current instantaneous pose of the VRDisplay, with no
  124939. * prediction applied.
  124940. * @returns the current instantaneous pose
  124941. */
  124942. getImmediatePose(): VRPose;
  124943. /**
  124944. * The callback passed to `requestAnimationFrame` will be called
  124945. * any time a new frame should be rendered. When the VRDisplay is
  124946. * presenting the callback will be called at the native refresh
  124947. * rate of the HMD. When not presenting this function acts
  124948. * identically to how window.requestAnimationFrame acts. Content should
  124949. * make no assumptions of frame rate or vsync behavior as the HMD runs
  124950. * asynchronously from other displays and at differing refresh rates.
  124951. * @param callback Define the eaction to run next frame
  124952. * @returns the request handle it
  124953. */
  124954. requestAnimationFrame(callback: FrameRequestCallback): number;
  124955. /**
  124956. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  124957. * Repeat calls while already presenting will update the VRLayers being displayed.
  124958. * @param layers Define the list of layer to present
  124959. * @returns a promise to know when the request has been fulfilled
  124960. */
  124961. requestPresent(layers: VRLayer[]): Promise<void>;
  124962. /**
  124963. * Reset the pose for this display, treating its current position and
  124964. * orientation as the "origin/zero" values. VRPose.position,
  124965. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  124966. * updated when calling resetPose(). This should be called in only
  124967. * sitting-space experiences.
  124968. */
  124969. resetPose(): void;
  124970. /**
  124971. * The VRLayer provided to the VRDisplay will be captured and presented
  124972. * in the HMD. Calling this function has the same effect on the source
  124973. * canvas as any other operation that uses its source image, and canvases
  124974. * created without preserveDrawingBuffer set to true will be cleared.
  124975. * @param pose Define the pose to submit
  124976. */
  124977. submitFrame(pose?: VRPose): void;
  124978. }
  124979. declare var VRDisplay: {
  124980. prototype: VRDisplay;
  124981. new(): VRDisplay;
  124982. };
  124983. interface VRLayer {
  124984. leftBounds?: number[] | Float32Array | null;
  124985. rightBounds?: number[] | Float32Array | null;
  124986. source?: HTMLCanvasElement | null;
  124987. }
  124988. interface VRDisplayCapabilities {
  124989. readonly canPresent: boolean;
  124990. readonly hasExternalDisplay: boolean;
  124991. readonly hasOrientation: boolean;
  124992. readonly hasPosition: boolean;
  124993. readonly maxLayers: number;
  124994. }
  124995. interface VREyeParameters {
  124996. /** @deprecated */
  124997. readonly fieldOfView: VRFieldOfView;
  124998. readonly offset: Float32Array;
  124999. readonly renderHeight: number;
  125000. readonly renderWidth: number;
  125001. }
  125002. interface VRFieldOfView {
  125003. readonly downDegrees: number;
  125004. readonly leftDegrees: number;
  125005. readonly rightDegrees: number;
  125006. readonly upDegrees: number;
  125007. }
  125008. interface VRFrameData {
  125009. readonly leftProjectionMatrix: Float32Array;
  125010. readonly leftViewMatrix: Float32Array;
  125011. readonly pose: VRPose;
  125012. readonly rightProjectionMatrix: Float32Array;
  125013. readonly rightViewMatrix: Float32Array;
  125014. readonly timestamp: number;
  125015. }
  125016. interface VRPose {
  125017. readonly angularAcceleration: Float32Array | null;
  125018. readonly angularVelocity: Float32Array | null;
  125019. readonly linearAcceleration: Float32Array | null;
  125020. readonly linearVelocity: Float32Array | null;
  125021. readonly orientation: Float32Array | null;
  125022. readonly position: Float32Array | null;
  125023. readonly timestamp: number;
  125024. }
  125025. interface VRStageParameters {
  125026. sittingToStandingTransform?: Float32Array;
  125027. sizeX?: number;
  125028. sizeY?: number;
  125029. }
  125030. interface Navigator {
  125031. getVRDisplays(): Promise<VRDisplay[]>;
  125032. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  125033. }
  125034. interface Window {
  125035. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  125036. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  125037. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  125038. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125039. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125040. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  125041. }
  125042. interface Gamepad {
  125043. readonly displayId: number;
  125044. }
  125045. type XRSessionMode =
  125046. | "inline"
  125047. | "immersive-vr"
  125048. | "immersive-ar";
  125049. type XRReferenceSpaceType =
  125050. | "viewer"
  125051. | "local"
  125052. | "local-floor"
  125053. | "bounded-floor"
  125054. | "unbounded";
  125055. type XREnvironmentBlendMode =
  125056. | "opaque"
  125057. | "additive"
  125058. | "alpha-blend";
  125059. type XRVisibilityState =
  125060. | "visible"
  125061. | "visible-blurred"
  125062. | "hidden";
  125063. type XRHandedness =
  125064. | "none"
  125065. | "left"
  125066. | "right";
  125067. type XRTargetRayMode =
  125068. | "gaze"
  125069. | "tracked-pointer"
  125070. | "screen";
  125071. type XREye =
  125072. | "none"
  125073. | "left"
  125074. | "right";
  125075. interface XRSpace extends EventTarget {
  125076. }
  125077. interface XRRenderState {
  125078. depthNear?: number;
  125079. depthFar?: number;
  125080. inlineVerticalFieldOfView?: number;
  125081. baseLayer?: XRWebGLLayer;
  125082. }
  125083. interface XRInputSource {
  125084. handedness: XRHandedness;
  125085. targetRayMode: XRTargetRayMode;
  125086. targetRaySpace: XRSpace;
  125087. gripSpace: XRSpace | undefined;
  125088. gamepad: Gamepad | undefined;
  125089. profiles: Array<string>;
  125090. }
  125091. interface XRSession {
  125092. addEventListener: Function;
  125093. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125094. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  125095. requestAnimationFrame: Function;
  125096. end(): Promise<void>;
  125097. renderState: XRRenderState;
  125098. inputSources: Array<XRInputSource>;
  125099. }
  125100. interface XRReferenceSpace extends XRSpace {
  125101. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  125102. onreset: any;
  125103. }
  125104. interface XRFrame {
  125105. session: XRSession;
  125106. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  125107. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  125108. }
  125109. interface XRViewerPose extends XRPose {
  125110. views: Array<XRView>;
  125111. }
  125112. interface XRPose {
  125113. transform: XRRigidTransform;
  125114. emulatedPosition: boolean;
  125115. }
  125116. declare var XRWebGLLayer: {
  125117. prototype: XRWebGLLayer;
  125118. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  125119. };
  125120. interface XRWebGLLayer {
  125121. framebuffer: WebGLFramebuffer;
  125122. framebufferWidth: number;
  125123. framebufferHeight: number;
  125124. getViewport: Function;
  125125. }
  125126. interface XRRigidTransform {
  125127. position: DOMPointReadOnly;
  125128. orientation: DOMPointReadOnly;
  125129. matrix: Float32Array;
  125130. inverse: XRRigidTransform;
  125131. }
  125132. interface XRView {
  125133. eye: XREye;
  125134. projectionMatrix: Float32Array;
  125135. transform: XRRigidTransform;
  125136. }
  125137. interface XRInputSourceChangeEvent {
  125138. session: XRSession;
  125139. removed: Array<XRInputSource>;
  125140. added: Array<XRInputSource>;
  125141. }